[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] [PATCH] Enable USB device setting information handling on virsh.



Hi

When domHVM started by virsh create, 
the information of USB setting is not saved by vish dumpxml.
The reason is that USB setting is defined by Xen itself, not virsh.

This patch enables USB device setting information handling 
on virsh create/virsh dumpxml.

Signed-off-by: Masayuki Sunou <fj1826dm aa jp fujitsu com>

Thanks,
Masayuki Sunou


Index: libvirt/src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.99
diff -u -p -r1.99 xend_internal.c
--- libvirt/src/xend_internal.c	6 Mar 2007 21:55:44 -0000	1.99
+++ libvirt/src/xend_internal.c	7 Mar 2007 08:28:55 -0000
@@ -1666,6 +1666,13 @@ xend_parse_sexp_desc(virConnectPtr conn,
         free(tty);
     }
 
+    tmp = sexpr_node(root, "domain/image/hvm/usbdevice");
+    if ((tmp != NULL) && (tmp[0] != 0)) {
+        virBufferVSprintf(&buf, "    <usb usbdevice='%s'/>\n", tmp);
+    } else if (sexpr_int(root, "domain/image/hvm/usb")) {
+        virBufferAdd(&buf, "    <usb/>\n", 11 );
+    }
+
     virBufferAdd(&buf, "  </devices>\n", 13);
     virBufferAdd(&buf, "</domain>\n", 10);
 
Index: libvirt/src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.62
diff -u -p -r1.62 xml.c
--- libvirt/src/xml.c	6 Mar 2007 20:00:17 -0000	1.62
+++ libvirt/src/xml.c	7 Mar 2007 08:28:55 -0000
@@ -524,6 +524,20 @@ virDomainParseXMLOSDescHVM(virConnectPtr
     }
     xmlXPathFreeObject(obj);
 
+    obj = xmlXPathEval(BAD_CAST "/domain/devices/usb", ctxt);
+    if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+        (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+        virBufferAdd(buf, "(usb 1)", 7);
+        xmlXPathFreeObject(obj);
+        obj = xmlXPathEval(BAD_CAST "string(/domain/devices/usb/@usbdevice)", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_STRING) &&
+            (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
+            virBufferVSprintf(buf, "(usbdevice '%s')", obj->stringval);
+        }
+    }
+    if (obj)
+        xmlXPathFreeObject(obj);
+
     virBufferAdd(buf, "))", 2);
 
     if (boot_dev)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]