WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xm, xend: Add commands to hotplug usb dev

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xm, xend: Add commands to hotplug usb devices to hvm guests
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Oct 2009 04:00:20 -0700
Delivery-date: Mon, 19 Oct 2009 04:00:30 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1255945727 -3600
# Node ID b84064697e4d59f379a52f1abf13ce80f78a90d8
# Parent  9482554734fc9bb9a50ab0993c1e8755c3c5c0c0
xm,xend: Add commands to hotplug usb devices to hvm guests
Signed-off-by: James Song Wei <jsong@xxxxxxxxxx>
---
 tools/python/xen/xend/XendDomain.py       |   39 ++++++++++++++++++++++++++++++
 tools/python/xen/xend/server/SrvDomain.py |   13 ++++++++++
 tools/python/xen/xm/main.py               |   18 +++++++++++++
 3 files changed, 70 insertions(+)

diff -r 9482554734fc -r b84064697e4d tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Mon Oct 19 10:47:09 2009 +0100
+++ b/tools/python/xen/xend/XendDomain.py       Mon Oct 19 10:48:47 2009 +0100
@@ -1522,6 +1522,45 @@ class XendDomain:
             raise XendError("can't write guest state file %s: %s" %
                             (dst, ex[1]))
 
+    def domain_usb_add(self, domid, dev_id):
+        dominfo = self.domain_lookup_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
+
+        usb = dominfo.info['platform'].get('usb')
+        if not usb:
+            raise XendError("Can't add usb device to a guest with usb disabled 
in configure file")
+
+        hvm = dominfo.info.is_hvm()
+        if not hvm:
+            raise XendError("Can't add usb device to a non-hvm guest")
+
+        if dominfo._stateGet() != DOM_STATE_HALTED:
+            dominfo.image.signalDeviceModel("usb-add",
+                "usb-added", dev_id)
+        else:
+            log.debug("error: Domain is not running!")
+
+
+    def domain_usb_del(self, domid, dev_id):
+        dominfo = self.domain_lookup_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
+
+        usb = dominfo.info['platform'].get('usb')
+        if not usb:
+            raise XendError("Can't add usb device to a guest with usb disabled 
in configure file")
+
+        hvm = dominfo.info.is_hvm()
+        if not hvm:
+            raise XendError("Can't del usb to a non-hvm guest")
+
+        if dominfo._stateGet() != DOM_STATE_HALTED:
+            dominfo.image.signalDeviceModel("usb-del",
+                "usb-deleted", dev_id)
+        else:
+            log.debug("error: Domain is not running!")
+
     def domain_pincpu(self, domid, vcpu, cpumap):
         """Set which cpus vcpu can use
 
diff -r 9482554734fc -r b84064697e4d tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:47:09 2009 +0100
+++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:48:47 2009 +0100
@@ -225,6 +225,19 @@ class SrvDomain(SrvDir):
         self.acceptCommand(req)
         return self.xd.domain_reset(self.dom.getName())
 
+    def op_usb_add(self, op, req):
+        self.acceptCommand(req)
+        return req.threadRequest(self.do_usb_add, op, req)
+
+    def do_usb_add(self, _, req):
+        return self.xd.domain_usb_add(self.dom.getName(), req)
+ 
+    def op_usb_del(self, op, req):
+        self.acceptCommand(req)
+        return req.threadRequest(self.do_usb_add, op, req)
+
+    def do_usb_del(self, _, req):
+        return self.xd.domain_usb_add(self.dom.getName(), req)
 
     def render_POST(self, req):
         return self.perform(req)
diff -r 9482554734fc -r b84064697e4d tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Mon Oct 19 10:47:09 2009 +0100
+++ b/tools/python/xen/xm/main.py       Mon Oct 19 10:48:47 2009 +0100
@@ -161,6 +161,9 @@ SUBCOMMAND_HELP = {
     'vcpu-set'    : ('<Domain> <vCPUs>',
                      'Set the number of active VCPUs for allowed for the'
                      ' domain.'),
+    #usb
+    'usb-add'     : ('<domain> <[host:bus.addr] 
[host:vendor_id:product_id]>','Add the usb device to FV VM.'),
+    'usb-del'     : ('<domain> <[host:bus.addr] 
[host:vendor_id:product_id]>','Delete the usb device to FV VM.'),
 
     # device commands
 
@@ -351,6 +354,8 @@ common_commands = [
     "top",
     "unpause",
     "uptime",
+    "usb-add",
+    "usb-del",
     "vcpu-set",
     ]
 
@@ -383,6 +388,8 @@ domain_commands = [
     "top",
     "unpause",
     "uptime",
+    "usb-add",
+    "usb-del",
     "vcpu-list",
     "vcpu-pin",
     "vcpu-set",
@@ -1474,6 +1481,14 @@ def xm_mem_set(args):
     else:
         mem_target = int_unit(args[1], 'm')
         server.xend.domain.setMemoryTarget(dom, mem_target)
+
+def xm_usb_add(args):
+    arg_check(args, "usb-add", 2)
+    server.xend.domain.usb_add(args[0],args[1])
+
+def xm_usb_del(args):
+    arg_check(args, "usb-del", 2)
+    server.xend.domain.usb_del(args[0],args[1])
     
 def xm_vcpu_set(args):
     arg_check(args, "vcpu-set", 2)
@@ -3312,6 +3327,9 @@ commands = {
     "tmem-set": xm_tmem_set,
     "tmem-freeable": xm_tmem_freeable_mb,
     "tmem-shared-auth": xm_tmem_shared_auth,
+    #usb
+    "usb-add": xm_usb_add,
+    "usb-del": xm_usb_del,
     }
 
 ## The commands supported by a separate argument parser in xend.xm.

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xm, xend: Add commands to hotplug usb devices to hvm guests, Xen patchbot-unstable <=