James Song
2009-Oct-15 08:12 UTC
[Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
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> diff -r 41dbce3c96ea tools/ioemu-remote/xenstore.c --- a/tools/ioemu-remote/xenstore.c Tue Oct 13 14:23:10 2009 +0800 +++ b/tools/ioemu-remote/xenstore.c Wed Oct 14 15:10:24 2009 +0800 @@ -908,6 +908,7 @@ char *path = NULL, *command = NULL, *par = NULL; unsigned int len; extern char* snapshot_name; + extern void do_usb_add(const char *devname); if (pasprintf(&path, "/local/domain/0/device-model/%u/command", domid) == -1) { @@ -932,6 +933,34 @@ } snapshot_name = xs_read(xsh, XBT_NULL, path, &len); + } 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); } else if (!strncmp(command, "snapshot-delete", len)) { if (pasprintf(&path, "/local/domain/0/device-model/%u/parameter", domid) == -1) { diff -r 41dbce3c96ea tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Tue Oct 13 14:23:10 2009 +0800 +++ b/tools/python/xen/xend/XendDomain.py Wed Oct 14 15:10:24 2009 +0800 @@ -1561,6 +1561,28 @@ raise XendError("Unable to read snapshot file file %s: %s" % (snap_file, ex[1])) + def domain_usb_add(self, domid, dev_id): + dominfo = self.domain_lookup_nr(domid) + if not dominfo: + raise XendInvalidDomain(str(domid)) + + 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)) + + 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_snapshot_delete(self, domid, name): """Delete domain snapshot diff -r 41dbce3c96ea tools/python/xen/xend/server/SrvDomain.py --- a/tools/python/xen/xend/server/SrvDomain.py Tue Oct 13 14:23:10 2009 +0800 +++ b/tools/python/xen/xend/server/SrvDomain.py Wed Oct 14 15:10:24 2009 +0800 @@ -120,6 +120,20 @@ def do_snapshot_delete(self, _, req): return self.xd.domain_snapshot_delete(self.dom.getName(), req.args[''name''][0]) + 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 op_dump(self, op, req): self.acceptCommand(req) return req.threadRequest(self.do_dump, op, req) diff -r 41dbce3c96ea tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Tue Oct 13 14:23:10 2009 +0800 +++ b/tools/python/xen/xm/main.py Wed Oct 14 15:10:24 2009 +0800 @@ -168,6 +168,9 @@ ''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 @@ -325,6 +328,8 @@ "top", "unpause", "uptime", + "usb-add", + "usb-del", "vcpu-set", ] @@ -361,6 +366,8 @@ "top", "unpause", "uptime", + "usb-add", + "usb-del", "vcpu-list", "vcpu-pin", "vcpu-set", @@ -1500,6 +1507,14 @@ 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) @@ -2990,6 +3005,9 @@ "scsi-attach": xm_scsi_attach, "scsi-detach": xm_scsi_detach, "scsi-list": xm_scsi_list, + #usb + "usb-add": xm_usb_add, + "usb-del": xm_usb_del, } ## The commands supported by a separate argument parser in xend.xm. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2009-Oct-15 08:46 UTC
Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
On 15/10/2009 09:12, "James Song" <jsong@novell.com> wrote:> 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>Again, given the weird encoding of your email this patch will probably turn out to be corrupted. But also you cannot patch tools/iomu-remote/ -- ioemu patches are to be applied to the separate qemu-xen-unstable.git repository and sent to the list cc''ed to Ian Jackson who maintains that repository. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Masaki Kanno
2009-Oct-15 08:51 UTC
Re: [Xen-devel] add the two command to add or delete the usb deviceinstead of do it in QEMU console
Hi James, I have a comment. If a target domain is Domain-0 or PV-domain, the commands should raise XendError with a suitable error message. Best regards, Kan Thu, 15 Oct 2009 02:12:49 -0600, "James Song" wrote:>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> >diff -r 41dbce3c96ea tools/ioemu-remote/xenstore.c >--- a/tools/ioemu-remote/xenstore.c Tue Oct 13 14:23:10 2009 +0800 >+++ b/tools/ioemu-remote/xenstore.c Wed Oct 14 15:10:24 2009 +0800 >@@ -908,6 +908,7 @@ > char *path = NULL, *command = NULL, *par = NULL; > unsigned int len; > extern char* snapshot_name; >+ extern void do_usb_add(const char *devname); > > if (pasprintf(&path, > "/local/domain/0/device-model/%u/command", domid) == -1) { >@@ -932,6 +933,34 @@ > } > > snapshot_name = xs_read(xsh, XBT_NULL, path, &len); >+ } 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); > } else if (!strncmp(command, "snapshot-delete", len)) { > if (pasprintf(&path, > "/local/domain/0/device-model/%u/parameter", domid) == -1) { >diff -r 41dbce3c96ea tools/python/xen/xend/XendDomain.py >--- a/tools/python/xen/xend/XendDomain.py Tue Oct 13 14:23:10 2009 + >0800 >+++ b/tools/python/xen/xend/XendDomain.py Wed Oct 14 15:10:24 2009 + >0800 >@@ -1561,6 +1561,28 @@ > raise XendError("Unable to read snapshot file file %s: %s" % > (snap_file, ex[1])) > >+ def domain_usb_add(self, domid, dev_id): >+ dominfo = self.domain_lookup_nr(domid) >+ if not dominfo: >+ raise XendInvalidDomain(str(domid)) >+ >+ 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)) >+ >+ 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_snapshot_delete(self, domid, name): > """Delete domain snapshot > >diff -r 41dbce3c96ea tools/python/xen/xend/server/SrvDomain.py >--- a/tools/python/xen/xend/server/SrvDomain.py Tue Oct 13 14:23:10 2009 + >0800 >+++ b/tools/python/xen/xend/server/SrvDomain.py Wed Oct 14 15:10:24 2009 + >0800 >@@ -120,6 +120,20 @@ > def do_snapshot_delete(self, _, req): > return self.xd.domain_snapshot_delete(self.dom.getName(), req.args >[''name''][0]) > >+ 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 op_dump(self, op, req): > self.acceptCommand(req) > return req.threadRequest(self.do_dump, op, req) >diff -r 41dbce3c96ea tools/python/xen/xm/main.py >--- a/tools/python/xen/xm/main.py Tue Oct 13 14:23:10 2009 +0800 >+++ b/tools/python/xen/xm/main.py Wed Oct 14 15:10:24 2009 +0800 >@@ -168,6 +168,9 @@ > ''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 > >@@ -325,6 +328,8 @@ > "top", > "unpause", > "uptime", >+ "usb-add", >+ "usb-del", > "vcpu-set", > ] > >@@ -361,6 +366,8 @@ > "top", > "unpause", > "uptime", >+ "usb-add", >+ "usb-del", > "vcpu-list", > "vcpu-pin", > "vcpu-set", >@@ -1500,6 +1507,14 @@ > 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) > >@@ -2990,6 +3005,9 @@ > "scsi-attach": xm_scsi_attach, > "scsi-detach": xm_scsi_detach, > "scsi-list": xm_scsi_list, >+ #usb >+ "usb-add": xm_usb_add, >+ "usb-del": xm_usb_del, > } > > ## The commands supported by a separate argument parser in xend.xm. > > > > >-------------------------------text/plain------------------------------- >_______________________________________________ >Xen-devel mailing list >Xen-devel@lists.xensource.com >http://lists.xensource.com/xen-devel > > >---html-part included links------- >mailto:jsong@novell.com_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Song
2009-Oct-15 09:11 UTC
Re: [Xen-devel] add the two command to add or delete the usb deviceinstead of do it in QEMU console
Yes, It should raise XendError when met that scenario. Thanks Kanno-san. I will adjust the patch to fit the unstable-tree and resend it. Thanks Keir. -James>>> Masaki Kanno <kanno.masaki@jp.fujitsu.com> 2009-10-15 16:51 >>>Hi James, I have a comment. If a target domain is Domain-0 or PV-domain, the commands should raise XendError with a suitable error message. Best regards, Kan Thu, 15 Oct 2009 02:12:49 -0600, "James Song" wrote:>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> >diff -r 41dbce3c96ea tools/ioemu-remote/xenstore.c >--- a/tools/ioemu-remote/xenstore.c Tue Oct 13 14:23:10 2009 +0800 >+++ b/tools/ioemu-remote/xenstore.c Wed Oct 14 15:10:24 2009 +0800 >@@ -908,6 +908,7 @@ > char *path = NULL, *command = NULL, *par = NULL; > unsigned int len; > extern char* snapshot_name; >+ extern void do_usb_add(const char *devname); > > if (pasprintf(&path, > "/local/domain/0/device-model/%u/command", domid) == -1) { >@@ -932,6 +933,34 @@ > } > > snapshot_name = xs_read(xsh, XBT_NULL, path, &len); >+ } 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); > } else if (!strncmp(command, "snapshot-delete", len)) { > if (pasprintf(&path, > "/local/domain/0/device-model/%u/parameter", domid) == -1) { >diff -r 41dbce3c96ea tools/python/xen/xend/XendDomain.py >--- a/tools/python/xen/xend/XendDomain.py Tue Oct 13 14:23:10 2009 + >0800 >+++ b/tools/python/xen/xend/XendDomain.py Wed Oct 14 15:10:24 2009 + >0800 >@@ -1561,6 +1561,28 @@ > raise XendError("Unable to read snapshot file file %s: %s" % > (snap_file, ex[1])) > >+ def domain_usb_add(self, domid, dev_id): >+ dominfo = self.domain_lookup_nr(domid) >+ if not dominfo: >+ raise XendInvalidDomain(str(domid)) >+ >+ 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)) >+ >+ 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_snapshot_delete(self, domid, name): > """Delete domain snapshot > >diff -r 41dbce3c96ea tools/python/xen/xend/server/SrvDomain.py >--- a/tools/python/xen/xend/server/SrvDomain.py Tue Oct 13 14:23:10 2009 + >0800 >+++ b/tools/python/xen/xend/server/SrvDomain.py Wed Oct 14 15:10:24 2009 + >0800 >@@ -120,6 +120,20 @@ > def do_snapshot_delete(self, _, req): > return self.xd.domain_snapshot_delete(self.dom.getName(), req.args >[''name''][0]) > >+ 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 op_dump(self, op, req): > self.acceptCommand(req) > return req.threadRequest(self.do_dump, op, req) >diff -r 41dbce3c96ea tools/python/xen/xm/main.py >--- a/tools/python/xen/xm/main.py Tue Oct 13 14:23:10 2009 +0800 >+++ b/tools/python/xen/xm/main.py Wed Oct 14 15:10:24 2009 +0800 >@@ -168,6 +168,9 @@ > ''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 > >@@ -325,6 +328,8 @@ > "top", > "unpause", > "uptime", >+ "usb-add", >+ "usb-del", > "vcpu-set", > ] > >@@ -361,6 +366,8 @@ > "top", > "unpause", > "uptime", >+ "usb-add", >+ "usb-del", > "vcpu-list", > "vcpu-pin", > "vcpu-set", >@@ -1500,6 +1507,14 @@ > 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) > >@@ -2990,6 +3005,9 @@ > "scsi-attach": xm_scsi_attach, > "scsi-detach": xm_scsi_detach, > "scsi-list": xm_scsi_list, >+ #usb >+ "usb-add": xm_usb_add, >+ "usb-del": xm_usb_del, > } > > ## The commands supported by a separate argument parser in xend.xm. > > > > >-------------------------------text/plain------------------------------- >_______________________________________________ >Xen-devel mailing list >Xen-devel@lists.xensource.com >http://lists.xensource.com/xen-devel > > >---html-part included links------- >mailto:jsong@novell.com_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Song
2009-Oct-19 02:48 UTC
Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
I rewrite the patch, pls check. Thanks, -James Signed-off-by: James Song Wei <jsong@novell.com> diff -r 0705efd9c69e tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Fri Oct 16 09:04:53 2009 +0100 +++ b/tools/python/xen/xend/XendDomain.py Mon Oct 19 10:15:06 2009 +0800 @@ -1522,6 +1522,45 @@ 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 0705efd9c69e tools/python/xen/xend/server/SrvDomain.py --- a/tools/python/xen/xend/server/SrvDomain.py Fri Oct 16 09:04:53 2009 +0100 +++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:15:06 2009 +0800 @@ -225,6 +225,19 @@ 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 0705efd9c69e tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Fri Oct 16 09:04:53 2009 +0100 +++ b/tools/python/xen/xm/main.py Mon Oct 19 10:15:06 2009 +0800 @@ -161,6 +161,9 @@ ''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 @@ -350,6 +353,8 @@ "top", "unpause", "uptime", + "usb-add", + "usb-del", "vcpu-set", ] @@ -382,6 +387,8 @@ "top", "unpause", "uptime", + "usb-add", + "usb-del", "vcpu-list", "vcpu-pin", "vcpu-set", @@ -1473,6 +1480,14 @@ 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) @@ -3311,6 +3326,9 @@ "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. --------------------------For qemu-xen-unstable ----------------------------------------------------- Signed-off-by: James Song Wei <jsong@novell.com> diff --git a/xenstore.c b/xenstore.c index da278f4..694152a 100644 --- a/xenstore.c +++ b/xenstore.c @@ -752,6 +752,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");>>> Keir Fraser <keir.fraser@eu.citrix.com> 2009-10-15 16:46 >>>On 15/10/2009 09:12, "James Song" <jsong@novell.com> wrote:> 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>Again, given the weird encoding of your email this patch will probably turn out to be corrupted. But also you cannot patch tools/iomu-remote/ -- ioemu patches are to be applied to the separate qemu-xen-unstable.git repository and sent to the list cc''ed to Ian Jackson who maintains that repository. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2009-Oct-19 14:36 UTC
Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
Keir Fraser writes ("Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console"):> Again, given the weird encoding of your email this patch will probably turn > out to be corrupted. But also you cannot patch tools/iomu-remote/ -- ioemu > patches are to be applied to the separate qemu-xen-unstable.git repository > and sent to the list cc''ed to Ian Jackson who maintains that repository.I can apply a patch easily enough even if it was made against tools/ioemu-remote/. But I''ll look for the revised version from James Song. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Song
2009-Oct-20 07:26 UTC
[Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
I rewrite the patch, pls check. I also put those as attachments. Thanks, -James Signed-off-by: James Song Wei <jsong@novell.com> diff -r 0705efd9c69e tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Fri Oct 16 09:04:53 2009 +0100 +++ b/tools/python/xen/xend/XendDomain.py Mon Oct 19 10:15:06 2009 +0800 @@ -1522,6 +1522,45 @@ 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 0705efd9c69e tools/python/xen/xend/server/SrvDomain.py --- a/tools/python/xen/xend/server/SrvDomain.py Fri Oct 16 09:04:53 2009 +0100 +++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:15:06 2009 +0800 @@ -225,6 +225,19 @@ 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 0705efd9c69e tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Fri Oct 16 09:04:53 2009 +0100 +++ b/tools/python/xen/xm/main.py Mon Oct 19 10:15:06 2009 +0800 @@ -161,6 +161,9 @@ ''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 @@ -350,6 +353,8 @@ "top", "unpause", "uptime", + "usb-add", + "usb-del", "vcpu-set", ] @@ -382,6 +387,8 @@ "top", "unpause", "uptime", + "usb-add", + "usb-del", "vcpu-list", "vcpu-pin", "vcpu-set", @@ -1473,6 +1480,14 @@ 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) @@ -3311,6 +3326,9 @@ "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. This is another patch for qemu-xen-unstable Signed-off-by: James Song Wei <jsong@novell.com> diff --git a/xenstore.c b/xenstore.c index da278f4..694152a 100644 --- a/xenstore.c +++ b/xenstore.c @@ -752,6 +752,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"); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Pasi Kärkkäinen
2009-Oct-27 15:23 UTC
Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
On Tue, Oct 20, 2009 at 01:26:19AM -0600, James Song wrote:> I rewrite the patch, pls check. I also put those as attachments. >I see this is committed to qemu-xen-unstable: http://xenbits.xen.org/ext/qemu-xen-unstable.hg?rev/df1b7da6e411 I guess this would be nice to have also in qemu-xen-3.4 -- Pasi> Thanks, > -James > > Signed-off-by: James Song Wei <[1]jsong@novell.com> > > diff -r 0705efd9c69e tools/python/xen/xend/XendDomain.py > --- a/tools/python/xen/xend/XendDomain.py Fri Oct 16 09:04:53 2009 > +0100 > +++ b/tools/python/xen/xend/XendDomain.py Mon Oct 19 10:15:06 2009 > +0800 > @@ -1522,6 +1522,45 @@ > 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 0705efd9c69e tools/python/xen/xend/server/SrvDomain.py > --- a/tools/python/xen/xend/server/SrvDomain.py Fri Oct 16 09:04:53 2009 > +0100 > +++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:15:06 2009 > +0800 > @@ -225,6 +225,19 @@ > 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 0705efd9c69e tools/python/xen/xm/main.py > --- a/tools/python/xen/xm/main.py Fri Oct 16 09:04:53 2009 +0100 > +++ b/tools/python/xen/xm/main.py Mon Oct 19 10:15:06 2009 +0800 > @@ -161,6 +161,9 @@ > ''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 > > @@ -350,6 +353,8 @@ > "top", > "unpause", > "uptime", > + "usb-add", > + "usb-del", > "vcpu-set", > ] > > @@ -382,6 +387,8 @@ > "top", > "unpause", > "uptime", > + "usb-add", > + "usb-del", > "vcpu-list", > "vcpu-pin", > "vcpu-set", > @@ -1473,6 +1480,14 @@ > 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) > @@ -3311,6 +3326,9 @@ > "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. > > > > > > > This is another patch for qemu-xen-unstable > > > Signed-off-by: James Song Wei <[2]jsong@novell.com> > > diff --git a/xenstore.c b/xenstore.c > index da278f4..694152a 100644 > --- a/xenstore.c > +++ b/xenstore.c > @@ -752,6 +752,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"); > > References > > Visible links > 1. mailto:jsong@novell.com > 2. mailto:jsong@novell.com> diff -r 0705efd9c69e tools/python/xen/xend/XendDomain.py > --- a/tools/python/xen/xend/XendDomain.py Fri Oct 16 09:04:53 2009 +0100 > +++ b/tools/python/xen/xend/XendDomain.py Mon Oct 19 10:15:06 2009 +0800 > @@ -1522,6 +1522,45 @@ > 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 0705efd9c69e tools/python/xen/xend/server/SrvDomain.py > --- a/tools/python/xen/xend/server/SrvDomain.py Fri Oct 16 09:04:53 2009 +0100 > +++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:15:06 2009 +0800 > @@ -225,6 +225,19 @@ > 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 0705efd9c69e tools/python/xen/xm/main.py > --- a/tools/python/xen/xm/main.py Fri Oct 16 09:04:53 2009 +0100 > +++ b/tools/python/xen/xm/main.py Mon Oct 19 10:15:06 2009 +0800 > @@ -161,6 +161,9 @@ > ''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 > > @@ -350,6 +353,8 @@ > "top", > "unpause", > "uptime", > + "usb-add", > + "usb-del", > "vcpu-set", > ] > > @@ -382,6 +387,8 @@ > "top", > "unpause", > "uptime", > + "usb-add", > + "usb-del", > "vcpu-list", > "vcpu-pin", > "vcpu-set", > @@ -1473,6 +1480,14 @@ > 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) > @@ -3311,6 +3326,9 @@ > "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.> diff --git a/xenstore.c b/xenstore.c > index da278f4..694152a 100644 > --- a/xenstore.c > +++ b/xenstore.c > @@ -752,6 +752,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");> _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Pasi Kärkkäinen
2009-Dec-13 21:09 UTC
Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
On Tue, Oct 20, 2009 at 01:26:19AM -0600, James Song wrote:> I rewrite the patch, pls check. I also put those as attachments. > > Thanks, > -James > > Signed-off-by: James Song Wei <[1]jsong@novell.com> >> diff -r 0705efd9c69e tools/python/xen/xend/server/SrvDomain.py > --- a/tools/python/xen/xend/server/SrvDomain.py Fri Oct 16 09:04:53 2009 > +0100 > +++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:15:06 2009 > +0800 > @@ -225,6 +225,19 @@ > 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) >Hello, Shouldn''t op_usb_del() use do_usb_del() and do_usb_del() use domain_usb_del() ? Or did I miss something? -- Pasi _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James (song wei)
2009-Dec-14 02:41 UTC
Re: [Xen-devel] add the two command to add or delete the usb device instead of do it in QEMU console
Yes, you are right. Sorry, I''ll send the patch. Pasi Kärkkäinen wrote:> > On Tue, Oct 20, 2009 at 01:26:19AM -0600, James Song wrote: >> I rewrite the patch, pls check. I also put those as attachments. >> >> Thanks, >> -James >> >> Signed-off-by: James Song Wei <[1]jsong@novell.com> >> > >> diff -r 0705efd9c69e tools/python/xen/xend/server/SrvDomain.py >> --- a/tools/python/xen/xend/server/SrvDomain.py Fri Oct 16 09:04:53 >> 2009 >> +0100 >> +++ b/tools/python/xen/xend/server/SrvDomain.py Mon Oct 19 10:15:06 >> 2009 >> +0800 >> @@ -225,6 +225,19 @@ >> 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) >> > > Hello, > > Shouldn''t op_usb_del() use do_usb_del() and do_usb_del() use > domain_usb_del() ? > > Or did I miss something? > > -- Pasi > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > >-- View this message in context: http://old.nabble.com/add-the-two-command-to-add-or-delete-the-usb-device-instead-of-do-it-in-QEMU-console-tp25970825p26772284.html Sent from the Xen - Dev mailing list archive at Nabble.com. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel