Re: [libvirt] Question SSH support and libirt on Windows
On Fri, Aug 08, 2008 at 02:28:44PM +0900, Atsushi SAKAI wrote: Hi, Rich I have a question about SSH support of libvirt on Windows. Is there any reason for not supporting SSH. The initial problem is that to use SSH we fork/exec not gonna work on Windows which has no concept of fork/exec. So at the very least we'd need a completely separate branch of code to deal with this on Windows. Co-incidentally I'm in the process of changing all code in libvirt which uses fork/exec to make use of the 'virRun' and 'virExec' functions in the util.c file. So if we could figure out an alternate impl of these virRun virExec functions for Windows, that'd make it easier to try SSH support Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Question SSH support and libirt on Windows
On Fri, Aug 08, 2008 at 10:09:22AM +0100, Daniel P. Berrange wrote: On Fri, Aug 08, 2008 at 02:28:44PM +0900, Atsushi SAKAI wrote: Hi, Rich I have a question about SSH support of libvirt on Windows. Is there any reason for not supporting SSH. The initial problem is that to use SSH we fork/exec not gonna work on Windows which has no concept of fork/exec. So at the very least we'd need a completely separate branch of code to deal with this on Windows. Co-incidentally I'm in the process of changing all code in libvirt which uses fork/exec to make use of the 'virRun' and 'virExec' functions in the util.c file. So if we could figure out an alternate impl of these virRun virExec functions for Windows, that'd make it easier to try SSH support That's one place where looking at existing glib function can really help, they have gone over this kind of problems, and i assume found APIs they could make consistent across platforms. http://library.gnome.org/devel/glib/unstable/glib-Spawning-Processes.html the APIs are a bit frightening though ... Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] /var/run/libvirt
It is a trivial error, but i wonder if: Failed to change group ownership of /var/run/libvirt Failed to bind socket to '/var/run/libvirt/libvirt-sock': No such file or directory This could be corrected to: /var/run/libvirt doesn't exist or an mkdir is done on the directory... Stefan -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] /var/run/libvirt
On Fri, Aug 08, 2008 at 11:49:46AM +0200, Stefan de Konink wrote: It is a trivial error, but i wonder if: Failed to change group ownership of /var/run/libvirt Failed to bind socket to '/var/run/libvirt/libvirt-sock': No such file or directory This could be corrected to: /var/run/libvirt doesn't exist or an mkdir is done on the directory... I see install -d -m 0755 $RPM_BUILD_ROOT%{_localstatedir}/run/libvirt/ in libvirt spec file and mkdir -p $(DESTDIR)$(localstatedir)/run/libvirt in qemud/Makefile.am as part of install-data-local rule. So it seems it really should be created appropriately as part of 'make install' a better reporting of the error would be fine, but something else went wrong first. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] /var/run/libvirt
On Fri, 8 Aug 2008, Daniel Veillard wrote: On Fri, Aug 08, 2008 at 11:49:46AM +0200, Stefan de Konink wrote: It is a trivial error, but i wonder if: Failed to change group ownership of /var/run/libvirt Failed to bind socket to '/var/run/libvirt/libvirt-sock': No such file or directory This could be corrected to: /var/run/libvirt doesn't exist or an mkdir is done on the directory... I see install -d -m 0755 $RPM_BUILD_ROOT%{_localstatedir}/run/libvirt/ in libvirt spec file and mkdir -p $(DESTDIR)$(localstatedir)/run/libvirt in qemud/Makefile.am as part of install-data-local rule. So it seems it really should be created appropriately as part of 'make install' My /var/run is empty upon boot. (ramfs) One may wonder why libvirt needs a dedicated directory at all for two sockets... a better reporting of the error would be fine, but something else went wrong first. See the trivial part. Stefan -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH]: ruby-libvirt migration fixes
Attached is a relatively simple patch to the ruby-libvirt bindings with some bugfixes for the migrate call. The first problem was that there was no way to pass a nil through to the underlying virDomainMigrate() call. This is important because generally the dname and uri parameters end up being NULL. This patch also makes all the parameters beyond the first 2 optional. I've tested this out by live migrating a KVM guest between two hosts, and this now does what I expect. Signed-off-by: Chris Lalancette [EMAIL PROTECTED] diff -r c6a3e36cdf54 ext/libvirt/_libvirt.c --- a/ext/libvirt/_libvirt.c Thu Jul 17 15:24:26 2008 -0700 +++ b/ext/libvirt/_libvirt.c Fri Aug 08 06:04:56 2008 -0400 @@ -637,16 +637,51 @@ VALUE libvirt_conn_num_of_defined_storag } #endif +static char *get_string_or_nil(VALUE arg) +{ +if (TYPE(arg) == T_NIL) +return NULL; +else if (TYPE(arg) == T_STRING) +return STR2CSTR(arg); +else +rb_raise(rb_eTypeError, wrong argument type (expected String or nil));return NULL; +} + /* * Class Libvirt::Domain */ -VALUE libvirt_dom_migrate(VALUE s, VALUE dconn, VALUE flags, - VALUE dname, VALUE uri, VALUE bandwidth) { +VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) { virDomainPtr ddom = NULL; +VALUE dconn; +unsigned long flags; +char *dname; +char *uri; +unsigned long bandwidth; -ddom = virDomainMigrate(domain_get(s), conn(dconn), NUM2UINT(flags), -StringValueCStr(dname), StringValueCStr(uri), -NUM2UINT(bandwidth)); +if (argc 2 || argc 5) { +rb_raise(rb_eArgError, Must provide between 2 and 5 arguments); +} + +dconn = argv[0]; +flags = NUM2UINT(argv[1]); +dname = NULL; +uri = NULL; +bandwidth = 0; + +switch(argc) { +case 5: +Check_Type(argv[4], T_FIXNUM); +bandwidth = NUM2UINT(argv[4]); +/* fallthrough */ +case 4: +uri = get_string_or_nil(argv[3]); +/* fallthrough */ +case 3: +dname = get_string_or_nil(argv[2]); +} + +ddom = virDomainMigrate(domain_get(s), conn(dconn), flags, +dname, uri, bandwidth); _E(ddom == NULL, create_error(e_Error, virDomainMigrate, , conn(dconn))); @@ -1853,7 +1888,7 @@ void Init__libvirt() { /* virDomainMigrateFlags */ rb_define_const(c_domain, MIGRATE_LIVE, INT2NUM(VIR_MIGRATE_LIVE)); -rb_define_method(c_domain, migrate, libvirt_dom_migrate, 5); +rb_define_method(c_domain, migrate, libvirt_dom_migrate, -1); rb_define_attr(c_domain, connection, 1, 0); rb_define_method(c_domain, shutdown, libvirt_dom_shutdown, 0); rb_define_method(c_domain, reboot, libvirt_dom_reboot, -1); -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] /var/run/libvirt
On Fri, Aug 08, 2008 at 12:08:05PM +0200, Stefan de Konink wrote: On Fri, 8 Aug 2008, Daniel Veillard wrote: install -d -m 0755 $RPM_BUILD_ROOT%{_localstatedir}/run/libvirt/ in libvirt spec file and mkdir -p $(DESTDIR)$(localstatedir)/run/libvirt in qemud/Makefile.am as part of install-data-local rule. So it seems it really should be created appropriately as part of 'make install' My /var/run is empty upon boot. (ramfs) One may wonder why libvirt needs a dedicated directory at all for two sockets... That just happens to be your particular deployment scenario. Other hypervisor drivers put stuff in there too, hence we have a directory. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] /var/run/libvirt
On Fri, 8 Aug 2008, Daniel P. Berrange wrote: On Fri, Aug 08, 2008 at 12:08:05PM +0200, Stefan de Konink wrote: On Fri, 8 Aug 2008, Daniel Veillard wrote: install -d -m 0755 $RPM_BUILD_ROOT%{_localstatedir}/run/libvirt/ in libvirt spec file and mkdir -p $(DESTDIR)$(localstatedir)/run/libvirt in qemud/Makefile.am as part of install-data-local rule. So it seems it really should be created appropriately as part of 'make install' My /var/run is empty upon boot. (ramfs) One may wonder why libvirt needs a dedicated directory at all for two sockets... That just happens to be your particular deployment scenario. Other hypervisor drivers put stuff in there too, hence we have a directory. Anyway, it is a trivial fix... if I need to write a patch myself, so be it. Stefan -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Re: [PATCH]: hostdev passthrough support take #3
On Thu, Aug 07, 2008 at 06:25:56PM +0200, Guido G?nther wrote: Hi, attached is version three of the hostdev passthrough patch. It adds: * code to format the XML for output * RelaxNG schema update * testcases ACK, this looks ready to commit now - great work getting this done. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Re: [PATCH]: file backed usb massstorage #3
On Thu, Aug 07, 2008 at 07:16:30PM +0200, Guido G?nther wrote: Hi, attached is version three of the file backed usb massstorage patch. * handle type != DISK case * on OOM use VIR_ERR_NO_MEMORY instead of VIR_ERR_OPERAION_FAILED * RelaxNG schema update * testcase The patches are ment to be applied on top of the hostdev patches. ACK, also looks good to commit Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] PATCH: Fix const-ness for virRun/virExec
The exec() family of UNIX functions have broken const-ness in the argv[] parameter. For inexplicable reasons, I followed this brokeness when originally doing the virRun/virExec functions. So every caller is either using wrong const-ness, or having to cast when calling them. This patch fixes the virRun/virExec API const-ness, so we only need apply a cast at the time we finally call exec() src/iptables.c| 12 ++-- src/lxc_driver.c |2 +- src/openvz_driver.c | 34 +- src/qemu_conf.c |4 ++-- src/qemu_conf.h |2 +- src/qemu_driver.c |6 +++--- src/storage_backend.c |4 ++-- src/storage_backend_disk.c|4 ++-- src/storage_backend_fs.c |8 src/storage_backend_iscsi.c |6 +++--- src/storage_backend_logical.c | 12 ++-- src/util.c| 16 src/util.h|6 +++--- src/veth.c|8 tests/qemuxml2argvtest.c |2 +- 15 files changed, 63 insertions(+), 63 deletions(-) Daniel diff -r cc63ab958867 src/iptables.c --- a/src/iptables.cThu Aug 07 15:00:21 2008 +0100 +++ b/src/iptables.cThu Aug 07 22:59:08 2008 +0100 @@ -57,7 +57,7 @@ typedef struct { char *rule; -char **argv; +const char **argv; intcommand_idx; } iptRule; @@ -91,7 +91,7 @@ const char *path) { char arg[PATH_MAX]; -char *argv[4]; +const char *argv[4]; snprintf(arg, sizeof(arg), --custom-rules=ipv4:%s:%s, table, path); @@ -278,7 +278,7 @@ static int iptRulesAppend(iptRules *rules, char *rule, - char **argv, + const char **argv, int command_idx) { if (VIR_REALLOC_N(rules-rules, rules-nrules+1) 0) { @@ -385,7 +385,7 @@ } static char * -argvToString(char **argv) +argvToString(const char *const *argv) { int len, i; char *ret, *p; @@ -415,7 +415,7 @@ { va_list args; int retval = ENOMEM; -char **argv; +const char **argv; char *rule = NULL; const char *s; int n, command_idx; @@ -571,7 +571,7 @@ for (i = 0; i rules-nrules; i++) { iptRule *rule = rules-rules[i]; -char *orig; +const char *orig; orig = rule-argv[rule-command_idx]; rule-argv[rule-command_idx] = (char *) --delete; diff -r cc63ab958867 src/lxc_driver.c --- a/src/lxc_driver.c Thu Aug 07 15:00:21 2008 +0100 +++ b/src/lxc_driver.c Thu Aug 07 22:59:08 2008 +0100 @@ -1288,7 +1288,7 @@ int user_netns = 0; int kern_netns = 0; -if (virRun(NULL, (char **)argv, ip_rc) == 0) +if (virRun(NULL, argv, ip_rc) == 0) user_netns = WIFEXITED(ip_rc) (WEXITSTATUS(ip_rc) != 255); if (lxcCheckContainerSupport(CLONE_NEWNET) == 0) diff -r cc63ab958867 src/openvz_driver.c --- a/src/openvz_driver.c Thu Aug 07 15:00:21 2008 +0100 +++ b/src/openvz_driver.c Thu Aug 07 22:59:08 2008 +0100 @@ -91,13 +91,13 @@ unsigned int flags ATTRIBUTE_UNUSED); static int openvzDomainUndefine(virDomainPtr dom); -static void cmdExecFree(char *cmdExec[]); +static void cmdExecFree(const char *cmdExec[]); static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid); struct openvz_driver ovz_driver; -static void cmdExecFree(char *cmdExec[]) +static void cmdExecFree(const char *cmdExec[]) { int i=-1; while(cmdExec[++i]) @@ -111,7 +111,7 @@ 0 - OK */ static int openvzDomainDefineCmd(virConnectPtr conn, - char *args[], + const char *args[], int maxarg, struct openvz_vm_def *vmdef) { @@ -287,7 +287,7 @@ return -1; } -if (virRun(dom-conn, (char **)prog, NULL) 0) { +if (virRun(dom-conn, prog, NULL) 0) { openvzError(dom-conn, VIR_ERR_INTERNAL_ERROR, _(Could not exec %s), VZCTL); return -1; @@ -319,7 +319,7 @@ return -1; } -if (virRun(dom-conn, (char **)prog, NULL) 0) { +if (virRun(dom-conn, prog, NULL) 0) { openvzError(dom-conn, VIR_ERR_INTERNAL_ERROR, _(Could not exec %s), VZCTL); return -1; @@ -333,7 +333,7 @@ virDomainNetDefPtr net) { int rc = 0, narg; -char *prog[OPENVZ_MAX_ARG]; +const char *prog[OPENVZ_MAX_ARG]; char *mac = NULL; #define ADD_ARG_LIT(thisarg)\ @@ -391,7 +391,7 @@ if (prog[0] != NULL){ ADD_ARG_LIT(--save); -if (virRun(conn, (char **)prog, NULL) 0) { +if (virRun(conn, prog, NULL) 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _(Could not exec %s), VZCTL); rc = -1; @@ -427,7 +427,7 @@ struct
Re: [libvirt] /var/run/libvirt
On Fri, Aug 08, 2008 at 06:05:12AM -0400, Daniel Veillard wrote: install -d -m 0755 $RPM_BUILD_ROOT%{_localstatedir}/run/libvirt/ in libvirt spec file and mkdir -p $(DESTDIR)$(localstatedir)/run/libvirt /var/run is tmpfs on at least Solaris. regards john -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] PATCH: Fix const-ness for virRun/virExec
Daniel P. Berrange [EMAIL PROTECTED] wrote: The exec() family of UNIX functions have broken const-ness in the argv[] parameter. For inexplicable reasons, I followed this brokeness when originally doing the virRun/virExec functions. So every caller is either using wrong const-ness, or having to cast when calling them. This patch fixes the virRun/virExec API const-ness, so we only need apply a cast at the time we finally call exec() +1 to massive cast removal + const-correctness fixes ;-) Nice. ACK -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: file backed usb massstorage #3
Guido Günther [EMAIL PROTECTED] wrote: attached is version three of the file backed usb massstorage patch. * handle type != DISK case * on OOM use VIR_ERR_NO_MEMORY instead of VIR_ERR_OPERAION_FAILED * RelaxNG schema update * testcase ... ACK, once you fix the following: From 123763836d1fe71e6180c36a75690ceec0174f8c Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Sun, 3 Aug 2008 01:07:00 +0200 Subject: [PATCH] usbmass: use files as USB disks ... diff --git a/src/qemu_conf.c b/src/qemu_conf.c ... +#define ADD_USBDISK(thisarg)\ +do {\ +ADD_ARG_LIT(-usbdevice); \ +ADD_ARG_SPACE; \ +if ((asprintf(qargv[qargc++], disk:%s, thisarg)) == -1) \ +goto no_memory; \ Set qargv[qargc-1] = NULL before the goto, since upon asprintf failure it's undefined -- and the subsequent attempt to free it may well evoke a segfault. +} while (0) ... diff --git a/src/qemu_driver.c b/src/qemu_driver.c index ef4e158..118d423 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -2978,6 +2978,43 @@ static int qemudDomainAttachCdromDevice(virDomainPtr dom, return 0; } +static int qemudDomainAttachUsbMassstorageDevice(virDomainPtr dom, virDomainDeviceDefPtr dev) +{ +struct qemud_driver *driver = (struct qemud_driver *)dom-conn-privateData; +virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid); This should handle the case in which vm == NULL. Otherwise, qemudMonitorCommand will dereference NULL. ... From a714b14a13f97b824c288fc40165ef9fe5fbaae0 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Thu, 7 Aug 2008 14:39:35 +0200 Subject: [PATCH] usbmass: testcase for file as src for usb disk ... diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args new file mode 100644 index 000..60a8317 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args @@ -0,0 +1 @@ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img -net none -serial none -parallel none -usb \ No newline at end of file Please add a newline and split the long line: /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \ -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \ -net none -serial none -parallel none -usb -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: hostdev passthrough support take #3
Guido Günther [EMAIL PROTECTED] wrote: attached is version three of the hostdev passthrough patch. It adds: * code to format the XML for output * RelaxNG schema update * testcases ACK, modulo the details below. From cfcfc85accdcc7be7a5fbfd2c8dde435646d5ab2 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Fri, 25 Jul 2008 15:18:16 -0400 Subject: [PATCH] hostdev: pass host devices to the guest ... diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 7fe3903..ef4e158 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -2951,12 +2951,83 @@ static int qemudDomainChangeCDROM(virDomainPtr dom, return 0; } +static int qemudDomainAttachCdromDevice(virDomainPtr dom, +virDomainDeviceDefPtr dev) +{ +struct qemud_driver *driver = (struct qemud_driver *)dom-conn-privateData; +virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid); +virDomainDiskDefPtr disk; + +disk = vm-def-disks; Check for vm == NULL before dereferencing it. ... +static int qemudDomainAttachHostDevice(virDomainPtr dom, virDomainDeviceDefPtr dev) +{ +struct qemud_driver *driver = (struct qemud_driver *)dom-conn-privateData; +virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid); ... +if (qemudMonitorCommand(driver, vm, cmd, reply) 0) { Likewise. ... From 6fd13e2faa49eadf2db4a7e4a3a28192b4c61622 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Thu, 7 Aug 2008 14:25:50 +0200 Subject: [PATCH] hostdev: add testcases ... diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args new file mode 100644 index 000..0b8 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args @@ -0,0 +1 @@ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:014.006 \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args new file mode 100644 index 000..b993ae5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args @@ -0,0 +1 @@ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:0204:6025 \ No newline at end of file Please split the long lines and add a newline at EOF. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: file back ed usb massstorage #3
On Fri, Aug 08, 2008 at 02:07:49PM +0200, Jim Meyering wrote: Guido Günther [EMAIL PROTECTED] wrote: From a714b14a13f97b824c288fc40165ef9fe5fbaae0 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Thu, 7 Aug 2008 14:39:35 +0200 Subject: [PATCH] usbmass: testcase for file as src for usb disk ... diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args new file mode 100644 index 000..60a8317 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args @@ -0,0 +1 @@ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img -net none -serial none -parallel none -usb \ No newline at end of file Please add a newline and split the long line: /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \ -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \ -net none -serial none -parallel none -usb No, this would break the test case, since its being compared against generated data in the format shown by the patch. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [et-mgmt-tools] Re: [libvirt] RE: [Qemu-devel] [ANNOUNCE] virt-mem tools version 0.2.8 released
On Thu, Aug 7, 2008 at 8:06 AM, Richard W.M. Jones [EMAIL PROTECTED] wrote: I think the message here is, install libvirt be happy :-) nice as this tool sounds, i would need far more than this to make me switch from a simple, easily scriptable command-line to a generic, 'lowest common', solution like libvirt. of course, i hope it keeps getting better. who knows? maybe in a year or so it would be comparable to the CLI. -- Javier -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: file backed usb massstorage #3
Daniel P. Berrange [EMAIL PROTECTED] wrote: On Fri, Aug 08, 2008 at 02:07:49PM +0200, Jim Meyering wrote: Guido Günther [EMAIL PROTECTED] wrote: From a714b14a13f97b824c288fc40165ef9fe5fbaae0 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] ... Please add a newline and split the long line: /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \ -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \ -net none -serial none -parallel none -usb No, this would break the test case, since its being compared against generated data in the format shown by the patch. Ahh... it looked like something to be executed (and maintained), rather than merely expected output. So no need to split long lines. However, including a trailing newline might be worthwhile (and adjust the code to emit the matching newline), since some editors have a hard time modifying or creating a file with no newline at EOF. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Release of libvirt-java-0.2.1
Following the refactoring patch by Tóth István, it was a good idea to make a release awoiding all the know leaks and providing the storage API. Sor libvirt-java-0.2.1 is available at the usual place: ftp://libvirt.org/libvirt/java/ thanks Tóth ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: file backed usb massstorage #3
Jim Meyering wrote: On Fri, Aug 08, 2008 at 02:07:49PM +0200, Jim Meyering wrote: Guido Günther [EMAIL PROTECTED] wrote: From a714b14a13f97b824c288fc40165ef9fe5fbaae0 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] ... Please add a newline and split the long line: /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \ -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \ -net none -serial none -parallel none -usb No, this would break the test case, since its being compared against generated data in the format shown by the patch. Ahh... it looked like something to be executed (and maintained), rather than merely expected output. So no need to split long lines. However, including a trailing newline might be worthwhile (and adjust the code to emit the matching newline), since some editors have a hard time modifying or creating a file with no newline at EOF. Heh. Unfortunately, that's not an option either. The tests just do a simple strcmp(), so if there is an extra trailing newline in the args file, the test will fail. I ran into this before. Chris Lalancette -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: ruby-libvirt migration fixes
Chris Lalancette [EMAIL PROTECTED] wrote: Attached is a relatively simple patch to the ruby-libvirt bindings with some bugfixes for the migrate call. The first problem was that there was no way to pass a nil through to the underlying virDomainMigrate() call. This is important because generally the dname and uri parameters end up being NULL. This patch also makes all the parameters beyond the first 2 optional. I've tested this out by live migrating a KVM guest between two hosts, and this now does what I expect. Hi Chris, I'm no ruby integration guru, but took a look anyhow. Looks fine modulo a couple nits. diff -r c6a3e36cdf54 ext/libvirt/_libvirt.c --- a/ext/libvirt/_libvirt.c Thu Jul 17 15:24:26 2008 -0700 +++ b/ext/libvirt/_libvirt.c Fri Aug 08 06:04:56 2008 -0400 @@ -637,16 +637,51 @@ VALUE libvirt_conn_num_of_defined_storag } #endif +static char *get_string_or_nil(VALUE arg) +{ +if (TYPE(arg) == T_NIL) +return NULL; +else if (TYPE(arg) == T_STRING) +return STR2CSTR(arg); STR2CSTR is marked as obsolete in ruby.h, where it says to use StringValuePtr instead: /* obsolete API - use StringValuePtr() */ #define STR2CSTR(x) rb_str2cstr((VALUE)(x),0) +else +rb_raise(rb_eTypeError, wrong argument type (expected String or nil));return NULL; +} + /* * Class Libvirt::Domain */ -VALUE libvirt_dom_migrate(VALUE s, VALUE dconn, VALUE flags, - VALUE dname, VALUE uri, VALUE bandwidth) { +VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) { virDomainPtr ddom = NULL; +VALUE dconn; +unsigned long flags; +char *dname; +char *uri; Both pointers can be const. Marking them as const also helps to emphasize that they must not be freed. +unsigned long bandwidth; -ddom = virDomainMigrate(domain_get(s), conn(dconn), NUM2UINT(flags), -StringValueCStr(dname), StringValueCStr(uri), -NUM2UINT(bandwidth)); +if (argc 2 || argc 5) { +rb_raise(rb_eArgError, Must provide between 2 and 5 arguments); +} + +dconn = argv[0]; +flags = NUM2UINT(argv[1]); +dname = NULL; +uri = NULL; +bandwidth = 0; + +switch(argc) { +case 5: +Check_Type(argv[4], T_FIXNUM); +bandwidth = NUM2UINT(argv[4]); +/* fallthrough */ +case 4: +uri = get_string_or_nil(argv[3]); +/* fallthrough */ +case 3: +dname = get_string_or_nil(argv[2]); +} + +ddom = virDomainMigrate(domain_get(s), conn(dconn), flags, +dname, uri, bandwidth); ... -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: file backed usb massstorage #3
Chris Lalancette [EMAIL PROTECTED] wrote: Jim Meyering wrote: On Fri, Aug 08, 2008 at 02:07:49PM +0200, Jim Meyering wrote: Guido Günther [EMAIL PROTECTED] wrote: From a714b14a13f97b824c288fc40165ef9fe5fbaae0 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] ... Please add a newline and split the long line: /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \ -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \ -net none -serial none -parallel none -usb No, this would break the test case, since its being compared against generated data in the format shown by the patch. Ahh... it looked like something to be executed (and maintained), rather than merely expected output. So no need to split long lines. However, including a trailing newline might be worthwhile (and adjust the code to emit the matching newline), since some editors have a hard time modifying or creating a file with no newline at EOF. Heh. Unfortunately, that's not an option either. The tests just do a simple strcmp(), so if there is an extra trailing newline in the args file, the test will fail. I ran into this before. Maybe you're talking about something else? I proposed to add a trailing newline in the expected output as well as in the code to generate the actual output. This is the sort of change I was thinking of: diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d136a13..25465ae 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -53,7 +53,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, int extra goto fail; tmp = argv; -len = 0; +len = 1; /* for trailing newline */ while (*tmp) { len += strlen(*tmp) + 1; tmp++; @@ -68,6 +68,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, int extra strcat(actualargv, *tmp); tmp++; } +strcat(actualargv, \n); if (STRNEQ(expectargv, actualargv)) { virtTestDifference(stderr, expectargv, actualargv); -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH]: file backed usb massstorage #4
On Fri, Aug 08, 2008 at 02:07:49PM +0200, Jim Meyering wrote: Guido Günther [EMAIL PROTECTED] wrote: [..snip..] +static int qemudDomainAttachUsbMassstorageDevice(virDomainPtr dom, virDomainDeviceDefPtr dev) +{ +struct qemud_driver *driver = (struct qemud_driver *)dom-conn-privateData; +virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid); This should handle the case in which vm == NULL. Otherwise, qemudMonitorCommand will dereference NULL. ... The function gets called from qemudDomainAttachDevice which does the same call to virDomainFindbyUUid and checks for vm == NULL already but you're right: better safe than sorry. [..snip..] Please add a newline and split the long line: /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \ -boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \ -net none -serial none -parallel none -usb I'd rather not since this breaks the testcase, it compares the exact output. New patches attached. Patches apply on top of the hostdev patches. -- Guido From 72df28ae2eb476d56c51963c660650a344265c76 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Sun, 3 Aug 2008 01:07:00 +0200 Subject: [PATCH] usbmass: use files as usbdisks works in QEMU/KVM --- src/domain_conf.c |3 ++- src/domain_conf.h |1 + src/qemu_conf.c | 37 - src/qemu_driver.c | 46 ++ 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/src/domain_conf.c b/src/domain_conf.c index 922cf76..237579f 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -84,7 +84,8 @@ VIR_ENUM_IMPL(virDomainDiskBus, VIR_DOMAIN_DISK_BUS_LAST, fdc, scsi, virtio, - xen) + xen, + usb) VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST, mount, diff --git a/src/domain_conf.h b/src/domain_conf.h index 8a9d1db..9e7c524 100644 --- a/src/domain_conf.h +++ b/src/domain_conf.h @@ -72,6 +72,7 @@ enum virDomainDiskBus { VIR_DOMAIN_DISK_BUS_SCSI, VIR_DOMAIN_DISK_BUS_VIRTIO, VIR_DOMAIN_DISK_BUS_XEN, +VIR_DOMAIN_DISK_BUS_USB, VIR_DOMAIN_DISK_BUS_LAST }; diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 46bb9f4..3b65b65 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -55,7 +55,8 @@ VIR_ENUM_IMPL(virDomainDiskQEMUBus, VIR_DOMAIN_DISK_BUS_LAST, floppy, scsi, virtio, - xen) + xen, + usb) #define qemudLog(level, msg...) fprintf(stderr, msg) @@ -772,6 +773,16 @@ int qemudBuildCommandLine(virConnectPtr conn, goto no_memory; \ } while (0) +#define ADD_USBDISK(thisarg)\ +do {\ +ADD_ARG_LIT(-usbdevice); \ +ADD_ARG_SPACE; \ +if ((asprintf(qargv[qargc++], disk:%s, thisarg)) == -1) {\ +qargv[qargc-1] = NULL; \ +goto no_memory; \ +} \ +} while (0) + snprintf(memory, sizeof(memory), %lu, vm-def-memory/1024); snprintf(vcpus, sizeof(vcpus), %lu, vm-def-vcpus); @@ -883,6 +894,18 @@ int qemudBuildCommandLine(virConnectPtr conn, int idx = virDiskNameToIndex(disk-dst); const char *bus = virDomainDiskQEMUBusTypeToString(disk-bus); +if (disk-bus == VIR_DOMAIN_DISK_BUS_USB) { +if (disk-device == VIR_DOMAIN_DISK_DEVICE_DISK) { +ADD_USBDISK(disk-src); +} else { +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unsupported usb disk type for '%s'), disk-src); +goto error; +} +disk = disk-next; +continue; +} + if (idx 0) { qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _(unsupported disk type '%s'), disk-dst); @@ -922,6 +945,18 @@ int qemudBuildCommandLine(virConnectPtr conn, char dev[NAME_MAX]; char file[PATH_MAX]; +if (disk-bus == VIR_DOMAIN_DISK_BUS_USB) { +if (disk-device == VIR_DOMAIN_DISK_DEVICE_DISK) { +ADD_USBDISK(disk-src); +} else { +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unsupported usb disk type for '%s'), disk-src); +goto error; +} +
[libvirt] [PATCH]: hostdev passthrough support take #4
On Fri, Aug 08, 2008 at 02:30:15PM +0200, Jim Meyering wrote: Guido Günther [EMAIL PROTECTED] wrote: [..snip..] +static int qemudDomainAttachCdromDevice(virDomainPtr dom, +virDomainDeviceDefPtr dev) +{ +struct qemud_driver *driver = (struct qemud_driver *)dom-conn-privateData; +virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid); +virDomainDiskDefPtr disk; + +disk = vm-def-disks; Check for vm == NULL before dereferencing it. ... +static int qemudDomainAttachHostDevice(virDomainPtr dom, virDomainDeviceDefPtr dev) +{ +struct qemud_driver *driver = (struct qemud_driver *)dom-conn-privateData; +virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid); ... +if (qemudMonitorCommand(driver, vm, cmd, reply) 0) { Likewise. The same applies here: qemudDomainAttachDevice checked that already, but again - better safe than sorry. Updated patches attached. -- Guido From 137b82948a680a68c619ac2ccdb1afedecc046b4 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Fri, 25 Jul 2008 15:18:16 -0400 Subject: [PATCH] hostdev: pass host devices to the guest current implementation allows to pass on usb devices to qemu/kvm --- src/domain_conf.c | 268 - src/domain_conf.h | 51 ++ src/qemu_conf.c | 29 ++ src/qemu_driver.c | 118 ++- 4 files changed, 440 insertions(+), 26 deletions(-) diff --git a/src/domain_conf.c b/src/domain_conf.c index 4998a7d..922cf76 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -131,6 +131,13 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST, sdl, vnc) +VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST, + subsystem, + capabilities) + +VIR_ENUM_IMPL(virDomainHostdevSubsys, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST, + usb, + pci) static void virDomainReportError(virConnectPtr conn, int code, const char *fmt, ...) @@ -332,6 +339,16 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def) VIR_FREE(def); } +void virDomainHostdevDefFree(virDomainHostdevDefPtr def) +{ +if (!def) +return; + +VIR_FREE(def-target); +virDomainHostdevDefFree(def-next); +VIR_FREE(def); +} + void virDomainDeviceDefFree(virDomainDeviceDefPtr def) { if (!def) @@ -350,6 +367,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) case VIR_DOMAIN_DEVICE_SOUND: virDomainSoundDefFree(def-data.sound); break; +case VIR_DOMAIN_DEVICE_HOSTDEV: +virDomainHostdevDefFree(def-data.hostdev); +break; } VIR_FREE(def); @@ -369,7 +389,7 @@ void virDomainDefFree(virDomainDefPtr def) virDomainChrDefFree(def-parallels); virDomainChrDefFree(def-console); virDomainSoundDefFree(def-sounds); - +virDomainHostdevDefFree(def-hostdevs); VIR_FREE(def-os.type); VIR_FREE(def-os.arch); @@ -1400,6 +1420,180 @@ error: goto cleanup; } +static int +virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, + const xmlNodePtr node, + virDomainHostdevDefPtr def) { + +int ret = -1; +xmlNodePtr cur; + +cur = node-children; +while (cur != NULL) { +if (cur-type == XML_ELEMENT_NODE) { +if (xmlStrEqual(cur-name, BAD_CAST vendor)) { +char *vendor = virXMLPropString(cur, id); + +if (vendor) { +if (virStrToLong_ui(vendor, NULL, 0, +def-source.subsys.usb.vendor) 0) { +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _(cannot parse vendor id %s), vendor); +VIR_FREE(vendor); +goto out; +} +VIR_FREE(vendor); +} else { +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + %s, _(usb vendor needs id)); +goto out; +} +} else if (xmlStrEqual(cur-name, BAD_CAST product)) { +char* product = virXMLPropString(cur, id); + +if (product) { +if (virStrToLong_ui(product, NULL, 0, +def-source.subsys.usb.product) 0) { +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, +_(cannot parse product %s), product); +VIR_FREE(product); +goto out; +} +VIR_FREE(product); +} else { +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, +
[libvirt] Re: [PATCH]: hostdev passthrough support take #4
Guido Günther [EMAIL PROTECTED] wrote: The same applies here: qemudDomainAttachDevice checked that already, but again - better safe than sorry. Updated patches attached. ACK. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Re: [PATCH]: file backed usb massstorage #4
Guido Günther [EMAIL PROTECTED] wrote: New patches attached. Patches apply on top of the hostdev patches. ACK. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: ruby-libvirt migration fixes
Jim Meyering wrote: diff -r c6a3e36cdf54 ext/libvirt/_libvirt.c --- a/ext/libvirt/_libvirt.c Thu Jul 17 15:24:26 2008 -0700 +++ b/ext/libvirt/_libvirt.c Fri Aug 08 06:04:56 2008 -0400 @@ -637,16 +637,51 @@ VALUE libvirt_conn_num_of_defined_storag } #endif +static char *get_string_or_nil(VALUE arg) +{ +if (TYPE(arg) == T_NIL) +return NULL; +else if (TYPE(arg) == T_STRING) +return STR2CSTR(arg); STR2CSTR is marked as obsolete in ruby.h, where it says to use StringValuePtr instead: /* obsolete API - use StringValuePtr() */ #define STR2CSTR(x) rb_str2cstr((VALUE)(x),0) Yeah, you are right. I looked through the ruby source code, actually, and I ended up using StringValueCStr (which is used elsewhere in the ruby-libvirt bindings). It's basically the same as StringValuePtr, but does an additional check to make sure the string is not of 0 length and that there aren't additional embedded \0 in the string. I also updated the patch with the const pointers as you suggested. Attached. Thanks for the review! Chris Lalancette diff -r c6a3e36cdf54 ext/libvirt/_libvirt.c --- a/ext/libvirt/_libvirt.c Thu Jul 17 15:24:26 2008 -0700 +++ b/ext/libvirt/_libvirt.c Fri Aug 08 16:20:25 2008 +0200 @@ -637,16 +637,51 @@ VALUE libvirt_conn_num_of_defined_storag } #endif +static char *get_string_or_nil(VALUE arg) +{ +if (TYPE(arg) == T_NIL) +return NULL; +else if (TYPE(arg) == T_STRING) +return StringValueCStr(arg); +else +rb_raise(rb_eTypeError, wrong argument type (expected String or nil));return NULL; +} + /* * Class Libvirt::Domain */ -VALUE libvirt_dom_migrate(VALUE s, VALUE dconn, VALUE flags, - VALUE dname, VALUE uri, VALUE bandwidth) { +VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) { virDomainPtr ddom = NULL; +VALUE dconn; +unsigned long flags; +const char *dname; +const char *uri; +unsigned long bandwidth; -ddom = virDomainMigrate(domain_get(s), conn(dconn), NUM2UINT(flags), -StringValueCStr(dname), StringValueCStr(uri), -NUM2UINT(bandwidth)); +if (argc 2 || argc 5) { +rb_raise(rb_eArgError, Must provide between 2 and 5 arguments); +} + +dconn = argv[0]; +flags = NUM2UINT(argv[1]); +dname = NULL; +uri = NULL; +bandwidth = 0; + +switch(argc) { +case 5: +Check_Type(argv[4], T_FIXNUM); +bandwidth = NUM2UINT(argv[4]); +/* fallthrough */ +case 4: +uri = get_string_or_nil(argv[3]); +/* fallthrough */ +case 3: +dname = get_string_or_nil(argv[2]); +} + +ddom = virDomainMigrate(domain_get(s), conn(dconn), flags, +dname, uri, bandwidth); _E(ddom == NULL, create_error(e_Error, virDomainMigrate, , conn(dconn))); @@ -1853,7 +1888,7 @@ void Init__libvirt() { /* virDomainMigrateFlags */ rb_define_const(c_domain, MIGRATE_LIVE, INT2NUM(VIR_MIGRATE_LIVE)); -rb_define_method(c_domain, migrate, libvirt_dom_migrate, 5); +rb_define_method(c_domain, migrate, libvirt_dom_migrate, -1); rb_define_attr(c_domain, connection, 1, 0); rb_define_method(c_domain, shutdown, libvirt_dom_shutdown, 0); rb_define_method(c_domain, reboot, libvirt_dom_reboot, -1); -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: hostdev passthrough support take #4
On Fri, Aug 08, 2008 at 04:05:10PM +0200, Guido Günther wrote: Likewise. The same applies here: qemudDomainAttachDevice checked that already, but again - better safe than sorry. Updated patches attached. Okidoc, all look good ! Applied and commited to CVS, thanks a lot for the work, I think the only thing missing is extending the descrition in the documentation would you mind adding a description in formatdomain.html(.in) Probably an USB devices section added below the elementsDisks part, explaining the syntaxes and stating that it was added in versions after 0.4.4 If you don't feel comfortable with that I can do it, but you know better :) Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] append a newline to expected-output files lacking NL-at-EOF
Jim Meyering [EMAIL PROTECTED] wrote: Maybe you're talking about something else? I proposed to add a trailing newline in the expected output as well as in the code to generate the actual output. This is the sort of change I was thinking of: diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c At first I thought that might be incomplete. But it's all that's needed on the C side. I ran this one-liner to append the missing newlines, and we're all set: for i in $(find|grep '\.args$'); do echo $i;done make check and make syntax-check both pass. From b548c2f7caf311b7acfa2ebd839067f674d89a40 Mon Sep 17 00:00:00 2001 From: Jim Meyering [EMAIL PROTECTED] Date: Fri, 8 Aug 2008 16:18:57 +0200 Subject: [PATCH] tests: append a newline to expected-output files lacking NL-at-EOF * tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Adjust the code that creates actual output, so that it too produces a newline-terminated buffer. * tests/qemuxml2argvdata/*.args: Append a newline to each, via: for i in $(find|grep '\.args$'); do echo $i;done --- .../qemuxml2argvdata/qemuxml2argv-boot-cdrom.args |2 +- .../qemuxml2argvdata/qemuxml2argv-boot-floppy.args |2 +- .../qemuxml2argv-boot-network.args |2 +- .../qemuxml2argvdata/qemuxml2argv-bootloader.args |2 +- .../qemuxml2argv-clock-localtime.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args |2 +- .../qemuxml2argv-console-compat.args |2 +- .../qemuxml2argv-disk-cdrom-empty.args |2 +- .../qemuxml2argvdata/qemuxml2argv-disk-cdrom.args |2 +- .../qemuxml2argv-disk-drive-boot-cdrom.args|2 +- .../qemuxml2argv-disk-drive-boot-disk.args |2 +- .../qemuxml2argvdata/qemuxml2argv-disk-floppy.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-disk-many.args |2 +- .../qemuxml2argvdata/qemuxml2argv-disk-virtio.args |2 +- .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args |2 +- .../qemuxml2argv-graphics-sdl.args |2 +- .../qemuxml2argv-graphics-vnc.args |2 +- .../qemuxml2argv-input-usbmouse.args |2 +- .../qemuxml2argv-input-usbtablet.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-input-xen.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-minimal.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args |2 +- .../qemuxml2argv-misc-no-reboot.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-net-user.args |2 +- .../qemuxml2argvdata/qemuxml2argv-net-virtio.args |2 +- .../qemuxml2argv-parallel-tcp.args |2 +- .../qemuxml2argvdata/qemuxml2argv-serial-dev.args |2 +- .../qemuxml2argvdata/qemuxml2argv-serial-file.args |2 +- .../qemuxml2argvdata/qemuxml2argv-serial-many.args |2 +- .../qemuxml2argvdata/qemuxml2argv-serial-pty.args |2 +- .../qemuxml2argv-serial-tcp-telnet.args|2 +- .../qemuxml2argvdata/qemuxml2argv-serial-tcp.args |2 +- .../qemuxml2argvdata/qemuxml2argv-serial-udp.args |2 +- .../qemuxml2argvdata/qemuxml2argv-serial-unix.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args |2 +- tests/qemuxml2argvdata/qemuxml2argv-sound.args |2 +- tests/qemuxml2argvtest.c |3 ++- 37 files changed, 38 insertions(+), 37 deletions(-) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args index 3f45b24..6c062ae 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args @@ -1 +1 @@ -/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -serial none -parallel none -usb \ No newline at end of file +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -serial none -parallel none -usb ... [lots of generated changes elided] ... --- a/tests/qemuxml2argvdata/qemuxml2argv-sound.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-sound.args @@ -1 +1 @@ -/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -soundhw pcspk,es1370,sb16 \ No newline at end of file +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -soundhw pcspk,es1370,sb16 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d136a13..25465ae 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -53,7 +53,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, int extra goto fail; tmp = argv; -len = 0; +len = 1; /* for trailing newline */ while (*tmp) { len += strlen(*tmp) + 1; tmp++; @@ -68,6 +68,7 @@
Re: [libvirt] [PATCH]: ruby-libvirt migration fixes
Chris Lalancette [EMAIL PROTECTED] wrote: Jim Meyering wrote: diff -r c6a3e36cdf54 ext/libvirt/_libvirt.c --- a/ext/libvirt/_libvirt.cThu Jul 17 15:24:26 2008 -0700 +++ b/ext/libvirt/_libvirt.cFri Aug 08 06:04:56 2008 -0400 @@ -637,16 +637,51 @@ VALUE libvirt_conn_num_of_defined_storag } #endif +static char *get_string_or_nil(VALUE arg) +{ +if (TYPE(arg) == T_NIL) +return NULL; +else if (TYPE(arg) == T_STRING) +return STR2CSTR(arg); STR2CSTR is marked as obsolete in ruby.h, where it says to use StringValuePtr instead: /* obsolete API - use StringValuePtr() */ #define STR2CSTR(x) rb_str2cstr((VALUE)(x),0) Yeah, you are right. I looked through the ruby source code, actually, and I ended up using StringValueCStr (which is used elsewhere in the ruby-libvirt That does sound better, at least when (as here) you know there should be no empty string and no embedded NUL byte. bindings). It's basically the same as StringValuePtr, but does an additional check to make sure the string is not of 0 length and that there aren't additional embedded \0 in the string. I also updated the patch with the const pointers as you suggested. Attached. Thanks for the review! Looks fine. ACK. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: file backed usb massstorage #4
On Fri, Aug 08, 2008 at 04:04:17PM +0200, Guido Günther wrote: New patches attached. Patches apply on top of the hostdev patches. All commited, I just removed an extra space at end of line :-) thanks a lot ! Again a small patch to the doc describing it would fix the last weak spot, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH]: hostdev passthrough support take #4
Hi, On Fri, Aug 08, 2008 at 10:34:00AM -0400, Daniel Veillard wrote: [..snip..] I think the only thing missing is extending the descrition in the documentation would you mind adding a description in formatdomain.html(.in) Probably an USB devices section added below the elementsDisks part, explaining the syntaxes and stating that it was added in versions after 0.4.4 If you don't feel comfortable with that I can do it, but you know better :) Attached is a short patch for this. This might be a bit terse but we'll have to change this anyhow once pci passthrough for xen arrives. Cheers, -- Guido From 3a962e2f7a326e4dc8c27f37d7d206f6a6bf0530 Mon Sep 17 00:00:00 2001 From: Guido Guenther [EMAIL PROTECTED] Date: Fri, 8 Aug 2008 17:41:17 +0200 Subject: [PATCH] usb doc update --- docs/formatdomain.html.in | 49 +--- 1 files changed, 45 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d4f650e..1f02727 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -362,10 +362,11 @@ the device name in the guest OS. Treat it as a device ordering hint. The optional codebus/code attribute specifies the type of disk device to emulate; possible values are driver specific, with typical values being - ide, scsi, virtio, xen. If omitted, the bus type is inferred from - the style of the device name. eg, a device named 'sda' will typically be - exported using a SCSI bus. - span class=sinceSince 0.0.3; codebus/code attribute since 0.4.3/span/dd + ide, scsi, virtio, xen or usb. If omitted, the bus type is + inferred from the style of the device name. eg, a device named 'sda' + will typically be exported using a SCSI bus. + span class=sinceSince 0.0.3; codebus/code attribute since 0.4.3; +usb attribute value since after 0.4.4/span/dd dtcodedriver/code/dt ddIf the hypervisor supports multiple backend drivers, then the optional codedriver/code element allows them to be selected. The codename/code @@ -374,6 +375,46 @@ /dd /dl +h4a name=elementsUSBUSB devices/a/h4 + +p + USB devices attached to the host can be passed through to the guest using + the codehostdev/code element. span class=sincesince after 0.4.4/span +/p + +pre + ... + lt;hostdev mode='subsystem' type='usb'gt; + lt;sourcegt; + lt;vendor id='0x1234'/gt; + lt;product id='0xbeef'/gt; + lt;/sourcegt; + lt;/diskgt; + .../pre + +dl + dtcodehostdev/code/dt + ddThe codehostdev/code element is the main container for describing + host devices. For usb device passthrough codemode/code is always + subsystem and codetype/code is usb. + dtcodesource/code/dt + ddThe source element describes the device as seen from the host. + The USB device can either be addressed by vendor / product id using the + codevendor/code and codeproduct/code elements or by the device's + address on the hosts using the codeaddress/code element./dd + dtcodevendor/code, codeproduct/code/dt + ddThe codevendor/code and codeproduct/code elements each have an + codeid/code attribute that specifies the USB vendor and product id. + The ids can be given in decimal, hexadecimal (starting with 0x) or + ocatal (starting with 0) form./dd + dtcodeaddress/code/dt + ddThe codeaddress/code element has a codebus/code and + codedevice/code attribute to specify the USB bus and device number + the device appears at on the host. The values of these attributes can + be given in decimal, hexadecimal (starting with 0x) or ocatal (starting + with 0) form./dd +/dl + h4a name=elementsNICSNetwork interfaces/a/h4 pre -- 1.5.6.3 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] make sure we call the freshly build libvirtd
...not the one in $PATH. I was wondering why this test kept failing... -- Guido --- tests/daemon-conf |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/daemon-conf b/tests/daemon-conf index db1f0d3..4a42d1e 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -1,6 +1,8 @@ #!/bin/sh # Get coverage of libvirtd's config-parsing code. +LIBVIRTD=$abs_top_builddir/qemud/libvirtd + # Boilerplate code to set up a test directory, cd into it, # and to ensure we remove it upon completion. this_test_() { echo ./$0 | sed 's,.*/,,'; } @@ -27,7 +29,7 @@ while :; do # Change an RHS that starts with '' or '[' to 3. # Change an RHS that starts with 0 or 1 to the string 'foo'. sed $i's/ = [[].*/ = 3/;'$i's/ = [01].*/ = foo/' tmp.conf $f - libvirtd --config=$f 2 err fail=1 + $LIBVIRTD --config=$f 2 err fail=1 case $rhs in # ''*) msg='should be a string';; ''*) msg='invalid type: got long; expected string';; @@ -48,7 +50,7 @@ while :; do done # Run with the unmodified config file. -libvirtd --config=tmp.conf log 21 pid=$! +$LIBVIRTD --config=tmp.conf log 21 pid=$! sleep 2 kill $pid -- 1.5.6.3 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] make sure we call the freshly build libvirtd
Guido Guenther [EMAIL PROTECTED] wrote: ...not the one in $PATH. I was wondering why this test kept failing... You shouldn't need that change, since make check already sets PATH so that $abs_top_builddir/qemud is early in PATH. And it does it in such a way that it should work even if the absolute path contains shell meta-characters. Are you trying to run the test manually via ./daemon-conf? If you want to run just that one test, use this: make -C tests check TESTS=daemon-conf diff --git a/tests/daemon-conf b/tests/daemon-conf ... +LIBVIRTD=$abs_top_builddir/qemud/libvirtd ... -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] make sure we call the freshly build libvirtd
On Fri, Aug 08, 2008 at 06:30:56PM +0200, Jim Meyering wrote: Guido Guenther [EMAIL PROTECTED] wrote: ...not the one in $PATH. I was wondering why this test kept failing... You shouldn't need that change, since make check already sets PATH so that $abs_top_builddir/qemud is early in PATH. And it does it in such a way that it should work even if the absolute path contains shell meta-characters. I ran: cd tests/ make check and that particular check failed. I figure this isn't supported then? It works for all other tests and it works for daemon-conf with the patch I attached so it should probably be applied to make things a bit more newbie robust? -- Guido -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] make sure we call the freshly build libvirtd
Guido Günther [EMAIL PROTECTED] wrote: On Fri, Aug 08, 2008 at 06:30:56PM +0200, Jim Meyering wrote: Guido Guenther [EMAIL PROTECTED] wrote: ...not the one in $PATH. I was wondering why this test kept failing... You shouldn't need that change, since make check already sets PATH so that $abs_top_builddir/qemud is early in PATH. And it does it in such a way that it should work even if the absolute path contains shell meta-characters. I ran: cd tests/ make check and that particular check failed. I figure this isn't supported then? No, that should work fine. I've confirmed that it works for me, in a $srcdir build. Now trying a non-srcdir build... Yep, that works, too. Can you debug it? E.g., echo $PATH from within the script and figure out why it doesn't include $$abs_top_builddir/qemud. Are you using modern versions of automake, autoconf, etc.? It works for all other tests and it works for daemon-conf with the patch I attached so it should probably be applied to make things a bit more newbie robust? -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] introducing source name (for logical storage pools)
Hi Folks - This small patch is a proposed prerequisite for the storage pool discovery patch I submitted last week. Daniel B proposed having storage pool discovery return a bunch of XML storage source elements, rather than full pool elements (which contain target-dependent details like the local pool name and device or mount path -- things which don't need to be decided unless/until the pool is defined). I like his suggestion a lot, and I think it addresses the final API-definition problem keeping storage pool discovery out of libvirt. But ... it doesn't quite work for logical storage pools because those are created from the pool name element (which is the same as the volume group name). This patch introduces a new source element name, which is distinct from the pool name. name is used only by the logical storage backend, and represents the volume group name. For convenience and back-compatibility, source name defaults to the pool name if not specified when the pool is defined, and pool name defaults to the source name if not specified. There is no requirement that pool and source name be the same, though. While admittedly it seems a little weird, it does allow more flexibility (pool name not tied to vol group name), and allows source to fully specify a logical pool source, as it does for the other pool types[*]. Defaulting the source name from the pool name means all existing pool XML definitions continue to work. Defaulting the pool name from the source name is simply a matter of convenience (but perhaps a step too far?) If this is accepted, logical pool discovery can then return a bunch of sources like: sourcenameVolGroup00/name/source sourcenameVolGroup01/name/source Please note I'll be on vacation next week (Aug 11-15), so I may not be responding until the following week. Thanks, Dave [*] Well ... almost. Note that directory pools have a similar issue -- the source of the pool is given by the target path -- there's no source. I suppose implementing directory pool discovery (for the sake of completeness) means addressing this as well, maybe via some similar mechanism ... This patch introduces a new source element name, which is distinct from the pool name. name is used only by the logical storage backend, and represents the volume group name. For convenience and back-compatibility, source name defaults to the pool name if not specified when the pool is defined, and pool name defaults to the source name if not specified. There is no requirement that pool and source name be the same, though. Signed-off-by: David Lively [EMAIL PROTECTED] diff --git a/src/storage_backend.h b/src/storage_backend.h index 797ca01..422f26c 100644 --- a/src/storage_backend.h +++ b/src/storage_backend.h @@ -53,6 +53,7 @@ enum { VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE = (11), VIR_STORAGE_BACKEND_POOL_SOURCE_DIR = (12), VIR_STORAGE_BACKEND_POOL_SOURCE_ADAPTER = (13), +VIR_STORAGE_BACKEND_POOL_SOURCE_NAME= (14), }; typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions; diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c index 0c4f6a5..382078b 100644 --- a/src/storage_backend_logical.c +++ b/src/storage_backend_logical.c @@ -80,7 +80,7 @@ virStorageBackendLogicalSetActive(virConnectPtr conn, cmdargv[0] = VGCHANGE; cmdargv[1] = on ? -ay : -an; -cmdargv[2] = pool-def-name; +cmdargv[2] = pool-def-source.name; cmdargv[3] = NULL; if (virRun(conn, cmdargv, NULL) 0) @@ -213,7 +213,7 @@ virStorageBackendLogicalFindLVs(virConnectPtr conn, LVS, --separator, :, --noheadings, --units, b, --unbuffered, --nosuffix, --options, lv_name,uuid,devices,seg_size,vg_extent_size, -pool-def-name, NULL +pool-def-source.name, NULL }; int exitstatus; @@ -288,7 +288,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn, } vgargv[n++] = VGCREATE; -vgargv[n++] = pool-def-name; +vgargv[n++] = pool-def-source.name; pvargv[0] = PVCREATE; pvargv[2] = NULL; @@ -365,7 +365,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn, const char *prog[] = { VGS, --separator, :, --noheadings, --units, b, --unbuffered, --nosuffix, --options, vg_size,vg_free, -pool-def-name, NULL +pool-def-source.name, NULL }; int exitstatus; @@ -419,7 +419,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn, unsigned int flags ATTRIBUTE_UNUSED) { const char *cmdargv[] = { -VGREMOVE, -f, pool-def-name, NULL +VGREMOVE, -f, pool-def-source.name, NULL }; if (virRun(conn, cmdargv, NULL) 0) @@ -535,6 +535,7 @@ virStorageBackend virStorageBackendLogical = { .deleteVol = virStorageBackendLogicalDeleteVol, .poolOptions = { +.flags = VIR_STORAGE_BACKEND_POOL_SOURCE_NAME, .formatFromString =
Re: [libvirt] static ip address
On Sun, Aug 3, 2008 at 7:04 PM, Mads Chr. Olesen [EMAIL PROTECTED] wrote: lør, 02 08 2008 kl. 23:13 +0200, skrev Olivier Deckmyn: I would like to be able to choose on a way or another the ip of each of my VM. As far as I can understand, the only way to get an IP (from a vm point of view) if the dhcp it. But I have no garantee vm1 will always get x.x.x.1 Ip adress... This has been discussed previously, see https://www.redhat.com/archives/libvir-list/2008-April/msg00327.html Could someone please commit this patch, allowing libvirt to handle dnsmasq? -- Mads Chr. Olesen [EMAIL PROTECTED] shiyee.dk -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list