2010-01-28 02:07:11 +01:00
|
|
|
commit 7906a668fa8d5c21cc729db8a13b08e3dd1d241f
|
|
|
|
Author: Jim Fehlig <jfehlig@novell.com>
|
|
|
|
Date: Wed Jan 27 16:11:41 2010 -0700
|
|
|
|
|
|
|
|
Do not search xenstore for disk device IDs
|
|
|
|
|
|
|
|
Disk devices can be referenced by name in Xen, e.g. when modifying
|
|
|
|
their configuration or remvoving them. As such, don't search
|
|
|
|
xenstore for a device ID corresponding to the disk device. Instead,
|
|
|
|
search the disks contained in the domain definition and use the
|
|
|
|
disk's target name if found.
|
|
|
|
|
|
|
|
This approach allows removing a disk when domain is inactive. We
|
|
|
|
obviously can't search xenstore when the domain is inactive.
|
|
|
|
|
2012-01-09 23:51:36 +01:00
|
|
|
Index: libvirt-0.9.9/src/xen/xend_internal.c
|
2010-01-28 02:07:11 +01:00
|
|
|
===================================================================
|
2012-01-09 23:51:36 +01:00
|
|
|
--- libvirt-0.9.9.orig/src/xen/xend_internal.c
|
|
|
|
+++ libvirt-0.9.9/src/xen/xend_internal.c
|
2011-06-02 20:32:33 +02:00
|
|
|
@@ -60,6 +60,7 @@
|
2010-01-28 02:07:11 +01:00
|
|
|
|
|
|
|
static int
|
|
|
|
virDomainXMLDevID(virDomainPtr domain,
|
|
|
|
+ virDomainDefPtr domDef,
|
|
|
|
virDomainDeviceDefPtr dev,
|
|
|
|
char *class,
|
|
|
|
char *ref,
|
2012-01-09 23:51:36 +01:00
|
|
|
@@ -2752,7 +2753,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr
|
2010-01-28 02:07:11 +01:00
|
|
|
|
|
|
|
sexpr = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) {
|
|
|
|
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref))) {
|
|
|
|
/* device doesn't exist, define it */
|
|
|
|
ret = xend_op(domain->conn, domain->name, "op", "device_create",
|
|
|
|
"config", sexpr, NULL);
|
2012-01-09 23:51:36 +01:00
|
|
|
@@ -2873,7 +2874,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr
|
2010-04-16 00:56:55 +02:00
|
|
|
|
|
|
|
sexpr = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) {
|
|
|
|
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref))) {
|
|
|
|
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("requested device does not exist"));
|
|
|
|
goto cleanup;
|
2012-01-09 23:51:36 +01:00
|
|
|
@@ -2968,7 +2969,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr
|
2010-01-28 02:07:11 +01:00
|
|
|
def, xml, VIR_DOMAIN_XML_INACTIVE)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref)))
|
|
|
|
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
2012-01-09 23:51:36 +01:00
|
|
|
@@ -3916,6 +3917,7 @@ struct xenUnifiedDriver xenDaemonDriver
|
2010-01-28 02:07:11 +01:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virDomainXMLDevID(virDomainPtr domain,
|
|
|
|
+ virDomainDefPtr domDef,
|
|
|
|
virDomainDeviceDefPtr dev,
|
|
|
|
char *class,
|
|
|
|
char *ref,
|
2012-01-09 23:51:36 +01:00
|
|
|
@@ -3924,8 +3926,12 @@ virDomainXMLDevID(virDomainPtr domain,
|
2010-01-28 02:07:11 +01:00
|
|
|
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
|
|
|
char *xref;
|
|
|
|
char *tmp;
|
|
|
|
+ unsigned int i;
|
|
|
|
+ virDomainDiskDefPtr disk;
|
|
|
|
|
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
|
|
|
+ if (dev->data.disk->dst == NULL)
|
|
|
|
+ return -1;
|
|
|
|
if (dev->data.disk->driverName &&
|
|
|
|
STREQ(dev->data.disk->driverName, "tap"))
|
|
|
|
strcpy(class, "tap");
|
2012-01-09 23:51:36 +01:00
|
|
|
@@ -3935,19 +3941,21 @@ virDomainXMLDevID(virDomainPtr domain,
|
2010-01-28 02:07:11 +01:00
|
|
|
else
|
|
|
|
strcpy(class, "vbd");
|
|
|
|
|
|
|
|
- if (dev->data.disk->dst == NULL)
|
|
|
|
- return -1;
|
|
|
|
- xenUnifiedLock(priv);
|
|
|
|
- xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
|
|
|
|
- dev->data.disk->dst);
|
|
|
|
- xenUnifiedUnlock(priv);
|
|
|
|
- if (xref == NULL)
|
|
|
|
- return -1;
|
|
|
|
-
|
|
|
|
- tmp = virStrcpy(ref, xref, ref_len);
|
|
|
|
- VIR_FREE(xref);
|
|
|
|
- if (tmp == NULL)
|
|
|
|
- return -1;
|
|
|
|
+ /* For disks, the device name can be used directly.
|
|
|
|
+ * If disk device exists in domain definintion,
|
|
|
|
+ * copy it to ref and return success.
|
|
|
|
+ */
|
|
|
|
+ for (i = 0; i < domDef->ndisks; i++) {
|
|
|
|
+ disk = domDef->disks[i];
|
|
|
|
+ if (STREQ(dev->data.disk->dst, disk->dst)) {
|
|
|
|
+ tmp = virStrcpy(ref, disk->dst, ref_len);
|
|
|
|
+ if (tmp == NULL)
|
|
|
|
+ return -1;
|
|
|
|
+ else
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return -1;
|
|
|
|
} else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
|
|
|
|
char mac[30];
|
|
|
|
virDomainNetDefPtr def = dev->data.net;
|