+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>
* src/virsh.c: patch from Masayuki Sunou to fix parameter
attr = xmlGetProp(cur, BAD_CAST "dev");
if (attr == NULL)
goto error;
- strncpy(ref, (char *) attr, ref_len);
- ref[ref_len - 1] = '\0';
- goto cleanup;
+#ifdef WITH_XEN
+ xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
+ (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")) {
strcpy(class, "vif");
ref[ref_len - 1] = '\0';
goto cleanup;
}
-#else /* without xen */
+#else /* !WITH_XEN */
/* hack to avoid the warning that domain is unused */
if (domain->id < 0)
ret = -1;
-#endif /* WITH_XEN */
+#endif /* !WITH_XEN */
goto error;
}
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,
int id) {
char prop[200];