mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 10:03:49 +03:00
* src/xml.c src/xs_internal.c src/xs_internal.h: applied patch
from Masayuki Sunou to fix xend errors when adding disk devices, due to improper device id lookup. Daniel
This commit is contained in:
parent
31eade077e
commit
9899932303
@ -1,3 +1,9 @@
|
|||||||
|
Tue Nov 6 12:42:55 CET 2007 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/xml.c src/xs_internal.c src/xs_internal.h: applied patch
|
||||||
|
from Masayuki Sunou to fix xend errors when adding disk
|
||||||
|
devices, due to improper device id lookup.
|
||||||
|
|
||||||
Tue Nov 6 10:40:13 CET 2007 Daniel Veillard <veillard@redhat.com>
|
Tue Nov 6 10:40:13 CET 2007 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/virsh.c: patch from Masayuki Sunou to fix parameter
|
* src/virsh.c: patch from Masayuki Sunou to fix parameter
|
||||||
|
23
src/xml.c
23
src/xml.c
@ -1922,9 +1922,22 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
|
|||||||
attr = xmlGetProp(cur, BAD_CAST "dev");
|
attr = xmlGetProp(cur, BAD_CAST "dev");
|
||||||
if (attr == NULL)
|
if (attr == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
strncpy(ref, (char *) attr, ref_len);
|
#ifdef WITH_XEN
|
||||||
ref[ref_len - 1] = '\0';
|
xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
|
||||||
goto cleanup;
|
(char *) attr);
|
||||||
|
if (xref != NULL) {
|
||||||
|
strncpy(ref, xref, ref_len);
|
||||||
|
free(xref);
|
||||||
|
ref[ref_len - 1] = '\0';
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
#else /* !WITH_XEN */
|
||||||
|
/* hack to avoid the warning that domain is unused */
|
||||||
|
if (domain->id < 0)
|
||||||
|
ret = -1;
|
||||||
|
#endif /* !WITH_XEN */
|
||||||
|
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
|
} else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
|
||||||
strcpy(class, "vif");
|
strcpy(class, "vif");
|
||||||
@ -1945,11 +1958,11 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
|
|||||||
ref[ref_len - 1] = '\0';
|
ref[ref_len - 1] = '\0';
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
#else /* without xen */
|
#else /* !WITH_XEN */
|
||||||
/* hack to avoid the warning that domain is unused */
|
/* hack to avoid the warning that domain is unused */
|
||||||
if (domain->id < 0)
|
if (domain->id < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
#endif /* WITH_XEN */
|
#endif /* !WITH_XEN */
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -879,6 +879,58 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xenStoreDomainGetDiskID:
|
||||||
|
* @conn: pointer to the connection.
|
||||||
|
* @id: the domain id
|
||||||
|
* @dev: the virtual block device name
|
||||||
|
*
|
||||||
|
* Get the reference (i.e. the string number) for the device on that domain
|
||||||
|
* which uses the given virtual block device name
|
||||||
|
*
|
||||||
|
* Returns the new string or NULL in case of error, the string must be
|
||||||
|
* freed by the caller.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev) {
|
||||||
|
char dir[80], path[128], **list = NULL, *val = NULL;
|
||||||
|
unsigned int devlen, len, i, num;
|
||||||
|
char *ret = NULL;
|
||||||
|
xenUnifiedPrivatePtr priv;
|
||||||
|
|
||||||
|
if (id < 0)
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
priv = (xenUnifiedPrivatePtr) conn->privateData;
|
||||||
|
if (priv->xshandle == NULL)
|
||||||
|
return (NULL);
|
||||||
|
if (dev == NULL)
|
||||||
|
return (NULL);
|
||||||
|
devlen = strlen(dev);
|
||||||
|
if (devlen <= 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
snprintf(dir, sizeof(dir), "/local/domain/0/backend/vbd/%d", id);
|
||||||
|
list = xs_directory(priv->xshandle, 0, dir, &num);
|
||||||
|
if (list == NULL)
|
||||||
|
return(NULL);
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
|
snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "dev");
|
||||||
|
val = xs_read(priv->xshandle, 0, path, &len);
|
||||||
|
if (val == NULL)
|
||||||
|
break;
|
||||||
|
if ((devlen != len) || memcmp(val, dev, len)) {
|
||||||
|
free(val);
|
||||||
|
} else {
|
||||||
|
ret = strdup(list[i]);
|
||||||
|
free(val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(list);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
char *xenStoreDomainGetName(virConnectPtr conn,
|
char *xenStoreDomainGetName(virConnectPtr conn,
|
||||||
int id) {
|
int id) {
|
||||||
char prop[200];
|
char prop[200];
|
||||||
|
@ -50,6 +50,9 @@ char * xenStoreDomainGetOSTypeID(virConnectPtr conn,
|
|||||||
char * xenStoreDomainGetNetworkID(virConnectPtr conn,
|
char * xenStoreDomainGetNetworkID(virConnectPtr conn,
|
||||||
int id,
|
int id,
|
||||||
const char *mac);
|
const char *mac);
|
||||||
|
char * xenStoreDomainGetDiskID(virConnectPtr conn,
|
||||||
|
int id,
|
||||||
|
const char *mac);
|
||||||
char * xenStoreDomainGetName(virConnectPtr conn,
|
char * xenStoreDomainGetName(virConnectPtr conn,
|
||||||
int id);
|
int id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user