File xen-name-for-devid.patch of Package libvirt (Revision f883e99974fd769898fafe341039e7ba)
Currently displaying revision f883e99974fd769898fafe341039e7ba, show latest
1
commit 7906a668fa8d5c21cc729db8a13b08e3dd1d241f
2
Author: Jim Fehlig <jfehlig@novell.com>
3
Date: Wed Jan 27 16:11:41 2010 -0700
4
5
Do not search xenstore for disk device IDs
6
7
Disk devices can be referenced by name in Xen, e.g. when modifying
8
their configuration or remvoving them. As such, don't search
9
xenstore for a device ID corresponding to the disk device. Instead,
10
search the disks contained in the domain definition and use the
11
disk's target name if found.
12
13
This approach allows removing a disk when domain is inactive. We
14
obviously can't search xenstore when the domain is inactive.
15
16
Index: libvirt-0.9.2/src/xen/xend_internal.c
17
===================================================================
18
--- libvirt-0.9.2.orig/src/xen/xend_internal.c
19
+++ libvirt-0.9.2/src/xen/xend_internal.c
20
21
22
static int
23
virDomainXMLDevID(virDomainPtr domain,
24
+ virDomainDefPtr domDef,
25
virDomainDeviceDefPtr dev,
26
char *class,
27
char *ref,
28
29
30
sexpr = virBufferContentAndReset(&buf);
31
32
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) {
33
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref))) {
34
/* device doesn't exist, define it */
35
ret = xend_op(domain->conn, domain->name, "op", "device_create",
36
"config", sexpr, NULL);
37
38
39
sexpr = virBufferContentAndReset(&buf);
40
41
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) {
42
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref))) {
43
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
44
_("requested device does not exist"));
45
goto cleanup;
46
47
def, xml, VIR_DOMAIN_XML_INACTIVE)))
48
goto cleanup;
49
50
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref)))
51
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref)))
52
goto cleanup;
53
54
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
55
56
*/
57
static int
58
virDomainXMLDevID(virDomainPtr domain,
59
+ virDomainDefPtr domDef,
60
virDomainDeviceDefPtr dev,
61
char *class,
62
char *ref,
63
64
xenUnifiedPrivatePtr priv = domain->conn->privateData;
65
char *xref;
66
char *tmp;
67
+ unsigned int i;
68
+ virDomainDiskDefPtr disk;
69
70
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
71
+ if (dev->data.disk->dst == NULL)
72
+ return -1;
73
if (dev->data.disk->driverName &&
74
STREQ(dev->data.disk->driverName, "tap"))
75
strcpy(class, "tap");
76
77
else
78
strcpy(class, "vbd");
79
80
- if (dev->data.disk->dst == NULL)
81
- return -1;
82
- xenUnifiedLock(priv);
83
- xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
84
- dev->data.disk->dst);
85
- xenUnifiedUnlock(priv);
86
- if (xref == NULL)
87
- return -1;
88
-
89
- tmp = virStrcpy(ref, xref, ref_len);
90
- VIR_FREE(xref);
91
- if (tmp == NULL)
92
- return -1;
93
+ /* For disks, the device name can be used directly.
94
+ * If disk device exists in domain definintion,
95
+ * copy it to ref and return success.
96
+ */
97
+ for (i = 0; i < domDef->ndisks; i++) {
98
+ disk = domDef->disks[i];
99
+ if (STREQ(dev->data.disk->dst, disk->dst)) {
100
+ tmp = virStrcpy(ref, disk->dst, ref_len);
101
+ if (tmp == NULL)
102
+ return -1;
103
+ else
104
+ return 0;
105
+ }
106
+ }
107
+ return -1;
108
} else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
109
char mac[30];
110
virDomainNetDefPtr def = dev->data.net;
111