]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commitdiff
usb hotplug in qemu-dm via xm
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 20 Oct 2009 14:16:34 +0000 (15:16 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 28 Oct 2009 16:25:56 +0000 (16:25 +0000)
Add the two commands( "xm usb-add" and "xm usb-del") to add or delete
the usb device instead of do it in QEMU console.

Signed-off-by: James Song Wei <jsong@novell.com<mailto:jsong@novell.com>>
(cherry picked from commit a3285ff385d2568f0226f15fee2b9808ec3b6deb)

xenstore.c

index 9360771b3c37156bfa56b2d75e31aabbba886b7c..46915fb6959af2759e4cc15854736ec24130e5fe 100644 (file)
@@ -819,6 +819,34 @@ static void xenstore_process_dm_command_event(void)
     } else if (!strncmp(command, "continue", len)) {
         fprintf(logfile, "dm-command: continue after state save\n");
         xen_pause_requested = 0;
+    } else if (!strncmp(command, "usb-add", len)) {
+        fprintf(logfile, "dm-command: usb-add a usb device\n");
+        if (pasprintf(&path,
+                "/local/domain/0/device-model/%u/parameter", domid) == -1) {
+            fprintf(logfile, "out of memory reading dm command parameter\n");
+            goto out;
+        }
+        par = xs_read(xsh, XBT_NULL, path, &len);
+        fprintf(logfile, "dm-command: usb-add a usb device: %s \n", par);
+        if (!par)
+            goto out;
+        do_usb_add(par);
+        xenstore_record_dm_state("usb-added");
+        fprintf(logfile, "dm-command: finish usb-add a usb device:%s\n",par);
+    } else if (!strncmp(command, "usb-del", len)) {
+        fprintf(logfile, "dm-command: usb-del a usb device\n");
+        if (pasprintf(&path,
+                "/local/domain/0/device-model/%u/parameter", domid) == -1) {
+            fprintf(logfile, "out of memory reading dm command parameter\n");
+            goto out;
+        }
+        par = xs_read(xsh, XBT_NULL, path, &len);
+        fprintf(logfile, "dm-command: usb-del a usb device: %s \n", par);
+        if (!par)
+            goto out;
+        do_usb_del(par);
+        xenstore_record_dm_state("usb-deleted");
+        fprintf(logfile, "dm-command: finish usb-del a usb device:%s\n",par);
 #ifdef CONFIG_PASSTHROUGH
     } else if (!strncmp(command, "pci-rem", len)) {
         fprintf(logfile, "dm-command: hot remove pass-through pci dev \n");