Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver
No answer ? De : Yves Vinter Envoyé : vendredi 26 septembre 2014 10:31 À : 'Eric Blake'; libvir-list@redhat.com Objet : RE: [libvirt] [PATCH] New features implemented in hyperv libvirt driver Hi Eric, As you know, the is no more development in hyperv libvirt driver since version 0.10.2. The last development was committed 2 years ago: 2012-09-06 Peter Krempahttp://libvirt.org/git/?p=libvirt.git;a=search;s=Peter+Krempa;st=author hyperv: Add implementation for virConnectListAllDomains()http://libvirt.org/git/?p=libvirt.git;a=commit;h=60d0ecdaa140b34241e0be15a6e1c9a0581acf19 treehttp://libvirt.org/git/?p=libvirt.git;a=tree;f=src/hyperv;hb=60d0ecdaa140b34241e0be15a6e1c9a0581acf19 | commitdiffhttp://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=60d0ecdaa140b34241e0be15a6e1c9a0581acf19 Subsequent commits are fixes for reported issues; the last commit has been done about 2 month ago: 2014-07-03 Ján Tomkohttp://libvirt.org/git/?p=libvirt.git;a=search;s=J%C3%A1n+Tomko;st=author Use virBufferCheckError everywhere we report OOM errorhttp://libvirt.org/git/?p=libvirt.git;a=commit;h=92a8e72f9de5b4c435f66fd68cfde623225f13ba treehttp://libvirt.org/git/?p=libvirt.git;a=tree;f=src/hyperv;hb=92a8e72f9de5b4c435f66fd68cfde623225f13ba | commitdiffhttp://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=92a8e72f9de5b4c435f66fd68cfde623225f13ba Therefore, I didn’t miss any features … (verified after a sync) I understand that it would be easier for you to review the code to have the patch split by feature. I will make may best to help you in this way… Is that the last requirement ? Thanks, Yves. -Message d'origine- De : Eric Blake [mailto:ebl...@redhat.com] Envoyé : jeudi 25 septembre 2014 18:59 À : Yves Vinter; libvir-list@redhat.commailto:libvir-list@redhat.com Objet : Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver On 09/25/2014 06:38 AM, Yves Vinter wrote: Authors: Simon Rastello (Bull), Adrien Kantcheff (Bull), Yves Vinter (Bull) *** Summary of new features added in hyperv driver version 1.2.9 *** - Added a mutex to prevent concurrent requests from being run simultaneously [WSMAN libray not thread-safe] - Support of default authentication (credentials specified in ~/.config/libvirt/auth.conf) - Support of new types of WSMAN requests involving passing complex parameters (simple types, EPR, embedded objects) Required a new auto-generated header file to get the type of objects attributes (hyperv_wmi_classes_attr.generated.h) - New functions: - host management (in hyperv_driver module) - capabilities (limited) - domain management (in hyperv_driver module) - domain creation from an XML description - domain destruction - attachment of pre-existing disk images on IDE controller - attachment of Synthetic network devices - memory and vcpu management (get and set methods) - autostart, shutdown, ... - network management (in hyperv_network_driver module) - list available networks - informations for a specified network Required the declaration of new classes (in hyperv_wmi_generator.input) - Fixed several memory leak issues Please split each of these bulleted list items into a separate patch, for easier review. No one likes to review a 150k single patch. Also, it looks like you just missed feature freeze for 1.2.9; by the time you've split the series, it is probably a better candidate for inclusion in 1.2.10 around the end of October. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] increase number of libvirt threads by starting tansient guest doamin - is it a bug?
Hi Jim, i use libvirt 1.1.3.5 on fedora core 20, the vm´s i startet are xen-vm´s. i also take a look on libvirt 1.1.2 on an openSuSE 13.1 und also on libvirt 1.0.2 on an OpenSuSE 12.3 and i didn´t see threads that are created and not closed . But on the openSuSE-Systems the vm´s are KVM/qemu. on the fedora-system i will attach gdb to the libvirtd-process, and hope to see what´s doing on. all the best max ursprüngliche Nachricht- Von: Jim Fehlig jfeh...@suse.com An: usterman...@web.de Kopie: libvir-list@redhat.com, libvirt-us...@redhat.com Datum: Tue, 30 Sep 2014 18:44:17 -0600 - usterman...@web.de wrote: hello, if i start a transient guest doamin via virsh create abcd.xml i see an additional libvirt thread and also some open files: pstree -h `pgrep libvirtd` libvirtd───11*[{libvirtd}] libvirtd 3016 root 21w REG 253,0 6044 1052094 /var/log/libvirt/libxl/abcd.log libvirtd 3016 root 22r FIFO 0,8 0t0 126124 pipe libvirtd 3016 root 23w FIFO 0,8 0t0 126124 pipe libvirtd 3016 root 24u REG 0,37 0 4 /proc/xen/privcmd libvirtd 3016 root 25u unix 0x8807d2c3ad80 0t0 126125 socket libvirtd 3016 root 26r FIFO 0,8 0t0 126127 pipe libvirtd 3016 root 27w FIFO 0,8 0t0 126127 pipe libvirtd 3016 root 28r FIFO 0,8 0t0 124783 pipe libvirtd 3016 root 29w FIFO 0,8 0t0 124783 pipe libvirtd 3016 root 30r FIFO 0,8 0t0 127140 pipe libvirtd 3016 root 31w FIFO 0,8 0t0 127140 pipe if i destroy these vm via virsh destroy abcd, i see that the additional thread still exists and also the list of openfiles is the same. I don't see this behavior with current libvirt git master # pstree `pgrep libvirtd` libvirtd───10*[{libvirtd}] # virsh create ./test.xml Domain test created from ./test.xml # pstree `pgrep libvirtd` libvirtd───11*[{libvirtd}] # virsh destroy test Domain test destroyed # pstree `pgrep libvirtd` libvirtd───10*[{libvirtd}] All file descriptors opened when the domain was created were closed as well. What version of libvirt are you using? Regards, Jim -- -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver
Hi Yves, On Wed, Oct 01, 2014 at 06:59:52AM +, Yves Vinter wrote: No answer ? If you split the patch in several smaller chunks as Eric requested and send them to the mailing list for review, the next steps will be that people on this list will review pour patch, potentially make comments about how the code could be made better, or point out some bugs, ... If there are such comments, you'll have to address them, and potentially send revised versions of the patches. If there are no review comments, they will be committed in the upstream repository. I don't know if this is the kind of answer you were waiting for? Christophe pgpD7SWlAJHoz.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH/RFC] Add missing delta from Ubuntu to apparmor profiles
This had been on the Debian package list before but its time to take this onwards. So the goal would be to have one set to rule them all (when using apparmor) and drop the seperate set of definitions which exist at least in the Ubuntu packaging. Right now the patch would be at a state which adds all missing files and rules to the current examples in libvirt and installs them when using --with-apparmor-profiles. One problem seems to be that some of the definitions might cause parse failures on certain versions of apparmor. I checked this morning and this looks a bit hairy. So some apparmor 2.8 versions potentially have issues, but not all apparmor 2.8 are the same (gah). I could imagine (but John, we really could use some guidance here ;)) that at least some changes could be related to version 2.8.95~2430: + debian/patches/mediate-signals.patch, debian/patches/change-signal-syntax.patch: Parse signal rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. + debian/patches/change-ptrace-syntax.patch, debian/patches/mediate-ptrace.patch: Parse ptrace rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. But, regardless of the when, the apparmor rules maybe need a way to handle versioned features of the parser. One proposal was to comment out problematic rules and allow the packager to re-enable things. Maybe going one step further and have some pre-processing that handles version based sections (like #if (APPARMOR_VERSION = xxx)). So that is where we stand. Ideas are very welcome. -Stefan --- From aec5cf8cc30c80492a37856626264c3d4c27a31f Mon Sep 17 00:00:00 2001 From: Stefan Bader stefan.ba...@canonical.com Date: Thu, 18 Sep 2014 14:15:17 +0200 Subject: [PATCH] Add missing delta from Ubuntu to apparmor profiles This fixes up the upstream profiles and would allow to drop apparmor related delta from the Ubuntu package. Thanks to Serge Hallyn for the Makefile.am install hook that allows to rename the local file. Signed-off-by: Stefan Bader stefan.ba...@canonical.com --- examples/apparmor/Makefile.am| 10 examples/apparmor/libvirt-lxc| 15 +++- examples/apparmor/libvirt-qemu | 31 +++- examples/apparmor/local-usr.sbin.libvirtd| 2 ++ examples/apparmor/usr.lib.libvirt.virt-aa-helper | 25 --- examples/apparmor/usr.sbin.libvirtd | 17 - 6 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 examples/apparmor/local-usr.sbin.libvirtd diff --git a/examples/apparmor/Makefile.am b/examples/apparmor/Makefile.am index 7a20e16..aa46cb9 100644 --- a/examples/apparmor/Makefile.am +++ b/examples/apparmor/Makefile.am @@ -20,6 +20,7 @@ EXTRA_DIST= \ libvirt-qemu\ libvirt-lxc \ usr.lib.libvirt.virt-aa-helper \ + local-usr.sbin.libvirtd \ usr.sbin.libvirtd if WITH_APPARMOR_PROFILES @@ -29,6 +30,15 @@ apparmor_DATA = \ usr.sbin.libvirtd \ $(NULL) +localdir = $(apparmordir)/local +local_DATA = \ + local-usr.sbin.libvirtd \ + $(NULL) + +install-data-hook: + mv $(DESTDIR)$(localdir)/local-usr.sbin.libvirtd \ + $(DESTDIR)$(localdir)/usr.sbin.libvirtd + abstractionsdir = $(apparmordir)/abstractions abstractions_DATA = \ libvirt-qemu \ diff --git a/examples/apparmor/libvirt-lxc b/examples/apparmor/libvirt-lxc index 4bfb503..4705e0a 100644 --- a/examples/apparmor/libvirt-lxc +++ b/examples/apparmor/libvirt-lxc @@ -1,12 +1,18 @@ -# Last Modified: Fri Feb 7 13:01:36 2014 +# Last Modified: Thu, 18 Sep 2014 13:56:49 +0200 #include abstractions/base umount, + dbus, + signal, + ptrace, # ignore DENIED message on / remount deny mount options=(ro, remount) - /, + # support use of cgmanager proxy + mount options=(move) /sys/fs/cgroup/cgmanager/ - /sys/fs/cgroup/cgmanager.lower/, + # allow tmpfs mounts everywhere mount fstype=tmpfs, @@ -33,8 +39,15 @@ mount fstype=fusectl - /sys/fs/fuse/connections/, mount fstype=securityfs - /sys/kernel/security/, mount fstype=debugfs - /sys/kernel/debug/, + deny mount fstype=debugfs - /var/lib/ureadahead/debugfs/, mount fstype=proc - /proc/, mount fstype=sysfs - /sys/, + + mount options=(rw nosuid nodev noexec remount) - /sys/, + mount options=(rw remount) - /sys/kernel/security/, + mount options=(rw remount) - /sys/fs/pstore/, + mount options=(ro remount) - /sys/fs/pstore/, + deny /sys/firmware/efi/efivars/** rwklx, deny /sys/kernel/security/** rwklx, diff --git a/examples/apparmor/libvirt-qemu b/examples/apparmor/libvirt-qemu index c6de6dd..b69e64c 100644 --- a/examples/apparmor/libvirt-qemu +++ b/examples/apparmor/libvirt-qemu @@ -1,4 +1,4 @@ -# Last Modified: Wed Sep 3 21:52:03 2014 +# Last Modified: Thu, 18 Sep 2014 16:41:21
Re: [libvirt] increase number of libvirt threads by starting tansient guest doamin - is it a bug?
Hello, sorry for my later answer. so, after i started libvirtd (no vm´s running) and attach gdb i get the following threads (gdb) info thread Id Target Id Frame 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i restore an persistent domain, i see the following in gdb: Detaching after fork from child process 20880. Detaching after fork from child process 20882. [New Thread 0x7f190893d700 (LWP 20883)] Detaching after fork from child process 20890. Detaching after fork from child process 20906. (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i now destroy this vm i get the following: (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at
Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver
Hi Christophe, I understand clearly the process. I was just asking if there are some other requirements I should be aware of juts to save time. BTW. Splitting the developments into several patchs (by features) will introduce a dependency between them; they will have to be reviewed and applied in a specific order. Does it mean that the new set of patch must be submitted one after one ? In case a patch needs to be revised, all other patchs (on the same source code) may need to be regenerated, right ? Thanks, Yves. -Message d'origine- De : Christophe Fergeau [mailto:cferg...@redhat.com] Envoyé : mercredi 1 octobre 2014 10:20 À : Yves Vinter Cc : Eric Blake; libvir-list@redhat.com Objet : Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver Hi Yves, On Wed, Oct 01, 2014 at 06:59:52AM +, Yves Vinter wrote: No answer ? If you split the patch in several smaller chunks as Eric requested and send them to the mailing list for review, the next steps will be that people on this list will review pour patch, potentially make comments about how the code could be made better, or point out some bugs, ... If there are such comments, you'll have to address them, and potentially send revised versions of the patches. If there are no review comments, they will be committed in the upstream repository. I don't know if this is the kind of answer you were waiting for? Christophe -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/8] Added public API to enable post-copy migration
On 2014-09-30 17:16, Daniel P. Berrange wrote: On Tue, Sep 30, 2014 at 05:11:03PM +0200, Jiri Denemark wrote: On Tue, Sep 30, 2014 at 16:39:22 +0200, Cristian Klein wrote: Signed-off-by: Cristian Klein cristian.kl...@cs.umu.se --- include/libvirt/libvirt.h.in | 1 + src/libvirt.c| 7 +++ 2 files changed, 8 insertions(+) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5217ab3..82f3aeb 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1225,6 +1225,7 @@ typedef enum { VIR_MIGRATE_ABORT_ON_ERROR= (1 12), /* abort migration on I/O errors happened during migration */ VIR_MIGRATE_AUTO_CONVERGE = (1 13), /* force convergence */ VIR_MIGRATE_RDMA_PIN_ALL = (1 14), /* RDMA memory pinning */ +VIR_MIGRATE_POSTCOPY = (1 15), /* enable (but don't start) post-copy */ } virDomainMigrateFlags; I still think we should add an extra flag to start post copy immediately. To address your concerns about it, I don't think it's implementing a policy in libvirt. It's for apps that want to make sure migration converges without having to spawn another thread and monitor the progress or wait for a timeout. It's a bit similar to migrating a paused domain vs. migrating a running domain and pausing it when it doesn't seem to converge. Your point about spawning another thread makes me wonder if we should actually look at adding a 'VIR_MIGRATE_ASYNC' method (that would require P2P migration of course). If this flag were set, virDomainMigrateXXX would only block for long enough to start the migration and then return. Callers can use the job info API to monitor progress success/failure. Then we wouldn't have to keep adding flags like you suggest - apps can just easily call the appropriate API right away with no threads needed This would make a lot of sense. The user would call: virDomainMigrateXXX(..., VIR_MIGRATE_POSTCOPY | VIR_MIGRATE_ASYNC) virDomainMigrateStartPostCopy(...) Would this be seen as more cumbersome than having a dedicated VIR_MIGRATE_POSTCOPY_AUTOSTART? -- Cristian Klein, PhD Post-doc @ Umeå Universitet http://www8.cs.umu.se/~cklein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver
On Wed, Oct 01, 2014 at 08:37:43AM +, Yves Vinter wrote: Hi Christophe, I understand clearly the process. I was just asking if there are some other requirements I should be aware of juts to save time. BTW. Splitting the developments into several patchs (by features) will introduce a dependency between them; they will have to be reviewed and applied in a specific order. Does it mean that the new set of patch must be submitted one after one ? In case a patch needs to be revised, all other patchs (on the same source code) may need to be regenerated, right ? Yes, that's correct. When working on a large feature like this our general recommendation is to create a branch for the new work. Then on that branch you'll end up with a sequence of patches committed. You can use 'git rebase -i master' to edit that series of patches to prepare it. Once you're happy with the branch then if you use 'git send-email master..' it will automatically turn the contents of your current branch into a series of linked emails and send them to the list in the right order. If you've not used git send-email before, it is wise to test it first by sending the patches to your own email address. That lets you see that they are formatted how you expect, before sending them to this mailing list. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/8] Added public API to enable post-copy migration
On Wed, Oct 01, 2014 at 10:45:33AM +0200, Cristian KLEIN wrote: On 2014-09-30 17:16, Daniel P. Berrange wrote: On Tue, Sep 30, 2014 at 05:11:03PM +0200, Jiri Denemark wrote: On Tue, Sep 30, 2014 at 16:39:22 +0200, Cristian Klein wrote: Signed-off-by: Cristian Klein cristian.kl...@cs.umu.se --- include/libvirt/libvirt.h.in | 1 + src/libvirt.c| 7 +++ 2 files changed, 8 insertions(+) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5217ab3..82f3aeb 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1225,6 +1225,7 @@ typedef enum { VIR_MIGRATE_ABORT_ON_ERROR= (1 12), /* abort migration on I/O errors happened during migration */ VIR_MIGRATE_AUTO_CONVERGE = (1 13), /* force convergence */ VIR_MIGRATE_RDMA_PIN_ALL = (1 14), /* RDMA memory pinning */ +VIR_MIGRATE_POSTCOPY = (1 15), /* enable (but don't start) post-copy */ } virDomainMigrateFlags; I still think we should add an extra flag to start post copy immediately. To address your concerns about it, I don't think it's implementing a policy in libvirt. It's for apps that want to make sure migration converges without having to spawn another thread and monitor the progress or wait for a timeout. It's a bit similar to migrating a paused domain vs. migrating a running domain and pausing it when it doesn't seem to converge. Your point about spawning another thread makes me wonder if we should actually look at adding a 'VIR_MIGRATE_ASYNC' method (that would require P2P migration of course). If this flag were set, virDomainMigrateXXX would only block for long enough to start the migration and then return. Callers can use the job info API to monitor progress success/failure. Then we wouldn't have to keep adding flags like you suggest - apps can just easily call the appropriate API right away with no threads needed This would make a lot of sense. The user would call: virDomainMigrateXXX(..., VIR_MIGRATE_POSTCOPY | VIR_MIGRATE_ASYNC) virDomainMigrateStartPostCopy(...) Would this be seen as more cumbersome than having a dedicated VIR_MIGRATE_POSTCOPY_AUTOSTART? I think it is still acceptably simple - the root complaint that Jiri had was that he doesn't want apps to have to spawn threads, which this proposal of mine achieves. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH/RFC] Add missing delta from Ubuntu to apparmor profiles
On Wed, Oct 01, 2014 at 10:30:58AM +0200, Stefan Bader wrote: This had been on the Debian package list before but its time to take this onwards. So the goal would be to have one set to rule them all (when using apparmor) and drop the seperate set of definitions which exist at least in the Ubuntu packaging. Right now the patch would be at a state which adds all missing files and rules to the current examples in libvirt and installs them when using --with-apparmor-profiles. One problem seems to be that some of the definitions might cause parse failures on certain versions of apparmor. I checked this morning and this looks a bit hairy. So some apparmor 2.8 versions potentially have issues, but not all apparmor 2.8 are the same (gah). What versions of apparmour are present in the currently supported versions of Debian Ubuntu ? I could imagine (but John, we really could use some guidance here ;)) that at least some changes could be related to version 2.8.95~2430: + debian/patches/mediate-signals.patch, debian/patches/change-signal-syntax.patch: Parse signal rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. + debian/patches/change-ptrace-syntax.patch, debian/patches/mediate-ptrace.patch: Parse ptrace rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. But, regardless of the when, the apparmor rules maybe need a way to handle versioned features of the parser. One proposal was to comment out problematic rules and allow the packager to re-enable things. Maybe going one step further and have some pre-processing that handles version based sections (like #if (APPARMOR_VERSION = xxx)). I think it would be pretty reasonable to rename the files in have '.in' suffixes, and then have a build script that expands 'if APPARMOR_VERSION' conditionals to generate the final file. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/8] Added public API to enable post-copy migration
On Wed, Oct 01, 2014 at 10:45:33 +0200, Cristian KLEIN wrote: On 2014-09-30 17:16, Daniel P. Berrange wrote: On Tue, Sep 30, 2014 at 05:11:03PM +0200, Jiri Denemark wrote: On Tue, Sep 30, 2014 at 16:39:22 +0200, Cristian Klein wrote: Signed-off-by: Cristian Klein cristian.kl...@cs.umu.se --- include/libvirt/libvirt.h.in | 1 + src/libvirt.c| 7 +++ 2 files changed, 8 insertions(+) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5217ab3..82f3aeb 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1225,6 +1225,7 @@ typedef enum { VIR_MIGRATE_ABORT_ON_ERROR= (1 12), /* abort migration on I/O errors happened during migration */ VIR_MIGRATE_AUTO_CONVERGE = (1 13), /* force convergence */ VIR_MIGRATE_RDMA_PIN_ALL = (1 14), /* RDMA memory pinning */ +VIR_MIGRATE_POSTCOPY = (1 15), /* enable (but don't start) post-copy */ } virDomainMigrateFlags; I still think we should add an extra flag to start post copy immediately. To address your concerns about it, I don't think it's implementing a policy in libvirt. It's for apps that want to make sure migration converges without having to spawn another thread and monitor the progress or wait for a timeout. It's a bit similar to migrating a paused domain vs. migrating a running domain and pausing it when it doesn't seem to converge. Your point about spawning another thread makes me wonder if we should actually look at adding a 'VIR_MIGRATE_ASYNC' method (that would require P2P migration of course). If this flag were set, virDomainMigrateXXX would only block for long enough to start the migration and then return. Callers can use the job info API to monitor progress success/failure. Then we wouldn't have to keep adding flags like you suggest - apps can just easily call the appropriate API right away with no threads needed This would make a lot of sense. The user would call: virDomainMigrateXXX(..., VIR_MIGRATE_POSTCOPY | VIR_MIGRATE_ASYNC) virDomainMigrateStartPostCopy(...) Would this be seen as more cumbersome than having a dedicated VIR_MIGRATE_POSTCOPY_AUTOSTART? The ASYNC flag Daniel suggested makes sense, so I guess you can just ignore my request for a special flag. Although, I don't think the ASYNC stuff needs to be done within this series, let's just focus on the post-copy stuff. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] qemu: bulk stats: add block allocation information
On 09/29/14 20:32, Eric Blake wrote: On 09/25/2014 06:06 AM, Peter Krempa wrote: From: Francesco Romani from...@redhat.com Management software wants to be able to allocate disk space on demand. To support this they need keep track of the space occupation of the block device. This information is reported by qemu as part of block stats. This patch extend the block information in the bulk stats with the allocation information. To keep the same behaviour a helper is extracted from qemuMonitorJSONGetBlockExtent in order to get per-device allocation information. And this also sounds useful for my work on trying to add a flag for showing capacity information during dumpxml. Signed-off-by: Francesco Romani from...@redhat.com Signed-off-by: Peter Krempa pkre...@redhat.com --- src/libvirt.c| 6 +++ src/qemu/qemu_driver.c | 27 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 91 ++-- 4 files changed, 105 insertions(+), 20 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index aa83365..b078eed 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -21656,6 +21656,12 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * unsigned long long. * block.num.errors - Xen only: the 'oo_req' value as *unsigned long long. + * block.num.allocation - offset of the highest written sector + *as unsigned long long. + * block.num.capacity - logical size in bytes of the block device backing + * image as unsinged long long. s/unsinged/unsigned/ + * block.num.physical - physical size in bytes of the container of the + * backing image as unsigned long long. * +typedef enum { +QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK, +QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT, +QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS, +QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET +} qemuMonitorBlockExtentError; Prefer trailing commas in the enum. ACK. Border-line on whether 2 and 3 are a feature addition, or rounding out the completed implementation (and therefore a bug fix) of a feature already being introduced in 1.2.9. So I'll leave it up to you on whether to push or delay, if no one else chimes in. They are now pushed as the release is out. Peter signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Release of libvirt 1.2.9
As planned the release of libvirt 1.2.9 is available, tagged in git, signed sources and rpms are available at the usual place: ftp://libvirt.org/libvirt/ I also pushed the libvirt-python release 1.2.9 to its own location: ftp://libvirt.org/libvirt/python/ This release introduce some new APIs and functionalities as well as a number of bug fixes including 2 security fixes: CVE-2014-3633 and CVE-2014-3657 which has been pushed as part of the release. There is also a number of improvements available. In a nutshell users are invited to upgrade. Features: - Introduce virNodeAllocPages (Michal Privoznik) - event: introduce new event for tunable values (Pavel Hrdina) - add migration support for OpenVZ driver (Hongbin Lu) - Add support for fetching statistics of completed jobs (Jiri Denemark) Security: - CVE-2014-3657: domain_conf: fix domain deadlock (Pavel Hrdina) - CVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk (Peter Krempa) Documentation: - LXC: emphasis uid start of idmap only accept '0' in docs (Chen Hanxiao) - specify vhost-net instead of net-vhost (Jianwei Hu) - LXC: add HOME environment variable docs (Chen Hanxiao) - update zfs documentation (Roman Bogorodskiy) - man: virsh: Add docs for supported stats groups (Peter Krempa) - lib: Document that virConnectGetAllDomainStats may omit some stats fields (Peter Krempa) - lib: De-duplicate stats group documentation for all stats functions (Peter Krempa) - util: Fix copy-paste error in virXPathLongLong description (Martin Kletzander) - formatdomain: Update loader/ example to match the rest (Michal Privoznik) - virsh: desc command in --title mode mentions description instead of title (Peter Krempa) - fix encryption format attribute in example (Ján Tomko) Bug Fixes: - Allow setting migration max downtime any time (Chris St. Pierre) - qemu: monitor: return block stats data as a hash to avoid disk mixup (Peter Krempa) - Also filter out non-migratable features out of host-passthrough (Ján Tomko) - Don't verify CPU features with host-passthrough (Ján Tomko) - Fix crash cpu_shares change event crash on domain startup (Ján Tomko) - storage: Fix logical pool fmt type (Erik Skultety) - virsh: Fix help message of allocpages (Tomoki Sekiyama) - qemu: remove capabilities.monitor.sock when done (Guido Günther) - conf: report error in virCPUDefParseXML (Jincheng Miao) - Check for NULL in qemu monitor event filter (Ján Tomko) - qemuPrepareNVRAM: Save domain after NVRAM path generation (Michal Privoznik) - remoteNodeGetFreePages: Don't alloc args.pages.pages_val (Michal Privoznik) - virNodeAllocPages: Disallow RO connection (Michal Privoznik) - polkit_driver: fix possible segfault (Pavel Hrdina) - blkdeviotune: fix bug with saving values into live XML (Pavel Hrdina) - security: Fix labelling host devices (bz 1145968) (Cole Robinson) - nodeinfo: fix nodeGetFreePages when max node is zero (Jincheng Miao) - Fix bug with loading bridge name for active domain during libvirtd start (Pavel Hrdina) - libvirt-guests: run after time-sync.target (Jim Fehlig) - qemu: Fix memory leak in RDMA migration code (Jiri Denemark) - nodeinfo: report error when given node is out of range (Jincheng Miao) - virsh-host: fix pagesize unit of freepages (Jincheng Miao) - qemu: raise an error when trying to use readonly sata disks (Giuseppe Scrivano) - qemu: Add missing goto on rawio (John Ferlan) - Move the FIPS detection from capabilities (Pavel Hrdina) - virSecuritySELinuxSetTapFDLabel: Temporarily revert to old behavior (Michal Privoznik) - audit: fix memory leak without WITH_AUDIT (Ján Tomko) - Fixes for domains with no iothreads (Ján Tomko) - Fix leak in x86UpdateHostModel (Ján Tomko) - Fix libvirtd crash when removing metadata (Erik Skultety) - qemu: Don't fail startup/attach for IOThreads if no JSON (John Ferlan) - qemu: fix crash with shared disks (Ján Tomko) - qemu: Honor hugepages for UMA domains (Michal Privoznik) - conf: Disallow nonexistent NUMA nodes for hugepages (Michal Privoznik) - domaincapstest: Run cleanly on systems missing OVMF firmware (Michal Privoznik) - util: storage: Copy driver type when initializing chain element (Peter Krempa) - qemu: time: Report errors if agent command fails (Peter Krempa) - network: check negative values in bridge queues (Erik Skultety) - openvz: fixed two memory leaks on migration code (Hongbin Lu) - util: storage: Fix qcow(2) header parser according to docs (Peter Krempa) - qemu: Fix call in qemuDomainSetNumaParamsLive for virCgroupNewIOThread (John Ferlan) - qemu: Fix iothreads issue (John Ferlan) - domain_conf: Add iothreadpin to cputune (John Ferlan) - network: check for invalid forward delay time (Erik Skultety) - qemu: Fix build breaker on printf directive (John Ferlan) - daemon: Resolve Coverity FORWARD_NULL (John Ferlan) - qemu: Resolve Coverity BAD_SIZEOF (John Ferlan) - Resolve Coverity CHECKED_RETURN (John Ferlan) - virsh: Resolve Coverity DEADCODE (John Ferlan) - domain_conf: Resolve
Re: [libvirt] [PATCH/RFC] Add missing delta from Ubuntu to apparmor profiles
On 01.10.2014 11:04, Daniel P. Berrange wrote: On Wed, Oct 01, 2014 at 10:30:58AM +0200, Stefan Bader wrote: This had been on the Debian package list before but its time to take this onwards. So the goal would be to have one set to rule them all (when using apparmor) and drop the seperate set of definitions which exist at least in the Ubuntu packaging. Right now the patch would be at a state which adds all missing files and rules to the current examples in libvirt and installs them when using --with-apparmor-profiles. One problem seems to be that some of the definitions might cause parse failures on certain versions of apparmor. I checked this morning and this looks a bit hairy. So some apparmor 2.8 versions potentially have issues, but not all apparmor 2.8 are the same (gah). What versions of apparmour are present in the currently supported versions of Debian Ubuntu ? The way release are handled in Ubuntu (once released there is usually no backporting) we would have to worry less about supported releases. For the Debian side I would think this is similar (correct me if I am wrong, please). So it looks to me that right now this would be down to Debian having 2.8.0 in unstable/testing and Ubuntu having 2.8.96~2652 in Utopic (with the same version in Debian experimental). Right now I would expect it to boil down to those two. But I suppose the parser can change again and so there might be a similar situation in the future. -Stefan I could imagine (but John, we really could use some guidance here ;)) that at least some changes could be related to version 2.8.95~2430: + debian/patches/mediate-signals.patch, debian/patches/change-signal-syntax.patch: Parse signal rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. + debian/patches/change-ptrace-syntax.patch, debian/patches/mediate-ptrace.patch: Parse ptrace rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. But, regardless of the when, the apparmor rules maybe need a way to handle versioned features of the parser. One proposal was to comment out problematic rules and allow the packager to re-enable things. Maybe going one step further and have some pre-processing that handles version based sections (like #if (APPARMOR_VERSION = xxx)). I think it would be pretty reasonable to rename the files in have '.in' suffixes, and then have a build script that expands 'if APPARMOR_VERSION' conditionals to generate the final file. Regards, Daniel signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] qemu: bulk stats: add block allocation information
On 09/25/2014 08:06 AM, Peter Krempa wrote: From: Francesco Romani from...@redhat.com Management software wants to be able to allocate disk space on demand. To support this they need keep track of the space occupation of the block device. This information is reported by qemu as part of block stats. This patch extend the block information in the bulk stats with the allocation information. To keep the same behaviour a helper is extracted from qemuMonitorJSONGetBlockExtent in order to get per-device allocation information. Signed-off-by: Francesco Romani from...@redhat.com Signed-off-by: Peter Krempa pkre...@redhat.com --- src/libvirt.c| 6 +++ src/qemu/qemu_driver.c | 27 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 91 ++-- 4 files changed, 105 insertions(+), 20 deletions(-) ,,, int qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b634121..c41a7fb 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1782,6 +1782,40 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon, } +typedef enum { +QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK, +QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT, +QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS, +QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET +} qemuMonitorBlockExtentError; + + +static int +qemuMonitorJSONDevGetBlockExtent(virJSONValuePtr dev, + unsigned long long *extent) +{ +virJSONValuePtr stats; +virJSONValuePtr parent; + +if ((parent = virJSONValueObjectGet(dev, parent)) == NULL || +parent-type != VIR_JSON_TYPE_OBJECT) { +return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT; +} + +if ((stats = virJSONValueObjectGet(parent, stats)) == NULL || +stats-type != VIR_JSON_TYPE_OBJECT) { +return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS; +} + +if (virJSONValueObjectGetNumberUlong(stats, wr_highest_offset, + extent) 0) { +return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET; +} + +return QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK; +} + + int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, virHashTablePtr *ret_stats) { @@ -1908,6 +1942,9 @@ int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, goto cleanup; } +/* it's ok to not have this information here. Just skip silently. */ +qemuMonitorJSONDevGetBlockExtent(dev, bstats-wr_highest_offset); + if (virHashAddEntry(hash, devname, bstats) 0) goto cleanup; bstats = NULL; @@ -2077,6 +2114,36 @@ int qemuMonitorJSONGetBlockStatsParamsNumber(qemuMonitorPtr mon, return ret; } + +static int +qemuMonitorJSONReportBlockExtentError(qemuMonitorBlockExtentError error) +{ +switch (error) { +case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT: +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(blockstats parent entry was not in + expected format)); +break; + +case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS: +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(blockstats stats entry was not in + expected format)); + Missing a break; (found by my monrning Coverity run) John +case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET: +virReportError(VIR_ERR_INTERNAL_ERROR, + _(cannot read %s statistic), + wr_highest_offset); +break; + +case QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK: +return 0; +} + +return -1; +} + + int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon, const char *dev_name, unsigned long long *extent) @@ -2111,9 +2178,8 @@ int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon, for (i = 0; i virJSONValueArraySize(devices); i++) { virJSONValuePtr dev = virJSONValueArrayGet(devices, i); -virJSONValuePtr stats; -virJSONValuePtr parent; const char *thisdev; +int err; if (!dev || dev-type != VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(blockstats device entry was not in expected format)); @@ -2137,24 +2203,9 @@ int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon, continue; found = true; -if ((parent = virJSONValueObjectGet(dev, parent)) == NULL || -parent-type != VIR_JSON_TYPE_OBJECT) { -virReportError(VIR_ERR_INTERNAL_ERROR, %s, - _(blockstats parent entry was not in
Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver
On Wed, Oct 01, 2014 at 11:03:40AM +, Yves Vinter wrote: Do I need credentials and/or specific rights on the libvirt git to do that? No, you do everything in your local GIT checkout - there's no need for your branch to be public Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] Fix hot unplug of scsi_host hostdev
On 09/24/2014 09:11 AM, John Ferlan wrote: https://bugzilla.redhat.com/show_bug.cgi?id=1141732 Attempting to hot unplug a scsi_host device fails. The first patch resolves the issue (and has some details in the commit message). The second patch removes the now unnecessary virConnectPtr from various places. The third patch resolves a potential issue if aliases weren't defined and debugging is enabled by making the check for NULL first before trying to message rather than the other way around. John Ferlan (3): qemu: Fix hot unplug of SCSI_HOST device qemu: Remove need for virConnectPtr in hotunplug detach host, net qemu: Remove possible NULL deref in debug output src/qemu/qemu_driver.c | 4 +-- src/qemu/qemu_hotplug.c | 70 +++-- src/qemu/qemu_hotplug.h | 6 ++--- 3 files changed, 37 insertions(+), 43 deletions(-) Now that 1.2.9 is out - ping? Tks, John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver
Do I need credentials and/or specific rights on the libvirt git to do that? -Message d'origine- De : Daniel P. Berrange [mailto:berra...@redhat.com] Envoyé : mercredi 1 octobre 2014 10:58 À : Yves Vinter Cc : Christophe Fergeau; libvir-list@redhat.com Objet : Re: [libvirt] [PATCH] New features implemented in hyperv libvirt driver On Wed, Oct 01, 2014 at 08:37:43AM +, Yves Vinter wrote: Hi Christophe, I understand clearly the process. I was just asking if there are some other requirements I should be aware of juts to save time. BTW. Splitting the developments into several patchs (by features) will introduce a dependency between them; they will have to be reviewed and applied in a specific order. Does it mean that the new set of patch must be submitted one after one ? In case a patch needs to be revised, all other patchs (on the same source code) may need to be regenerated, right ? Yes, that's correct. When working on a large feature like this our general recommendation is to create a branch for the new work. Then on that branch you'll end up with a sequence of patches committed. You can use 'git rebase -i master' to edit that series of patches to prepare it. Once you're happy with the branch then if you use 'git send-email master..' it will automatically turn the contents of your current branch into a series of linked emails and send them to the list in the right order. If you've not used git send-email before, it is wise to test it first by sending the patches to your own email address. That lets you see that they are formatted how you expect, before sending them to this mailing list. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] qemu: json: Fix missing break in error reporting function
Otherwise we'd report a different error. Reported by John Ferlan's coverity run. --- src/qemu/qemu_monitor_json.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5f00101..7fcf245 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2128,6 +2128,7 @@ qemuMonitorJSONReportBlockExtentError(qemuMonitorBlockExtentError error) virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(blockstats stats entry was not in expected format)); +break; case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET: virReportError(VIR_ERR_INTERNAL_ERROR, -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2] Fix issues introduced by the bulk stats series.
Patch 1/2 will be pushed soon under the trivial rule. Patch 2/2 will be pushed soon under the build breaker rule. Peter Krempa (2): qemu: json: Fix missing break in error reporting function qemu: monitor: Avoid shadowing variable devname on FreeBSD. Again. src/qemu/qemu_monitor_json.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] qemu: monitor: Avoid shadowing variable devname on FreeBSD. Again.
FreeBSD's compiler complains that we shadow the symbol. Sigh. s/devname/dev_name/ --- src/qemu/qemu_monitor_json.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7fcf245..90a125f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1993,7 +1993,7 @@ int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon, virJSONValuePtr inserted; virJSONValuePtr image; qemuBlockStatsPtr bstats; -const char *devname; +const char *dev_name; if (!dev || dev-type != VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, @@ -2002,18 +2002,18 @@ int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon, goto cleanup; } -if (!(devname = virJSONValueObjectGetString(dev, device))) { +if (!(dev_name = virJSONValueObjectGetString(dev, device))) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(query-block device entry was not in expected format)); goto cleanup; } -if (STRPREFIX(devname, QEMU_DRIVE_HOST_PREFIX)) -devname += strlen(QEMU_DRIVE_HOST_PREFIX); +if (STRPREFIX(dev_name, QEMU_DRIVE_HOST_PREFIX)) +dev_name += strlen(QEMU_DRIVE_HOST_PREFIX); /* ignore missing info */ -if (!(bstats = virHashLookup(stats, devname))) +if (!(bstats = virHashLookup(stats, dev_name))) continue; /* drive may be empty */ -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] qemu: monitor: Avoid shadowing variable devname on FreeBSD. Again.
On Wed, Oct 01, 2014 at 02:43:13PM +0200, Peter Krempa wrote: FreeBSD's compiler complains that we shadow the symbol. Sigh. s/devname/dev_name/ --- src/qemu/qemu_monitor_json.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) ACK but Seems like a candidate for syntax-check rule to prevent more regressions. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv3] qemu: NUMA/network tuning shouldn't be supported in session mode
Tuning NUMA or network interface parameters require root privileges to manage cgroups, thus an attempt to set some of these parameters in session mode on a running domain should be invalid followed by an error. As an example might be memory tuning which raises an error in such case. Following behavior in session mode will be present after applying this patch: Tuning | SET | GET | --|---|| NUMA | shut off only | always | Memory| never | never | Interface | never | always | Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1126762 --- src/qemu/qemu_command.c | 13 - src/qemu/qemu_driver.c | 35 +-- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index eb72451..4c335dc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7671,7 +7671,7 @@ qemuBuildCommandLine(virConnectPtr conn, emulator = def-emulator; if (!cfg-privileged) { -/* If we have no cgroups than we can have no tunings that +/* If we have no cgroups then we can have no tunings that * require them */ if (def-mem.hard_limit || def-mem.soft_limit || @@ -7694,6 +7694,17 @@ qemuBuildCommandLine(virConnectPtr conn, _(CPU tuning is not available in session mode)); goto error; } + +virDomainNetDefPtr *nets = def-nets; +virNetDevBandwidthPtr bandwidth = NULL; +size_t nnets = def-nnets; +for (i = 0; i nnets; i++) { +if ((bandwidth = virDomainNetGetActualBandwidth(nets[i])) != NULL) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(Network bandwidth tuning is not available in session mode)); +goto error; +} +} } for (i = 0; i def-ngraphics; ++i) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6606154..c64d272 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8974,6 +8974,13 @@ qemuDomainSetNumaParameters(virDomainPtr dom, persistentDef) 0) goto cleanup; +if (!cfg-privileged +flags VIR_DOMAIN_AFFECT_LIVE) { +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s, + _(NUMA tuning is not available in session mode)); +goto cleanup; +} + if (flags VIR_DOMAIN_AFFECT_LIVE) { if (!virCgroupHasController(priv-cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { virReportError(VIR_ERR_OPERATION_INVALID, %s, @@ -9058,6 +9065,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom, size_t i; virDomainObjPtr vm = NULL; virDomainDefPtr persistentDef = NULL; +virQEMUDriverConfigPtr cfg = NULL; char *nodeset = NULL; int ret = -1; virCapsPtr caps = NULL; @@ -9076,6 +9084,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom, return -1; priv = vm-privateData; +cfg = virQEMUDriverGetConfig(driver); if (virDomainGetNumaParametersEnsureACL(dom-conn, vm-def) 0) goto cleanup; @@ -9093,14 +9102,6 @@ qemuDomainGetNumaParameters(virDomainPtr dom, goto cleanup; } -if (flags VIR_DOMAIN_AFFECT_LIVE) { -if (!virCgroupHasController(priv-cgroup, VIR_CGROUP_CONTROLLER_MEMORY)) { -virReportError(VIR_ERR_OPERATION_INVALID, - %s, _(cgroup memory controller is not mounted)); -goto cleanup; -} -} - for (i = 0; i QEMU_NB_NUMA_PARAM i *nparams; i++) { virMemoryParameterPtr param = params[i]; @@ -9123,9 +9124,16 @@ qemuDomainGetNumaParameters(virDomainPtr dom, if (!nodeset) goto cleanup; } else { -if (virCgroupGetCpusetMems(priv-cgroup, nodeset) 0) -goto cleanup; +if (!virCgroupHasController(priv-cgroup, +VIR_CGROUP_CONTROLLER_MEMORY) || +virCgroupGetCpusetMems(priv-cgroup, nodeset) 0) { +nodeset = virDomainNumatuneFormatNodeset(vm-def-numatune, + NULL, -1); +if (!nodeset) +goto cleanup; +} } + if (virTypedParameterAssign(param, VIR_DOMAIN_NUMA_NODESET, VIR_TYPED_PARAM_STRING, nodeset) 0) goto cleanup; @@ -9150,6 +9158,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom, if (vm) virObjectUnlock(vm); virObjectUnref(caps); +virObjectUnref(cfg); return ret; } @@ -10120,6 +10129,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (virDomainSetInterfaceParametersEnsureACL(dom-conn, vm-def, flags) 0) goto
[libvirt] [PATCH] Include .libs in libdir in source tree pkg-config files
This lets me build against an uninstalled source tree without libtool. --- src/libvirt-lxc.pc.in | 2 +- src/libvirt-qemu.pc.in | 2 +- src/libvirt.pc.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libvirt-lxc.pc.in b/src/libvirt-lxc.pc.in index 20f173b..88e431b 100644 --- a/src/libvirt-lxc.pc.in +++ b/src/libvirt-lxc.pc.in @@ -4,7 +4,7 @@ prefix=@abs_top_builddir@ exec_prefix=@abs_top_builddir@ -libdir=@abs_top_builddir@/src +libdir=@abs_top_builddir@/src/.libs includedir=@abs_top_builddir@/include datarootdir=@abs_top_builddir@ diff --git a/src/libvirt-qemu.pc.in b/src/libvirt-qemu.pc.in index 1e2cadf..ed1f68a 100644 --- a/src/libvirt-qemu.pc.in +++ b/src/libvirt-qemu.pc.in @@ -4,7 +4,7 @@ prefix=@abs_top_builddir@ exec_prefix=@abs_top_builddir@ -libdir=@abs_top_builddir@/src +libdir=@abs_top_builddir@/src/.libs includedir=@abs_top_builddir@/include datarootdir=@abs_top_builddir@ diff --git a/src/libvirt.pc.in b/src/libvirt.pc.in index fa798cf..c2bdbb2 100644 --- a/src/libvirt.pc.in +++ b/src/libvirt.pc.in @@ -4,7 +4,7 @@ prefix=@abs_top_builddir@ exec_prefix=@abs_top_builddir@ -libdir=@abs_top_builddir@/src +libdir=@abs_top_builddir@/src/.libs includedir=@abs_top_builddir@/include datarootdir=@abs_top_builddir@ -- 2.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2] storage: Fix logical pool fmt type
Thank you. On 09/29/2014 01:53 PM, John Ferlan wrote: On 09/26/2014 06:56 AM, John Ferlan wrote: On 09/25/2014 10:26 AM, Erik Skultety wrote: According to our documentation logical pool supports formats 'auto' and 'lvm2'. However, in storage_conf.c we prevously defined storage pool s/prevously/previously formats: unknown, lvm2. Due to backward compatibility reasons documentation now refers to pool format type 'unknown' instead of 'auto'. could be modified depending on how you handle my comment below. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1123767 --- docs/schemas/storagepool.rng | 2 +- docs/storage.html.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 2d165a3..7234ef3 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -465,7 +465,7 @@ element name='format' attribute name='type' choice -valueauto/value +valueunknown/value Perhaps in order to avoid someone in the future getting us back into this mess - can we add a comment after the /value: !-- back-compat requires keeping 'unknown' not 'auto' -- There's a few other examples of back-compat comments... valuelvm2/value /choice /attribute diff --git a/docs/storage.html.in b/docs/storage.html.in index 3d2ffca..49fd862 100644 --- a/docs/storage.html.in +++ b/docs/storage.html.in @@ -331,7 +331,7 @@ The logical volume pool supports the following formats: /p ul - licodeauto/code - automatically determine format/li + licodeunknown/code - automatically determine format/li I think if you follow what 'virStoragePoolFormatDisk' does (or Disk volume pools on the webpage) and just don't list 'unknown' that'd probably be better. Unless someone else thinks it should be listed. Yes, a list of 1 element looks strange. If that's not desired some text indicating that logical pools only support the 'lvm2' type and if format is not provided, then libvirt will determine the type. li codelvm2/code /li ACK Let's see if anyone else has feelings one way or another - I can modify based on my review and push so you don't have to send a v3. Just want to give others a chance first... John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list I pushed the following for you John diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 2d165a3..0f05c5c 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -465,7 +465,7 @@ element name='format' attribute name='type' choice -valueauto/value +valueunknown/value !-- back-compat requires keeping 'unknown' not 'auto' -- valuelvm2/value /choice /attribute diff --git a/docs/storage.html.in b/docs/storage.html.in index 3d2ffca..9933548 100644 --- a/docs/storage.html.in +++ b/docs/storage.html.in @@ -328,14 +328,10 @@ h3Valid pool format types/h3 p - The logical volume pool supports the following formats: + The logical volume pool supports only the codelvm2/code format, + although not supplying a format value will result in automatic + selection of thecodelvm2/code format. /p -ul - licodeauto/code - automatically determine format/li - li -codelvm2/code - /li -/ul h3Valid volume format types/h3 p -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH/RFC] Add missing delta from Ubuntu to apparmor profiles
Quoting Stefan Bader (stefan.ba...@canonical.com): On 01.10.2014 11:04, Daniel P. Berrange wrote: On Wed, Oct 01, 2014 at 10:30:58AM +0200, Stefan Bader wrote: This had been on the Debian package list before but its time to take this onwards. So the goal would be to have one set to rule them all (when using apparmor) and drop the seperate set of definitions which exist at least in the Ubuntu packaging. Right now the patch would be at a state which adds all missing files and rules to the current examples in libvirt and installs them when using --with-apparmor-profiles. One problem seems to be that some of the definitions might cause parse failures on certain versions of apparmor. I checked this morning and this looks a bit hairy. So some apparmor 2.8 versions potentially have issues, but not all apparmor 2.8 are the same (gah). What versions of apparmour are present in the currently supported versions of Debian Ubuntu ? The way release are handled in Ubuntu (once released there is usually no backporting) we would have to worry less about supported releases. For the Debian side I would think this is similar (correct me if I am wrong, please). So it looks to me that right now this would be down to Debian having 2.8.0 in unstable/testing and Ubuntu having 2.8.96~2652 in Utopic (with the same version in Debian experimental). Right now I would expect it to boil down to those two. But I suppose the parser can change again and so there might be a similar situation in the future. There's also opensuse plus presumably people running hand-built systems. -Stefan I could imagine (but John, we really could use some guidance here ;)) that at least some changes could be related to version 2.8.95~2430: + debian/patches/mediate-signals.patch, debian/patches/change-signal-syntax.patch: Parse signal rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. + debian/patches/change-ptrace-syntax.patch, debian/patches/mediate-ptrace.patch: Parse ptrace rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. But, regardless of the when, the apparmor rules maybe need a way to handle versioned features of the parser. One proposal was to comment out problematic rules and allow the packager to re-enable things. Maybe going one step further and have some pre-processing that handles version based sections (like #if (APPARMOR_VERSION = xxx)). I think it would be pretty reasonable to rename the files in have '.in' suffixes, and then have a build script that expands 'if APPARMOR_VERSION' conditionals to generate the final file. Yeah, I think we need to do that. We just need to check the versions for (1) dbus, (2) signal+ptrace, and (3) unix. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] maint: Prohibit devname by a syntax check rules
and tweak the code to avoid using it. --- cfg.mk | 12 include/libvirt/libvirt.h.in | 2 +- src/conf/interface_conf.c | 10 +- src/conf/interface_conf.h | 2 +- src/interface/interface_backend_udev.c | 2 +- src/qemu/qemu_monitor.c| 4 ++-- src/qemu/qemu_monitor.h| 6 +++--- src/util/virfile.c | 6 +++--- tools/virsh-domain.c | 4 ++-- tools/virt-host-validate-common.h | 2 +- 10 files changed, 31 insertions(+), 19 deletions(-) diff --git a/cfg.mk b/cfg.mk index ed7123b..8e99d04 100644 --- a/cfg.mk +++ b/cfg.mk @@ -962,6 +962,15 @@ sc_prohibit_paren_brace: halt='Put space between closing parenthesis and opening brace' \ $(_sc_search_regexp) +# Look for diagnostics that aren't marked for translation. +# This won't find any for which error's format string is on a separate line. +# The sed filters eliminate false-positives like these: +sc_prohibit_devname: + @prohibit='\bdevname\b' \ + exclude='sc_prohibit_devname' \ + halt='avoid using 'devname' as FreeBSD exports the symbol' \ + $(_sc_search_regexp) + # We don't use this feature of maint.mk. prev_version_file = /dev/null @@ -1146,3 +1155,6 @@ exclude_file_name_regexp--sc_prohibit_empty_first_line = \ exclude_file_name_regexp--sc_prohibit_useless_translation = \ ^tests/virpolkittest.c + +exclude_file_name_regexp--sc_prohibit_devname = \ + ^(tools/virsh.pod|cfg.mk|docs/.*)$$ diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5217ab3..c9018c0 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -5601,7 +5601,7 @@ typedef enum { } virDomainConsoleFlags; int virDomainOpenConsole(virDomainPtr dom, - const char *devname, + const char *dev_name, virStreamPtr st, unsigned int flags); diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index effe5ad..10c7c09 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -101,7 +101,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def) break; case VIR_INTERFACE_TYPE_VLAN: VIR_FREE(def-data.vlan.tag); -VIR_FREE(def-data.vlan.devname); +VIR_FREE(def-data.vlan.dev_name); break; } @@ -671,9 +671,9 @@ virInterfaceDefParseVlan(virInterfaceDefPtr def, return -1; } -def-data.vlan.devname = +def-data.vlan.dev_name = virXPathString(string(./interface/@name), ctxt); -if (def-data.vlan.devname == NULL) { +if (def-data.vlan.dev_name == NULL) { virReportError(VIR_ERR_XML_ERROR, %s, _(vlan interface misses name attribute)); return -1; @@ -955,11 +955,11 @@ virInterfaceVlanDefFormat(virBufferPtr buf, const virInterfaceDef *def) } virBufferAsprintf(buf, vlan tag='%s', def-data.vlan.tag); -if (def-data.vlan.devname != NULL) { +if (def-data.vlan.dev_name != NULL) { virBufferAddLit(buf, \n); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, interface name='%s'/\n, - def-data.vlan.devname); + def-data.vlan.dev_name); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, /vlan\n); } else { diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h index 94c18ef..ac212fb 100644 --- a/src/conf/interface_conf.h +++ b/src/conf/interface_conf.h @@ -116,7 +116,7 @@ typedef struct _virInterfaceVlanDef virInterfaceVlanDef; typedef virInterfaceVlanDef *virInterfaceVlanDefPtr; struct _virInterfaceVlanDef { char *tag; /* TAG for vlan */ -char *devname; /* device name for vlan */ +char *dev_name; /* device name for vlan */ }; typedef struct _virInterfaceIpDef virInterfaceIpDef; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index ecb1b2a..1dbbfe7 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1015,7 +1015,7 @@ udevGetIfaceDefVlan(struct udev *udev ATTRIBUTE_UNUSED, if (VIR_STRNDUP(ifacedef-data.vlan.tag, vid_pos, vid_len) 0) goto cleanup; -if (VIR_STRNDUP(ifacedef-data.vlan.devname, dev_pos, dev_len) 0) { +if (VIR_STRNDUP(ifacedef-data.vlan.dev_name, dev_pos, dev_len) 0) { VIR_FREE(ifacedef-data.vlan.tag); goto cleanup; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c9929c3..00c62f7 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1821,7 +1821,7 @@ int qemuMonitorGetBlockExtent(qemuMonitorPtr mon, unsigned long long *extent) { int ret; -VIR_DEBUG(mon=%p, dev_name=%p, mon,
Re: [libvirt] [PATCH] maint: Prohibit devname by a syntax check rules
On 10/01/2014 08:14 AM, Peter Krempa wrote: and tweak the code to avoid using it. --- cfg.mk | 12 include/libvirt/libvirt.h.in | 2 +- src/conf/interface_conf.c | 10 +- src/conf/interface_conf.h | 2 +- src/interface/interface_backend_udev.c | 2 +- src/qemu/qemu_monitor.c| 4 ++-- src/qemu/qemu_monitor.h| 6 +++--- src/util/virfile.c | 6 +++--- tools/virsh-domain.c | 4 ++-- tools/virt-host-validate-common.h | 2 +- 10 files changed, 31 insertions(+), 19 deletions(-) diff --git a/cfg.mk b/cfg.mk index ed7123b..8e99d04 100644 --- a/cfg.mk +++ b/cfg.mk @@ -962,6 +962,15 @@ sc_prohibit_paren_brace: halt='Put space between closing parenthesis and opening brace' \ $(_sc_search_regexp) +# Look for diagnostics that aren't marked for translation. +# This won't find any for which error's format string is on a separate line. +# The sed filters eliminate false-positives like these: Comment is wrong. +sc_prohibit_devname: + @prohibit='\bdevname\b' \ + exclude='sc_prohibit_devname' \ + halt='avoid using 'devname' as FreeBSD exports the symbol' \ + $(_sc_search_regexp) Alignment of \ looks odd, but the rule itself looks okay. ACK with that cleaned up. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] maint: Prohibit devname by a syntax check rules
On 10/01/14 16:23, Eric Blake wrote: On 10/01/2014 08:14 AM, Peter Krempa wrote: and tweak the code to avoid using it. --- cfg.mk | 12 include/libvirt/libvirt.h.in | 2 +- src/conf/interface_conf.c | 10 +- src/conf/interface_conf.h | 2 +- src/interface/interface_backend_udev.c | 2 +- src/qemu/qemu_monitor.c| 4 ++-- src/qemu/qemu_monitor.h| 6 +++--- src/util/virfile.c | 6 +++--- tools/virsh-domain.c | 4 ++-- tools/virt-host-validate-common.h | 2 +- 10 files changed, 31 insertions(+), 19 deletions(-) diff --git a/cfg.mk b/cfg.mk index ed7123b..8e99d04 100644 --- a/cfg.mk +++ b/cfg.mk @@ -962,6 +962,15 @@ sc_prohibit_paren_brace: halt='Put space between closing parenthesis and opening brace' \ $(_sc_search_regexp) +# Look for diagnostics that aren't marked for translation. +# This won't find any for which error's format string is on a separate line. +# The sed filters eliminate false-positives like these: Comment is wrong. That happens when you set up to fix the comment later ... Sigh. +sc_prohibit_devname: +@prohibit='\bdevname\b' \ +exclude='sc_prohibit_devname' \ +halt='avoid using 'devname' as FreeBSD exports the symbol' \ + $(_sc_search_regexp) Alignment of \ looks odd, but the rule itself looks okay. ACK with that cleaned up. Thanks. Pushed. Peter signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH/RFC] Add missing delta from Ubuntu to apparmor profiles
On 10/01/2014 04:04 AM, Daniel P. Berrange wrote: On Wed, Oct 01, 2014 at 10:30:58AM +0200, Stefan Bader wrote: This had been on the Debian package list before but its time to take this onwards. So the goal would be to have one set to rule them all (when using apparmor) and drop the seperate set of definitions which exist at least in the Ubuntu packaging. Right now the patch would be at a state which adds all missing files and rules to the current examples in libvirt and installs them when using --with-apparmor-profiles. One problem seems to be that some of the definitions might cause parse failures on certain versions of apparmor. I checked this morning and this looks a bit hairy. So some apparmor 2.8 versions potentially have issues, but not all apparmor 2.8 are the same (gah). What versions of apparmour are present in the currently supported versions of Debian Ubuntu ? I could imagine (but John, we really could use some guidance here ;)) that at least some changes could be related to version 2.8.95~2430: + debian/patches/mediate-signals.patch, debian/patches/change-signal-syntax.patch: Parse signal rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. + debian/patches/change-ptrace-syntax.patch, debian/patches/mediate-ptrace.patch: Parse ptrace rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. But, regardless of the when, the apparmor rules maybe need a way to handle versioned features of the parser. One proposal was to comment out problematic rules and allow the packager to re-enable things. Maybe going one step further and have some pre-processing that handles version based sections (like #if (APPARMOR_VERSION = xxx)). I think it would be pretty reasonable to rename the files in have '.in' suffixes, and then have a build script that expands 'if APPARMOR_VERSION' conditionals to generate the final file. These are the rules that are problematic: dbus, ptrace, signal and unix. All of these are not part of upstream apparmor 2.8 proper, but are part of the upcoming 2.9 release. Ubuntu is using prereleases of upstream apparmor 2.9 where 2.8.95 has dbus, ptrace and signal rules and 2.8.96 adds unix rules (unfortunately, Ubuntu introduced dbus rules as a patch on top of apparmor 2.8.0 in 2.8.0-0ubuntu25 for Ubuntu 13.10-- however, Ubuntu 13.10 is EOL now so I think it is fine to not consider this). If we were to decide to adjust the rules based on apparmor version, then please add dbus, ptrace, signal and unix rules based on APPARMOR_VERSION = 2.9. Distributions like Ubuntu using a prerelease version of AppArmor can then choose to adjust the APPARMOR_VERSION check. IIUC Debian and SUSE will continue to use use official 2.8 until 2.9 becomes official[1]. Thanks [1] AppArmor upstream is working on finalizing the 2.9 release now -- Jamie Strandboge http://www.ubuntu.com/ signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH/RFC] Add missing delta from Ubuntu to apparmor profiles
On Wed, Oct 01, 2014 at 09:46:08AM -0500, Jamie Strandboge wrote: On 10/01/2014 04:04 AM, Daniel P. Berrange wrote: On Wed, Oct 01, 2014 at 10:30:58AM +0200, Stefan Bader wrote: This had been on the Debian package list before but its time to take this onwards. So the goal would be to have one set to rule them all (when using apparmor) and drop the seperate set of definitions which exist at least in the Ubuntu packaging. Right now the patch would be at a state which adds all missing files and rules to the current examples in libvirt and installs them when using --with-apparmor-profiles. One problem seems to be that some of the definitions might cause parse failures on certain versions of apparmor. I checked this morning and this looks a bit hairy. So some apparmor 2.8 versions potentially have issues, but not all apparmor 2.8 are the same (gah). What versions of apparmour are present in the currently supported versions of Debian Ubuntu ? I could imagine (but John, we really could use some guidance here ;)) that at least some changes could be related to version 2.8.95~2430: + debian/patches/mediate-signals.patch, debian/patches/change-signal-syntax.patch: Parse signal rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. + debian/patches/change-ptrace-syntax.patch, debian/patches/mediate-ptrace.patch: Parse ptrace rules with apparmor_parser. See the apparmor.d(5) man page for syntax details. But, regardless of the when, the apparmor rules maybe need a way to handle versioned features of the parser. One proposal was to comment out problematic rules and allow the packager to re-enable things. Maybe going one step further and have some pre-processing that handles version based sections (like #if (APPARMOR_VERSION = xxx)). I think it would be pretty reasonable to rename the files in have '.in' suffixes, and then have a build script that expands 'if APPARMOR_VERSION' conditionals to generate the final file. These are the rules that are problematic: dbus, ptrace, signal and unix. All of these are not part of upstream apparmor 2.8 proper, but are part of the upcoming 2.9 release. Ubuntu is using prereleases of upstream apparmor 2.9 where 2.8.95 has dbus, ptrace and signal rules and 2.8.96 adds unix rules (unfortunately, Ubuntu introduced dbus rules as a patch on top of apparmor 2.8.0 in 2.8.0-0ubuntu25 for Ubuntu 13.10-- however, Ubuntu 13.10 is EOL now so I think it is fine to not consider this). If we were to decide to adjust the rules based on apparmor version, then please add dbus, ptrace, signal and unix rules based on APPARMOR_VERSION = 2.9. Distributions like Ubuntu using a prerelease version of AppArmor can then choose to adjust the APPARMOR_VERSION check. IIUC Debian and SUSE will continue to use use official 2.8 until 2.9 becomes official[1]. Agreed, the libvirt upstream distributed file should do version checks based on official apparmor releases, and distros can tweak versions if they have backported features. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] qemu: Fix updating bandwidth limits in live XML
On 10/01/2014 01:55 AM, John Ferlan wrote: On 09/22/2014 06:41 AM, Erik Skultety wrote: When trying to update bandwidth limits on a running domain, limits get updated in our internal structures, however XML parser reads bandwidth limits from network 'actual' definition. Commiting this patch s/Commiting/Committing it is now available to update bandwidth 'actual' definition as well, thus updating domain runtime XML --- src/qemu/qemu_driver.c | 12 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 702d3cc..ede8880 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10028,7 +10028,19 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } else { net-bandwidth = NULL; } + +if (net-type == VIR_DOMAIN_NET_TYPE_NETWORK) { +virNetDevBandwidthFree(net-data.network.actual-bandwidth); This will set net-data.network.actual-bandwidth to NULL It's also remove it when net-bandwidth == NULL thus causing actual to be lost, which it doesn't seem is desired, but perhaps it is. Gues +if (!net-bandwidth || + virNetDevBandwidthCopy(net-data.network.actual-bandwidth, + net-bandwidth) 0) +net-data.network.actual-bandwidth = NULL; Making this irrelevant, but I wonder if the 0 here meant to do something else perhaps? +} The above hunk needs some space formatting. Also since the virNetDevBandwidthCopy() has a if (!src) check, (!net-bandwidth) || is unnecessary. if (net-type == VIR_DOMAIN_NET_TYPE_NETWORK) { virNetDevBandwidthFree(net-data.network.actual-bandwidth); if (virNetDevBandwidthCopy(net-data.network.actual-bandwidth, net-bandwidth) 0) goto cleanup } Looks better, thanks Jon, but you'd still loose 'actual' in the hunk above, maybe add a check like if (net-type == VIR_DOMAIN_NET_TYPE_NETWORK net-bandwidth) if you want to preserve 'actual' when net-bandwidth is NULL?? Whether this is what is expected is perhaps something Laine can answer... John + +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm) 0) +goto cleanup; } + if (flags VIR_DOMAIN_AFFECT_CONFIG) { if (!persistentNet-bandwidth) { persistentNet-bandwidth = bandwidth; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Erik -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] qemu: Fix updating bandwidth limits in live XML
On 10/01/2014 11:17 AM, Erik Skultety wrote: On 10/01/2014 01:55 AM, John Ferlan wrote: On 09/22/2014 06:41 AM, Erik Skultety wrote: When trying to update bandwidth limits on a running domain, limits get updated in our internal structures, however XML parser reads bandwidth limits from network 'actual' definition. Commiting this patch s/Commiting/Committing it is now available to update bandwidth 'actual' definition as well, thus updating domain runtime XML --- src/qemu/qemu_driver.c | 12 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 702d3cc..ede8880 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10028,7 +10028,19 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } else { net-bandwidth = NULL; } + +if (net-type == VIR_DOMAIN_NET_TYPE_NETWORK) { + virNetDevBandwidthFree(net-data.network.actual-bandwidth); This will set net-data.network.actual-bandwidth to NULL It's also remove it when net-bandwidth == NULL thus causing actual to be lost, which it doesn't seem is desired, but perhaps it is. Gues +if (!net-bandwidth || + virNetDevBandwidthCopy(net-data.network.actual-bandwidth, + net-bandwidth) 0) +net-data.network.actual-bandwidth = NULL; Making this irrelevant, but I wonder if the 0 here meant to do something else perhaps? +} The above hunk needs some space formatting. Also since the virNetDevBandwidthCopy() has a if (!src) check, (!net-bandwidth) || is unnecessary. if (net-type == VIR_DOMAIN_NET_TYPE_NETWORK) { virNetDevBandwidthFree(net-data.network.actual-bandwidth); if (virNetDevBandwidthCopy(net-data.network.actual-bandwidth, net-bandwidth) 0) goto cleanup } Looks better, thanks Jon, but you'd still loose 'actual' in the hunk above, maybe add a check like if (net-type == VIR_DOMAIN_NET_TYPE_NETWORK net-bandwidth) if you want to preserve 'actual' when net-bandwidth is NULL?? Right - I thought about that too, but then I thought the purpose of making the change to actual was to copy what happened to net-bandwidth. Looking at the hunk just above: virNetDevBandwidthFree(net-bandwidth); if (newBandwidth-in || newBandwidth-out) { net-bandwidth = newBandwidth; newBandwidth = NULL; } else { net-bandwidth = NULL; } That says to me in this live path, we're freeing net-bandwidth and only replacing it with 'newBandwidth' if in/out were found. Thus, it seems reasonable that we'd want to remove the bandwidth from actual in this case as well which we wouldn't do if the the net-bandwidth was added to the condition. Also, upon further reflection the net-data.network.actual-bandwidth = NULL; after the virNetDevBandwidthFree() will be necessary since we're passing by value and not reference... John Whether this is what is expected is perhaps something Laine can answer... John + +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm) 0) +goto cleanup; } + if (flags VIR_DOMAIN_AFFECT_CONFIG) { if (!persistentNet-bandwidth) { persistentNet-bandwidth = bandwidth; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Erik -- 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
Re: [libvirt] [PATCH v4 4/6] qemu: Add bps_max and friends QMP suport
On 30.09.2014 16:09, Matthias Gatto wrote: Detect if the the qemu binary currently in use suport the bps_max option, If yes add it to the command, if not, just ignore the options. Signed-off-by: Matthias Gatto matthias.ga...@outscale.com --- src/qemu/qemu_monitor_json.c | 59 +++- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a8759dd..bef7b5b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4029,6 +4029,12 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, } +#define GET_THROTTLE_STATS_OPTIONAL(FIELD, STORE) \ +if (virJSONValueObjectGetNumberUlong(inserted,\ + FIELD, \ + reply-STORE) 0) {\ +reply-STORE = 0; \ +} Well, this is going to be called if-and-only-if qemu supports the new flags. Shouldn't we error out here rather than silently hiding a bug? #define GET_THROTTLE_STATS(FIELD, STORE) \ if (virJSONValueObjectGetNumberUlong(inserted, \ FIELD, \ @@ -4050,7 +4056,6 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, size_t i; bool found = false; -(void)supportMaxOptions; io_throttle = virJSONValueObjectGet(result, return); if (!io_throttle || io_throttle-type != VIR_JSON_TYPE_ARRAY) { @@ -4096,6 +4101,16 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, GET_THROTTLE_STATS(iops, total_iops_sec); GET_THROTTLE_STATS(iops_rd, read_iops_sec); GET_THROTTLE_STATS(iops_wr, write_iops_sec); +if (supportMaxOptions) +{ +GET_THROTTLE_STATS_OPTIONAL(bps_max, total_bytes_sec_max); +GET_THROTTLE_STATS_OPTIONAL(bps_rd_max, read_bytes_sec_max); +GET_THROTTLE_STATS_OPTIONAL(bps_wr_max, write_bytes_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_max, total_iops_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_rd_max, read_iops_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_wr_max, write_iops_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_size, size_iops_sec); This should be GET_THROTTLE_STAT() then. +} break; } @@ -4112,6 +4127,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, return ret; } #undef GET_THROTTLE_STATS +#undef GET_THROTTLE_STATS_OPTIONAL int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, const char *device, @@ -4122,16 +4138,37 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, virJSONValuePtr cmd = NULL; virJSONValuePtr result = NULL; -(void)supportMaxOptions; -cmd = qemuMonitorJSONMakeCommand(block_set_io_throttle, - s:device, device, - U:bps, info-total_bytes_sec, - U:bps_rd, info-read_bytes_sec, - U:bps_wr, info-write_bytes_sec, - U:iops, info-total_iops_sec, - U:iops_rd, info-read_iops_sec, - U:iops_wr, info-write_iops_sec, - NULL); +if (supportMaxOptions) +{ +cmd = qemuMonitorJSONMakeCommand(block_set_io_throttle, + s:device, device, + U:bps, info-total_bytes_sec, + U:bps_rd, info-read_bytes_sec, + U:bps_wr, info-write_bytes_sec, + U:iops, info-total_iops_sec, + U:iops_rd, info-read_iops_sec, + U:iops_wr, info-write_iops_sec, + U:bps_max, info-total_bytes_sec_max, + U:bps_rd_max, info-read_bytes_sec_max, + U:bps_wr_max, info-write_bytes_sec_max, + U:iops_max, info-total_iops_sec_max, + U:iops_rd_max, info-read_iops_sec_max, + U:iops_wr_max, info-write_iops_sec_max, + U:iops_size, info-size_iops_sec, + NULL); +} +else +{ +cmd = qemuMonitorJSONMakeCommand(block_set_io_throttle, + s:device,
Re: [libvirt] [PATCH v4 1/6] qemu: Add defines for the news throttle options and modify the structure _virDomainBlockIoTuneInfo.
On 30.09.2014 16:08, Matthias Gatto wrote: Add defines for the news options total_bytes_sec_max, write_bytes_sec_max, read_bytes_sec_max total_iops_sec_max, write_iops_sec_max, read_iops_sec_max, size_iops_sec. Modify the structure _virDomainBlockIoTuneInfo to support these options. Change the initialization of the variable expectedInfo in qemumonitorjsontest.c to avoid compiling problem. Allow libvirt to save the configuration. Signed-off-by: Matthias Gatto matthias.ga...@outscale.com --- include/libvirt/libvirt.h.in | 54 + src/conf/domain_conf.c | 110 ++- src/conf/domain_conf.h | 7 +++ tests/qemumonitorjsontest.c | 2 +- 4 files changed, 171 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5217ab3..4eab987 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -2800,6 +2800,60 @@ int virDomainBlockCommit(virDomainPtr dom, const char *disk, const char *base, */ #define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC write_iops_sec +/** + * VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX: + * + * Macro for the BlockIoTune tunable weight: it represents the maximum total + * bytes per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX total_bytes_sec_max + +/** + * VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX: + * + * Macro for the BlockIoTune tunable weight: it represents the maximum read + * bytes per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX read_bytes_sec_max + +/** + * VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX: + * + * Macro for the BlockIoTune tunable weight: it represents the maximum write + * bytes per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX write_bytes_sec_max + +/** + * VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX: + * + * Macro for the BlockIoTune tunable weight: it represents the maximum + * I/O operations per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX total_iops_sec_max + +/** + * VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX: + * + * Macro for the BlockIoTune tunable weight: it represents the maximum read + * I/O operations per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX read_iops_sec_max + +/** + * VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX: + * Macro for the BlockIoTune tunable weight: it represents the maximum write + * I/O operations per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX write_iops_sec_max + +/** + * VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC: + * Macro for the BlockIoTune tunable weight: it represents the size + * I/O operations per second permitted through a block device, as a ullong. + */ +#define VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC size_iops_sec + The chunk above is not tied to the chunks below. Moreover, the following code extends domain XML space which should go hand in hand with documentation and RNG schema. So the first chunk can be separated into standalone patch and the rest should be extended. int virDomainSetBlockIoTune(virDomainPtr dom, const char *disk, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b114737..e629e22 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5787,6 +5787,49 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, def-blkdeviotune.write_iops_sec = 0; } +if (virXPathULongLong(string(./iotune/total_bytes_sec_max), + ctxt, + def-blkdeviotune.total_bytes_sec_max) 0) { +def-blkdeviotune.total_bytes_sec_max = 0; +} + +if (virXPathULongLong(string(./iotune/read_bytes_sec_max), + ctxt, + def-blkdeviotune.read_bytes_sec_max) 0) { +def-blkdeviotune.read_bytes_sec_max = 0; +} + +if (virXPathULongLong(string(./iotune/write_bytes_sec_max), + ctxt, + def-blkdeviotune.write_bytes_sec_max) 0) { +def-blkdeviotune.write_bytes_sec_max = 0; +} + +if (virXPathULongLong(string(./iotune/total_iops_sec_max), + ctxt, + def-blkdeviotune.total_iops_sec_max) 0) { +def-blkdeviotune.total_iops_sec_max = 0; +} + +if (virXPathULongLong(string(./iotune/read_iops_sec_max), +
Re: [libvirt] [PATCH v4 3/6] qemu: Add bps_max and friends qemu driver
On 30.09.2014 16:09, Matthias Gatto wrote: Add support for bps_max and friends in the driver part. In the part checking if a qemu is running, check if the running binary support bps_max, if not print an error message, if yes add it to info variable Signed-off-by: Matthias Gatto matthias.ga...@outscale.com --- include/libvirt/libvirt.h.in | 56 + src/qemu/qemu_driver.c | 181 +-- src/qemu/qemu_monitor.c | 10 ++- src/qemu/qemu_monitor.h | 6 +- src/qemu/qemu_monitor_json.c | 13 +++- src/qemu/qemu_monitor_json.h | 6 +- tests/qemumonitorjsontest.c | 4 +- 7 files changed, 256 insertions(+), 20 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 4eab987..acaca54 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -5373,6 +5373,62 @@ typedef void (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn, #define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC blkdeviotune.write_iops_sec /** + * VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX: + * + * Marco represents the total throughput limit in maximum bytes per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX blkdeviotune.total_bytes_sec_max + +/** + * VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX: + * + * Marco represents the read throughput limit in maximum bytes per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX blkdeviotune.read_bytes_sec_max + +/** + * VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX: + * + * Macro represents the write throughput limit in maximum bytes per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX blkdeviotune.write_bytes_sec_max + +/** + * VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX: + * + * Macro represents the total maximum I/O operations per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX blkdeviotune.total_iops_sec_max + +/** + * VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX: + * + * Macro represents the read maximum I/O operations per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX blkdeviotune.read_iops_sec_max + +/** + * VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX: + * + * Macro represents the write maximum I/O operations per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX blkdeviotune.write_iops_sec_max + +/** + * VIR_DOMAIN_TUNABLE_BLKDEV_SIZE_IOPS_SEC: + * + * Macro represents the size maximum I/O operations per second, + * as VIR_TYPED_PARAM_ULLONG. + */ +#define VIR_DOMAIN_TUNABLE_BLKDEV_SIZE_IOPS_SEC blkdeviotune.size_iops_sec + +/** * virConnectDomainEventTunableCallback: * @conn: connection object * @dom: domain on which the event occurred diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6606154..94cfa58 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -105,6 +105,7 @@ VIR_LOG_INIT(qemu.qemu_driver); #define QEMU_NB_MEM_PARAM 3 #define QEMU_NB_BLOCK_IO_TUNE_PARAM 6 +#define QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX 13 Okay, so this makes a little bit more sense now. If we are talking to newer qemu so that _max attributes are supported, we ought to return 13, and return 6 otherwise. #define QEMU_NB_NUMA_PARAM 2 @@ -16273,6 +16274,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, int conf_idx = -1; bool set_bytes = false; bool set_iops = false; +bool set_bytes_max = false; +bool set_iops_max = false; +bool set_size_iops = false; virQEMUDriverConfigPtr cfg = NULL; virCapsPtr caps = NULL; virObjectEventPtr event = NULL; @@ -16295,6 +16299,20 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, VIR_TYPED_PARAM_ULLONG, VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC, VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC, +
Re: [libvirt] [PATCH v4 2/6] qemu: Add the capability to detect if the qemu binary have the capability to use bps_max and friends
On 30.09.2014 16:09, Matthias Gatto wrote: Add a value in the enum virQEMUCapsFlags for the qemu capability. Set it with virQEMUCapsSet if the binary suport bps_max and they friends. Signed-off-by: Matthias Gatto matthias.ga...@outscale.com --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 + 3 files changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a409aaf..b73d520 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -270,6 +270,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, splash-timeout, /* 175 */ iothread, migrate-rdma, + drive-iotune-max, ); @@ -2448,6 +2449,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = { { spice, disable-agent-file-xfer, QEMU_CAPS_SPICE_FILE_XFER_DISABLE }, { msg, timestamp, QEMU_CAPS_MSG_TIMESTAMP }, { numa, NULL, QEMU_CAPS_NUMA }, +{ drive, throttling.bps-total-max, QEMU_CAPS_DRIVE_IOTUNE_MAX}, }; static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index a0bb5d3..9778be5 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -217,6 +217,7 @@ typedef enum { QEMU_CAPS_SPLASH_TIMEOUT = 175, /* -boot splash-time */ QEMU_CAPS_OBJECT_IOTHREAD= 176, /* -object iothread */ QEMU_CAPS_MIGRATE_RDMA = 177, /* have rdma migration */ +QEMU_CAPS_DRIVE_IOTUNE_MAX = 178, /* -drive bps_max= and friends */ QEMU_CAPS_LAST, /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps index 71d2459..fadfbb0 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps @@ -159,4 +159,5 @@ flag name='splash-timeout'/ flag name='iothread'/ flag name='migrate-rdma'/ +flag name='drive-iotune-max'/ /qemuCaps ACK Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] increase number of libvirt threads by starting tansient guest doamin - is it a bug?
On 01.10.2014 10:31, web2 wrote: Hello, sorry for my later answer. so, after i started libvirtd (no vm´s running) and attach gdb i get the following threads (gdb) info thread Id Target Id Frame 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i restore an persistent domain, i see the following in gdb: Detaching after fork from child process 20880. Detaching after fork from child process 20882. [New Thread 0x7f190893d700 (LWP 20883)] Detaching after fork from child process 20890. Detaching after fork from child process 20906. (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i now destroy this vm i get the following: (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP
Re: [libvirt] [PATCH v4 4/6] qemu: Add bps_max and friends QMP suport
On Wed, Oct 1, 2014 at 6:05 PM, Michal Privoznik mpriv...@redhat.com wrote: On 30.09.2014 16:09, Matthias Gatto wrote: Detect if the the qemu binary currently in use suport the bps_max option, If yes add it to the command, if not, just ignore the options. Signed-off-by: Matthias Gatto matthias.ga...@outscale.com --- src/qemu/qemu_monitor_json.c | 59 +++- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a8759dd..bef7b5b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4029,6 +4029,12 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, } +#define GET_THROTTLE_STATS_OPTIONAL(FIELD, STORE) \ +if (virJSONValueObjectGetNumberUlong(inserted, \ + FIELD, \ + reply-STORE) 0) { \ +reply-STORE = 0; \ +} Well, this is going to be called if-and-only-if qemu supports the new flags. Shouldn't we error out here rather than silently hiding a bug? #define GET_THROTTLE_STATS(FIELD, STORE) \ if (virJSONValueObjectGetNumberUlong(inserted, \ FIELD, \ @@ -4050,7 +4056,6 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, size_t i; bool found = false; -(void)supportMaxOptions; io_throttle = virJSONValueObjectGet(result, return); if (!io_throttle || io_throttle-type != VIR_JSON_TYPE_ARRAY) { @@ -4096,6 +4101,16 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, GET_THROTTLE_STATS(iops, total_iops_sec); GET_THROTTLE_STATS(iops_rd, read_iops_sec); GET_THROTTLE_STATS(iops_wr, write_iops_sec); +if (supportMaxOptions) +{ +GET_THROTTLE_STATS_OPTIONAL(bps_max, total_bytes_sec_max); +GET_THROTTLE_STATS_OPTIONAL(bps_rd_max, read_bytes_sec_max); +GET_THROTTLE_STATS_OPTIONAL(bps_wr_max, write_bytes_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_max, total_iops_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_rd_max, read_iops_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_wr_max, write_iops_sec_max); +GET_THROTTLE_STATS_OPTIONAL(iops_size, size_iops_sec); This should be GET_THROTTLE_STAT() then. +} break; } @@ -4112,6 +4127,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, return ret; } #undef GET_THROTTLE_STATS +#undef GET_THROTTLE_STATS_OPTIONAL int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, const char *device, @@ -4122,16 +4138,37 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, virJSONValuePtr cmd = NULL; virJSONValuePtr result = NULL; -(void)supportMaxOptions; -cmd = qemuMonitorJSONMakeCommand(block_set_io_throttle, - s:device, device, - U:bps, info-total_bytes_sec, - U:bps_rd, info-read_bytes_sec, - U:bps_wr, info-write_bytes_sec, - U:iops, info-total_iops_sec, - U:iops_rd, info-read_iops_sec, - U:iops_wr, info-write_iops_sec, - NULL); +if (supportMaxOptions) +{ +cmd = qemuMonitorJSONMakeCommand(block_set_io_throttle, + s:device, device, + U:bps, info-total_bytes_sec, + U:bps_rd, info-read_bytes_sec, + U:bps_wr, info-write_bytes_sec, + U:iops, info-total_iops_sec, + U:iops_rd, info-read_iops_sec, + U:iops_wr, info-write_iops_sec, + U:bps_max, info-total_bytes_sec_max, + U:bps_rd_max, info-read_bytes_sec_max, + U:bps_wr_max, info-write_bytes_sec_max, + U:iops_max, info-total_iops_sec_max, + U:iops_rd_max, info-read_iops_sec_max, + U:iops_wr_max, info-write_iops_sec_max, + U:iops_size, info-size_iops_sec, + NULL); +} +else +{ +cmd = qemuMonitorJSONMakeCommand(block_set_io_throttle, + s:device, device, + U:bps,
Re: [libvirt] increase number of libvirt threads by starting tansient guest doamin - is it a bug?
Hi ursprüngliche Nachricht- Von: Michal Privoznik mpriv...@redhat.com An: web2 usterman...@web.de , libvirt-users redhat.com , libvirt-list redhat.com Datum: Wed, 01 Oct 2014 18:12:45 +0200 - On 01.10.2014 10:31, web2 wrote: Hello, sorry for my later answer. so, after i started libvirtd (no vm´s running) and attach gdb i get the following threads (gdb) info thread Id Target Id Frame 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i restore an persistent domain, i see the following in gdb: Detaching after fork from child process 20880. Detaching after fork from child process 20882. [New Thread 0x7f190893d700 (LWP 20883)] Detaching after fork from child process 20890. Detaching after fork from child process 20906. (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i now destroy this vm i get the following: (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at
Re: [libvirt] [PATCH 0/6] handle NIC_RX_FILTER_CHANGED events from qemu
On 09/30/2014 03:47 PM, Laine Stump wrote: On 09/30/2014 02:28 PM, Tony Krowiak wrote: On 09/24/2014 05:50 AM, Laine Stump wrote: These patches set up an event handler for qemu's NIC_RX_FILTER_CHANGED event, which is sent whenever a guest makes a change to a network device's unicast/multicast filter, vlan table, or MAC address. The handler checks if it is appropriate to respond to the NIC_RX_FILTER_CHANGED event (based on device type and configuration) and takes appropriate action. Currently it checks if the guest interface has been configured with trustGuestRxFilters='yes' (defaults to 'no' for security reasons), and if the host side device is macvtap. If so, and the MAC address on the guest has changed, the MAC address of the macvtap device is changed to match. The result of this is that networking from the guest will continue to work if the mac address of a macvtap-connected network device is changed from within the guest, as long as trustGuestRxFilters='yes' (previously changing the MAC address in the guest would break networking). I still need to add code to compare the old and new unicast and multicast lists and program the filters in the macvtap to match the guest, and to check for a non-empty vlan table and handle that (currently that means just setting promiscuous mode on the macvtap), but that can come in a followup series. I was very interested in this patch set because I developed a set of patches to respond to the NIC_RX_FILTER_CHANGED event. I completed the patch set several weeks ago and have been awaiting completion of our internal review before submitting them to this mailing list. Apparently you beat me to the punch. I have code that compares the old and new multicast lists and synchronizes the macvtap filters with the guest's. I can modify my patches to integrate this function into what you have provided with this patch set. Would that be agreeable? Since I've just started working on exactly that, yes :-) What I'd started was a function virNetDevGetRxFilter(ifname, filter) in virnetdev.c which would do for the host-side tap/macvtap device what qemuMonitorQueryRxFilter() does for the guest's interface - retrieve the current unicast/multicast/vlan tables modes (using code from iproute2's bridge command as a guide to write equivalent libnl-based code) and return them in a fully-populated virNetDevRxFilter object (that's why I defined that struct in virnetdev.h even though I've so far used it only in the qemu driver), which would be called from the event handler; the event handler would compare the two virNetDevRxFilter objects (the one from the host-side device and the one from the guest-side device) and issue the necessary commands to make everything match (well, actually what I've been told is that in the case of vlans, if the guest has a non-empty vlan table we currently have to just set the macvtap to promiscuous mode). It sounds like you're only interested in the multicast list, so if you wanted to fill in enough to make it do that, your code could be used as a model to do the unicast list (which seems to be empty most of the time anyway; as I usually operate above that layer, I'm truthfully not exactly sure when it's even used). I am interested in a complete solution, however; I chose to ignore the unicast list for the time being for reasons similar to yours. I wrote code to synchronize the VLAN table, but subsequently learned that there were problems with VLAN on macvtap, so I took that code out of the patch set. I used the ip maddr show command in iproute2 as a model for acquiring the multicast list. This command reads the /proc/net/dev_mcast file on the host to get the current multicast MAC address list for the macvtap device. To synchronize the macvtap device's multicast list, I compared the list from /proc/net/dev_mcast with that returned from the query_rx_filter command and used the SIOCADDMULTI and SIOCDELMULTI ioctl's add and delete multicast MAC addresses as needed. I did not do anything with the mode (state) values as I have yet to figure out how to do that. I also wrote code to synchronize the following interface flags: * promiscuous * multicast * allmulti * broadcast I can integrate what I have with your infrastructure including: * Create a virNetDevGetRxFilter(ifname, filter) function in virnetdev.c that will populate the following fields in the filter: * name * mac * promiscuous * broadcastAllowed * multicast.table * multicast.nTable * vlan.table * vlan.nTable * Implement the event handler code to: * compare the two virNetDevRxFilter objects and issue the necessary commands to synchronize the multicast MAC address lists * set the promiscuous mode if the guest has a non-empty vlan table * compare the device flags and synchronize their values If you think this would be a worthwhile endeavor, I've got your patches installed and can proceed. In the future, this same infrastructure
Re: [libvirt] NBD TLS support in QEMU
Hi, On Fri, Sep 05, 2014 at 03:26:09PM +0200, Wouter Verhelst wrote: Tunneling the entire protocol inside an SSL connection doesn't fix that; if an attacker is able to hijack your TCP connections and change flags, then this attacker is also able to hijack your TCP connection and redirect it to a decrypting/encrypting proxy. I agree that preventing a possible SSL downgrade attack (and other forms of MITM) should be high on the priority list, but tunnel the whole thing in SSL doesn't do that. So, having given this some thought, I wanted to come up with a spec just so that we had something we could all agree on. As part of that, I had a look at qemu-nbd, and noticed that it uses the oldstyle handshake protocol (on port 10809 by default -- ew, please don't do that). I had to change the protocol incompatibly a few years back, because the oldstyle protocol is broken by design; in the oldstyle negotiation protocol, the server dumps all information it has on the export to the client, and then moves on to the data negotiation phase, without waiting for any reply from the client. This means the oldstyle protocol can't be used for any sort of negotiation[1]. As such, I strongly suggest that qemu-nbd move to the newstyle protocol. This would also allow you to use named exports and various other things, and would allow negotiation of TLS or SASL in a clean and proper way. [1] That sole issue is the reason I broke backwards compatibility with the newstyle handshake protocol, and is also why I reserved 10809, the port assigned to nbd by IANA at my request, to be for newstyle handshakes only. -- It is easy to love a country that is famous for chocolate and beer -- Barack Obama, speaking in Brussels, Belgium, 2014-03-26 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] network: Add network bandwidth support for ethernet interfaces
Should I recreate this patch on the top of the latest tree and resubmit? Or, is there anything that I missed out? Any feedback will be highly appreciated. Thanks. Anirban On 9/26/14, 10:52 AM, Anirban Chakraborty abc...@juniper.net wrote: V2: Addressed comments raised in review of V1. Consolidate calls to virNetDevBandwidthSet. Clear bandwidth settings when the interface is detached or domain destroyed. V1: Ethernet interfaces in libvirt currently do not support bandwidth setting. For example, following xml file for an interface will not apply these settings to corresponding qdiscs. interface type=ethernet mac address=02:36:1d:18:2a:e4/ model type=virtio/ script path=/ target dev=tap361d182a-e4/ bandwidth inbound average=984 peak=1024 burst=64/ outbound average=2000 peak=2048 burst=128/ /bandwidth /interface Signed-off-by: Anirban Chakraborty abc...@juniper.net --- src/lxc/lxc_process.c | 26 +- src/network/bridge_driver.c| 7 --- src/qemu/qemu_command.c| 9 - src/qemu/qemu_driver.c | 22 +- src/qemu/qemu_hotplug.c| 14 +- src/util/virnetdevbandwidth.c | 23 --- src/util/virnetdevbandwidth.h | 7 --- src/util/virnetdevmacvlan.c| 10 -- src/util/virnetdevmacvlan.h| 1 - tests/virnetdevbandwidthtest.c | 3 ++- 10 files changed, 81 insertions(+), 41 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index ed30c37..7f7e4ad 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -274,11 +274,6 @@ char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn, if (virNetDevSetOnline(parentVeth, true) 0) goto cleanup; -if (virNetDevBandwidthSet(net-ifname, - virDomainNetGetActualBandwidth(net), - false) 0) -goto cleanup; - if (net-filter virDomainConfNWFilterInstantiate(conn, vm-uuid, net) 0) goto cleanup; @@ -300,6 +295,7 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn, virNetDevBandwidthPtr bw; virNetDevVPortProfilePtr prof; virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver); +const char *linkdev = virDomainNetGetActualDirectDev(net); /* XXX how todo bandwidth controls ? * Since the 'net-ifname' is about to be moved to a different @@ -329,16 +325,15 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn, if (virNetDevMacVLanCreateWithVPortProfile( net-ifname, net-mac, -virDomainNetGetActualDirectDev(net), +linkdev, virDomainNetGetActualDirectMode(net), false, def-uuid, -virDomainNetGetActualVirtPortProfile(net), +prof, res_ifname, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, cfg-stateDir, -virDomainNetGetActualBandwidth(net), 0) 0) +0) 0) goto cleanup; - ret = res_ifname; cleanup: @@ -368,6 +363,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, int ret = -1; size_t i; size_t niface = 0; +int actualType; for (i = 0; i def-nnets; i++) { char *veth = NULL; @@ -381,7 +377,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, if (VIR_EXPAND_N(*veths, *nveths, 1) 0) goto cleanup; -switch (virDomainNetGetActualType(def-nets[i])) { +actualType = virDomainNetGetActualType(def-nets[i]); +switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: { virNetworkPtr network; char *brname = NULL; @@ -444,11 +441,14 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _(Unsupported network type %s), - virDomainNetTypeToString( - virDomainNetGetActualType(def-nets[i]) - )); + virDomainNetTypeToString(actualType)); goto cleanup; } +/* set network bandwidth */ +if (virNetDevBandwidthSet(def-nets[i]-ifname, +virDomainNetGetActualBandwidth(def-nets[i]), false, +actualType) 0) + goto cleanup; (*veths)[(*nveths)-1] = veth; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 979fb13..2e1f821 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2082,7 +2082,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, } if (virNetDevBandwidthSet(network-def-bridge, - network-def-bandwidth, true) 0) + network-def-bandwidth, true, +
[libvirt] [PATCH v3 02/14] vbox: Rewrite vboxNetworkOpen
--- po/POTFILES.in|1 + src/Makefile.am |1 + src/vbox/vbox_network.c | 58 + src/vbox/vbox_tmpl.c | 24 - src/vbox/vbox_uniformed_api.h |3 +++ 5 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 src/vbox/vbox_network.c diff --git a/po/POTFILES.in b/po/POTFILES.in index 020a9ac..9e00f73 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -220,6 +220,7 @@ src/vbox/vbox_MSCOMGlue.c src/vbox/vbox_XPCOMCGlue.c src/vbox/vbox_driver.c src/vbox/vbox_common.c +src/vbox/vbox_network.c src/vbox/vbox_snapshot_conf.c src/vbox/vbox_tmpl.c src/vmware/vmware_conf.c diff --git a/src/Makefile.am b/src/Makefile.am index dcd2ae2..34eb9f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -678,6 +678,7 @@ VBOX_DRIVER_SOURCES = \ vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \ vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \ vbox/vbox_common.c vbox/vbox_common.h \ + vbox/vbox_network.c \ vbox/vbox_uniformed_api.h \ vbox/vbox_get_driver.h diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c new file mode 100644 index 000..2e09b4b --- /dev/null +++ b/src/vbox/vbox_network.c @@ -0,0 +1,58 @@ +/* + * Copyright 2014, Taowei Luo (uaeda...@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * http://www.gnu.org/licenses/. + */ + +#include config.h + +#include internal.h +#include datatypes.h +#include domain_conf.h +#include domain_event.h +#include virlog.h + +#include vbox_common.h +#include vbox_uniformed_api.h + +#define VIR_FROM_THIS VIR_FROM_VBOX + +VIR_LOG_INIT(vbox.vbox_network); + +/** + * The Network Functions here on + */ + +virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + unsigned int flags) +{ +vboxGlobalData *data = conn-privateData; + +virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + +if (STRNEQ(conn-driver-name, VBOX)) +goto cleanup; + +if (!data-pFuncs || !data-vboxObj || !data-vboxSession) +goto cleanup; + +VIR_DEBUG(network initialized); +/* conn-networkPrivateData = some network specific data */ +return VIR_DRV_OPEN_SUCCESS; + + cleanup: +return VIR_DRV_OPEN_DECLINED; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index e5d6d66..da3841f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2059,30 +2059,6 @@ _registerDomainEvent(virDriverPtr driver) /** * The Network Functions here on */ -static virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, -virConnectAuthPtr auth ATTRIBUTE_UNUSED, -unsigned int flags) -{ -vboxGlobalData *data = conn-privateData; - -virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - -if (STRNEQ(conn-driver-name, VBOX)) -goto cleanup; - -if ((data-pFuncs == NULL) || -(data-vboxObj == NULL) || -(data-vboxSession == NULL)) -goto cleanup; - -VIR_DEBUG(network initialized); -/* conn-networkPrivateData = some network specific data */ -return VIR_DRV_OPEN_SUCCESS; - - cleanup: -return VIR_DRV_OPEN_DECLINED; -} - static int vboxNetworkClose(virConnectPtr conn) { VIR_DEBUG(network uninitialized); diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 41ce40f..0237160 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -534,6 +534,9 @@ typedef struct { virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid); +virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, + virConnectAuthPtr auth, + unsigned int flags); /* Version specified functions for installing uniformed API */ void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -- 1.7.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 00/14] vbox: rewrite network driver
This seriers of patches rewrite the vbox network driver. Diff from v2: *Seperate the network driver from the domain driver. *Prevent vbox code from being compiled too many times when building network driver. Taowei (14): vbox: Interfaces for register per parties vbox: Rewrite vboxNetworkOpen vbox: Rewrite vboxNetworkClose vbox: Rewrite vboxConnectNumOfNetworks vbox: Rewrite vboxConnectListNetworks vbox: Rewrite vboxConnectNumOfDefinedNetworks vbox: Rewrite vboxConnectListDefinedNetworks vbox: Rewrite vboxNetworkLookupByUUID vbox: Rewrite vboxNetworkLookupByName vbox: Rewrite vboxNetworkDefineCreateXML vbox: Rewrite vboxNetworkUndefineDestroy vbox: Rewrite vboxNetworkCreate vbox: Rewrite vboxNetworkGetXMLDesc vbox: New network driver po/POTFILES.in |1 + src/Makefile.am| 16 +- src/vbox/vbox_common.c | 70 +- src/vbox/vbox_common.h | 16 + src/vbox/vbox_driver.c | 55 +- src/vbox/{vbox_install_api.h = vbox_get_driver.h} |9 +- src/vbox/vbox_network.c| 1050 src/vbox/vbox_tmpl.c | 1261 +--- src/vbox/vbox_uniformed_api.h | 52 + 9 files changed, 1523 insertions(+), 1007 deletions(-) rename src/vbox/{vbox_install_api.h = vbox_get_driver.h} (79%) create mode 100644 src/vbox/vbox_network.c -- 1.7.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 01/14] vbox: Interfaces for register per parties
The patch dbb4cbf532fa by Michal has splited the vbox driver into three parties. This modification brings a more suitable interface to the previous patch. The new function vboxGetDriver is introduced to get the corresponding vbox domain driver directly thought the vbox version. Functions like vboxGetNetworkDriver and vboxGetStorageDriver will be introduced after rewriting it's drivers. This patch, by the wayi, fixed the align problem for vbox in Makefile.am --- src/Makefile.am|6 +- src/vbox/vbox_common.c | 69 ++-- src/vbox/vbox_driver.c | 48 ++ src/vbox/{vbox_install_api.h = vbox_get_driver.h} |8 +-- 4 files changed, 61 insertions(+), 70 deletions(-) rename src/vbox/{vbox_install_api.h = vbox_get_driver.h} (84%) diff --git a/src/Makefile.am b/src/Makefile.am index e65177f..dcd2ae2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -666,7 +666,7 @@ VMWARE_DRIVER_SOURCES = \ VBOX_DRIVER_SOURCES = \ vbox/vbox_glue.c vbox/vbox_glue.h \ vbox/vbox_driver.c vbox/vbox_driver.h \ - vbox/vbox_snapshot_conf.c vbox/vbox_snapshot_conf.h \ + vbox/vbox_snapshot_conf.c vbox/vbox_snapshot_conf.h \ vbox/vbox_V2_2.c vbox/vbox_CAPI_v2_2.h \ vbox/vbox_V3_0.c vbox/vbox_CAPI_v3_0.h \ vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \ @@ -674,12 +674,12 @@ VBOX_DRIVER_SOURCES = \ vbox/vbox_V4_0.c vbox/vbox_CAPI_v4_0.h \ vbox/vbox_V4_1.c vbox/vbox_CAPI_v4_1.h \ vbox/vbox_V4_2.c vbox/vbox_CAPI_v4_2.h \ - vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h\ + vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h\ vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \ vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \ vbox/vbox_common.c vbox/vbox_common.h \ vbox/vbox_uniformed_api.h \ - vbox/vbox_install_api.h + vbox/vbox_get_driver.h VBOX_DRIVER_EXTRA_DIST = \ vbox/vbox_tmpl.c vbox/README\ diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 7d75478..44270ff 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -38,7 +38,7 @@ #include vbox_common.h #include vbox_uniformed_api.h -#include vbox_install_api.h +#include vbox_get_driver.h /* Common codes for vbox driver. With the definitions in vbox_common.h, * it treats vbox structs as a void*. Though vboxUniformedAPI @@ -121,41 +121,6 @@ if (!data-vboxObj) {\ /* global vbox API, used for all common codes. */ static vboxUniformedAPI gVBoxAPI; -/* update the virDriver according to the vboxUniformedAPI */ -static void updateDriver(void); - -int vboxRegisterUniformedAPI(uint32_t uVersion) -{ -/* Install gVBoxAPI according to the vbox API version. - * Return -1 for unsupported version. - */ -if (uVersion = 2001052 uVersion 2002051) { -vbox22InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 2002051 uVersion 351) { -vbox30InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 351 uVersion 3001051) { -vbox31InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 3001051 uVersion 3002051) { -vbox32InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 3002051 uVersion 451) { -vbox40InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 451 uVersion 4001051) { -vbox41InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 4001051 uVersion 4002020) { -vbox42InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 4002020 uVersion 4002051) { -vbox42_20InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 4002051 uVersion 4003004) { -vbox43InstallUniformedAPI(gVBoxAPI); -} else if (uVersion = 4003004 uVersion 4003051) { -vbox43_4InstallUniformedAPI(gVBoxAPI); -} else { -return -1; -} -updateDriver(); -return 0; -} - static int openSessionForMachine(vboxGlobalData *data, const unsigned char *dom_uuid, vboxIIDUnion *iid, IMachine **machine, bool checkflag) { @@ -7565,3 +7530,35 @@ static void updateDriver(void) else vboxCommonDriver.domainScreenshot = NULL; } + +virDriverPtr vboxGetDriver(uint32_t uVersion) +{ +/* Install gVBoxAPI according to the vbox API version. + * Return -1 for unsupported version. + */ +if (uVersion = 2001052 uVersion 2002051) { +vbox22InstallUniformedAPI(gVBoxAPI); +} else if (uVersion =
[libvirt] [PATCH v3 04/14] vbox: Rewrite vboxConnectNumOfNetworks
--- src/vbox/vbox_common.h| 15 ++ src/vbox/vbox_network.c | 55 ++ src/vbox/vbox_tmpl.c | 65 - src/vbox/vbox_uniformed_api.h | 10 +++ 4 files changed, 111 insertions(+), 34 deletions(-) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index b5a0353..9f5385b 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -265,6 +265,19 @@ enum MediumVariant MediumVariant_Diff = 0x2 }; +enum HostNetworkInterfaceStatus +{ +HostNetworkInterfaceStatus_Unknown = 0, +HostNetworkInterfaceStatus_Up = 1, +HostNetworkInterfaceStatus_Down = 2 +}; + +enum HostNetworkInterfaceType +{ +HostNetworkInterfaceType_Bridged = 1, +HostNetworkInterfaceType_HostOnly = 2 +}; + # define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001 # define VBOX_E_INVALID_VM_STATE 0x80BB0002 # define VBOX_E_VM_ERROR 0x80BB0003 @@ -302,5 +315,7 @@ typedef nsISupports IStorageController; typedef nsISupports ISharedFolder; typedef nsISupports ISnapshot; typedef nsISupports IDisplay; +typedef nsISupports IHost; +typedef nsISupports IHostNetworkInterface; #endif /* VBOX_COMMON_H */ diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index af38562..b2e9060 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -31,6 +31,16 @@ VIR_LOG_INIT(vbox.vbox_network); +#define VBOX_RELEASE(arg) \ +do { \ +if (arg) {\ +gVBoxAPI.nsUISupports.Release((void *)arg); \ +(arg) = NULL; \ +} \ +} while (0) + +static vboxUniformedAPI gVBoxAPI; + /** * The Network Functions here on */ @@ -63,3 +73,48 @@ int vboxNetworkClose(virConnectPtr conn) conn-networkPrivateData = NULL; return 0; } + +int vboxConnectNumOfNetworks(virConnectPtr conn) +{ +vboxGlobalData *data = conn-privateData; +vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; +IHost *host = NULL; +size_t i = 0; +int ret = -1; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +gVBoxAPI.UArray.vboxArrayGet(networkInterfaces, host, + gVBoxAPI.UArray.handleHostGetNetworkInterfaces(host)); + +ret = 0; +for (i = 0; i networkInterfaces.count; i++) { +IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; +PRUint32 status = HostNetworkInterfaceStatus_Unknown; +PRUint32 interfaceType = 0; + +if (!networkInterface) +continue; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); +if (interfaceType != HostNetworkInterfaceType_HostOnly) +continue; + +gVBoxAPI.UIHNInterface.GetStatus(networkInterface, status); + +if (status == HostNetworkInterfaceStatus_Up) +ret++; +} + +gVBoxAPI.UArray.vboxArrayRelease(networkInterfaces); + +VBOX_RELEASE(host); + +VIR_DEBUG(numActive: %d, ret); +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 06b8722..324e5d6 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2060,40 +2060,6 @@ _registerDomainEvent(virDriverPtr driver) * The Network Functions here on */ -static int vboxConnectNumOfNetworks(virConnectPtr conn) -{ -VBOX_OBJECT_HOST_CHECK(conn, int, 0); -vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; -size_t i = 0; - -vboxArrayGet(networkInterfaces, host, host-vtbl-GetNetworkInterfaces); - -for (i = 0; i networkInterfaces.count; i++) { -IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; - -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -PRUint32 status = HostNetworkInterfaceStatus_Unknown; - -networkInterface-vtbl-GetStatus(networkInterface, status); - -if (status == HostNetworkInterfaceStatus_Up) -ret++; -} -} -} - -vboxArrayRelease(networkInterfaces); - -VBOX_RELEASE(host); - -VIR_DEBUG(numActive: %d, ret); -return ret; -} - static int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames) { VBOX_OBJECT_HOST_CHECK(conn, int, 0); vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; @@ -4501,6 +4467,11 @@ static void* _handleMediumGetSnapshotIds(IMedium *medium) return
[libvirt] [PATCH v3 06/14] vbox: Rewrite vboxConnectNumOfDefinedNetworks
--- src/vbox/vbox_network.c | 45 + src/vbox/vbox_tmpl.c | 34 --- src/vbox/vbox_uniformed_api.h |1 + 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index c6cb0e9..af451b4 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -195,3 +195,48 @@ int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames) return ret; } + +int vboxConnectNumOfDefinedNetworks(virConnectPtr conn) +{ +vboxGlobalData *data = conn-privateData; +vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; +IHost *host = NULL; +size_t i = 0; +int ret = -1; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +gVBoxAPI.UArray.vboxArrayGet(networkInterfaces, host, + gVBoxAPI.UArray.handleHostGetNetworkInterfaces(host)); + +ret = 0; +for (i = 0; i networkInterfaces.count; i++) { +IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; +PRUint32 status = HostNetworkInterfaceStatus_Unknown; +PRUint32 interfaceType = 0; + +if (!networkInterface) +continue; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); +if (interfaceType != HostNetworkInterfaceType_HostOnly) +continue; + +gVBoxAPI.UIHNInterface.GetStatus(networkInterface, status); + +if (status == HostNetworkInterfaceStatus_Down) +ret++; +} + +gVBoxAPI.UArray.vboxArrayRelease(networkInterfaces); + +VBOX_RELEASE(host); + +VIR_DEBUG(numActive: %d, ret); +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index c7aae25..fec9ce1 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2060,40 +2060,6 @@ _registerDomainEvent(virDriverPtr driver) * The Network Functions here on */ -static int vboxConnectNumOfDefinedNetworks(virConnectPtr conn) -{ -VBOX_OBJECT_HOST_CHECK(conn, int, 0); -vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; -size_t i = 0; - -vboxArrayGet(networkInterfaces, host, host-vtbl-GetNetworkInterfaces); - -for (i = 0; i networkInterfaces.count; i++) { -IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; - -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -PRUint32 status = HostNetworkInterfaceStatus_Unknown; - -networkInterface-vtbl-GetStatus(networkInterface, status); - -if (status == HostNetworkInterfaceStatus_Down) -ret++; -} -} -} - -vboxArrayRelease(networkInterfaces); - -VBOX_RELEASE(host); - -VIR_DEBUG(numActive: %d, ret); -return ret; -} - static int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) { VBOX_OBJECT_HOST_CHECK(conn, int, 0); vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index ec8e334..2ca90ff 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -550,6 +550,7 @@ virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, int vboxNetworkClose(virConnectPtr conn); int vboxConnectNumOfNetworks(virConnectPtr conn); int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames); +int vboxConnectNumOfDefinedNetworks(virConnectPtr conn); /* Version specified functions for installing uniformed API */ void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -- 1.7.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 07/14] vbox: Rewrite vboxConnectListDefinedNetworks
--- src/vbox/vbox_network.c | 57 + src/vbox/vbox_tmpl.c | 45 src/vbox/vbox_uniformed_api.h |1 + 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index af451b4..6d2ecdc 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -240,3 +240,60 @@ int vboxConnectNumOfDefinedNetworks(virConnectPtr conn) VIR_DEBUG(numActive: %d, ret); return ret; } + +int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) +{ +vboxGlobalData *data = conn-privateData; +vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; +IHost *host = NULL; +size_t i = 0; +int ret = -1; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +gVBoxAPI.UArray.vboxArrayGet(networkInterfaces, host, + gVBoxAPI.UArray.handleHostGetNetworkInterfaces(host)); + +ret = 0; +for (i = 0; (ret nnames) (i networkInterfaces.count); i++) { +IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; +PRUint32 interfaceType = 0; +char *nameUtf8 = NULL; +PRUnichar *nameUtf16 = NULL; +PRUint32 status = HostNetworkInterfaceStatus_Unknown; + +if (!networkInterface) +continue; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +continue; + +gVBoxAPI.UIHNInterface.GetStatus(networkInterface, status); + +if (status != HostNetworkInterfaceStatus_Down) +continue; + +gVBoxAPI.UIHNInterface.GetName(networkInterface, nameUtf16); +VBOX_UTF16_TO_UTF8(nameUtf16, nameUtf8); + +VIR_DEBUG(nnames[%d]: %s, ret, nameUtf8); +if (VIR_STRDUP(names[ret], nameUtf8) = 0) +ret++; + +VBOX_UTF8_FREE(nameUtf8); +VBOX_UTF16_FREE(nameUtf16); +} + +gVBoxAPI.UArray.vboxArrayRelease(networkInterfaces); + +VBOX_RELEASE(host); + +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index fec9ce1..ed75656 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2060,51 +2060,6 @@ _registerDomainEvent(virDriverPtr driver) * The Network Functions here on */ -static int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) { -VBOX_OBJECT_HOST_CHECK(conn, int, 0); -vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; -size_t i = 0; - -vboxArrayGet(networkInterfaces, host, host-vtbl-GetNetworkInterfaces); - -for (i = 0; (ret nnames) (i networkInterfaces.count); i++) { -IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; - -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); - -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -PRUint32 status = HostNetworkInterfaceStatus_Unknown; - -networkInterface-vtbl-GetStatus(networkInterface, status); - -if (status == HostNetworkInterfaceStatus_Down) { -char *nameUtf8 = NULL; -PRUnichar *nameUtf16 = NULL; - -networkInterface-vtbl-GetName(networkInterface, nameUtf16); -VBOX_UTF16_TO_UTF8(nameUtf16, nameUtf8); - -VIR_DEBUG(nnames[%d]: %s, ret, nameUtf8); -if (VIR_STRDUP(names[ret], nameUtf8) = 0) -ret++; - -VBOX_UTF8_FREE(nameUtf8); -VBOX_UTF16_FREE(nameUtf16); -} -} -} -} - -vboxArrayRelease(networkInterfaces); - -VBOX_RELEASE(host); - -return ret; -} - static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 2ca90ff..e6729f2 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -551,6 +551,7 @@ int vboxNetworkClose(virConnectPtr conn); int vboxConnectNumOfNetworks(virConnectPtr conn); int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames); int vboxConnectNumOfDefinedNetworks(virConnectPtr conn); +int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames); /* Version specified functions for installing uniformed API */ void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -- 1.7.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 05/14] vbox: Rewrite vboxConnectListNetworks
--- src/vbox/vbox_network.c | 77 + src/vbox/vbox_tmpl.c | 52 src/vbox/vbox_uniformed_api.h |2 ++ 3 files changed, 86 insertions(+), 45 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index b2e9060..c6cb0e9 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -23,6 +23,7 @@ #include domain_conf.h #include domain_event.h #include virlog.h +#include virstring.h #include vbox_common.h #include vbox_uniformed_api.h @@ -31,6 +32,25 @@ VIR_LOG_INIT(vbox.vbox_network); +#define VBOX_UTF16_FREE(arg)\ +do {\ +if (arg) { \ +gVBoxAPI.UPFN.Utf16Free(data-pFuncs, arg); \ +(arg) = NULL; \ +} \ +} while (0) + +#define VBOX_UTF8_FREE(arg) \ +do {\ +if (arg) { \ +gVBoxAPI.UPFN.Utf8Free(data-pFuncs, arg); \ +(arg) = NULL; \ +} \ +} while (0) + +#define VBOX_UTF16_TO_UTF8(arg1, arg2) gVBoxAPI.UPFN.Utf16ToUtf8(data-pFuncs, arg1, arg2) +#define VBOX_UTF8_TO_UTF16(arg1, arg2) gVBoxAPI.UPFN.Utf8ToUtf16(data-pFuncs, arg1, arg2) + #define VBOX_RELEASE(arg) \ do { \ if (arg) {\ @@ -118,3 +138,60 @@ int vboxConnectNumOfNetworks(virConnectPtr conn) VIR_DEBUG(numActive: %d, ret); return ret; } + +int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames) +{ +vboxGlobalData *data = conn-privateData; +vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; +IHost *host = NULL; +size_t i = 0; +int ret = -1; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +gVBoxAPI.UArray.vboxArrayGet(networkInterfaces, host, + gVBoxAPI.UArray.handleHostGetNetworkInterfaces(host)); + +ret = 0; +for (i = 0; (ret nnames) (i networkInterfaces.count); i++) { +IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; +char *nameUtf8 = NULL; +PRUnichar *nameUtf16 = NULL; +PRUint32 interfaceType = 0; +PRUint32 status = HostNetworkInterfaceStatus_Unknown; + +if (!networkInterface) +continue; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +continue; + +gVBoxAPI.UIHNInterface.GetStatus(networkInterface, status); + +if (status != HostNetworkInterfaceStatus_Up) +continue; + +gVBoxAPI.UIHNInterface.GetName(networkInterface, nameUtf16); +VBOX_UTF16_TO_UTF8(nameUtf16, nameUtf8); + +VIR_DEBUG(nnames[%d]: %s, ret, nameUtf8); +if (VIR_STRDUP(names[ret], nameUtf8) = 0) +ret++; + +VBOX_UTF8_FREE(nameUtf8); +VBOX_UTF16_FREE(nameUtf16); +} + +gVBoxAPI.UArray.vboxArrayRelease(networkInterfaces); + +VBOX_RELEASE(host); + +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 324e5d6..c7aae25 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2060,51 +2060,6 @@ _registerDomainEvent(virDriverPtr driver) * The Network Functions here on */ -static int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames) { -VBOX_OBJECT_HOST_CHECK(conn, int, 0); -vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; -size_t i = 0; - -vboxArrayGet(networkInterfaces, host, host-vtbl-GetNetworkInterfaces); - -for (i = 0; (ret nnames) (i networkInterfaces.count); i++) { -IHostNetworkInterface *networkInterface = networkInterfaces.items[i]; - -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); - -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -PRUint32 status = HostNetworkInterfaceStatus_Unknown; - -networkInterface-vtbl-GetStatus(networkInterface, status); - -if (status == HostNetworkInterfaceStatus_Up) { -char *nameUtf8 =
[libvirt] [PATCH v3 03/14] vbox: Rewrite vboxNetworkClose
--- src/vbox/vbox_network.c |7 +++ src/vbox/vbox_tmpl.c |6 -- src/vbox/vbox_uniformed_api.h |1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 2e09b4b..af38562 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -56,3 +56,10 @@ virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, cleanup: return VIR_DRV_OPEN_DECLINED; } + +int vboxNetworkClose(virConnectPtr conn) +{ +VIR_DEBUG(network uninitialized); +conn-networkPrivateData = NULL; +return 0; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index da3841f..06b8722 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2059,12 +2059,6 @@ _registerDomainEvent(virDriverPtr driver) /** * The Network Functions here on */ -static int vboxNetworkClose(virConnectPtr conn) -{ -VIR_DEBUG(network uninitialized); -conn-networkPrivateData = NULL; -return 0; -} static int vboxConnectNumOfNetworks(virConnectPtr conn) { diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 0237160..8552efb 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -537,6 +537,7 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags); +int vboxNetworkClose(virConnectPtr conn); /* Version specified functions for installing uniformed API */ void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -- 1.7.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 12/14] vbox: Rewrite vboxNetworkCreate
--- src/vbox/vbox_network.c | 72 + src/vbox/vbox_tmpl.c | 68 -- src/vbox/vbox_uniformed_api.h |1 + 3 files changed, 73 insertions(+), 68 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 60fbe5e..2fc8230 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -734,3 +734,75 @@ int vboxNetworkDestroy(virNetworkPtr network) { return vboxNetworkUndefineDestroy(network, false); } + +int vboxNetworkCreate(virNetworkPtr network) +{ +vboxGlobalData *data = network-conn-privateData; +char *networkNameUtf8 = NULL; +PRUnichar *networkInterfaceNameUtf16 = NULL; +IHostNetworkInterface *networkInterface = NULL; +PRUnichar *networkNameUtf16 = NULL; +IDHCPServer *dhcpServer = NULL; +PRUnichar *trunkTypeUtf16 = NULL; +PRUint32 interfaceType = 0; +IHost *host = NULL; +int ret = -1; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +/* Current limitation of the function for VirtualBox 2.2.* is + * that the default hostonly network vboxnet0 is always active + * and thus all this functions does is start the dhcp server, + * but the network can still be used without starting the dhcp + * server by giving the machine static IP + */ + +if (virAsprintf(networkNameUtf8, HostInterfaceNetworking-%s, network-name) 0) +goto cleanup; + +VBOX_UTF8_TO_UTF16(network-name, networkInterfaceNameUtf16); + +gVBoxAPI.UIHost.FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16, networkInterface); + +if (!networkInterface) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +goto cleanup; + +VBOX_UTF8_TO_UTF16(networkNameUtf8, networkNameUtf16); + +gVBoxAPI.UIVirtualBox.FindDHCPServerByNetworkName(data-vboxObj, + networkNameUtf16, + dhcpServer); +if (!dhcpServer) +goto cleanup; + +gVBoxAPI.UIDHCPServer.SetEnabled(dhcpServer, PR_TRUE); + +VBOX_UTF8_TO_UTF16(netflt, trunkTypeUtf16); + +gVBoxAPI.UIDHCPServer.Start(dhcpServer, +networkNameUtf16, +networkInterfaceNameUtf16, +trunkTypeUtf16); + +VBOX_UTF16_FREE(trunkTypeUtf16); +ret = 0; + + cleanup: +VBOX_RELEASE(dhcpServer); +VBOX_UTF16_FREE(networkNameUtf16); +VBOX_RELEASE(networkInterface); +VBOX_UTF16_FREE(networkInterfaceNameUtf16); +VBOX_RELEASE(host); +VIR_FREE(networkNameUtf8); +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index c072246..8712a3b 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2042,74 +2042,6 @@ _registerDomainEvent(virDriverPtr driver) * The Network Functions here on */ -static int vboxNetworkCreate(virNetworkPtr network) -{ -VBOX_OBJECT_HOST_CHECK(network-conn, int, -1); -char *networkNameUtf8 = NULL; -PRUnichar *networkInterfaceNameUtf16= NULL; -IHostNetworkInterface *networkInterface = NULL; - -/* Current limitation of the function for VirtualBox 2.2.* is - * that the default hostonly network vboxnet0 is always active - * and thus all this functions does is start the dhcp server, - * but the network can still be used without starting the dhcp - * server by giving the machine static IP - */ - -if (virAsprintf(networkNameUtf8, HostInterfaceNetworking-%s, network-name) 0) -goto cleanup; - -VBOX_UTF8_TO_UTF16(network-name, networkInterfaceNameUtf16); - -host-vtbl-FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16, networkInterface); - -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); - -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -PRUnichar *networkNameUtf16 = NULL; -IDHCPServer *dhcpServer = NULL; - - -VBOX_UTF8_TO_UTF16(networkNameUtf8, networkNameUtf16); - -data-vboxObj-vtbl-FindDHCPServerByNetworkName(data-vboxObj, - networkNameUtf16, - dhcpServer); -if (dhcpServer) { -PRUnichar *trunkTypeUtf16 = NULL; - -dhcpServer-vtbl-SetEnabled(dhcpServer, PR_TRUE); - -VBOX_UTF8_TO_UTF16(netflt, trunkTypeUtf16); - -dhcpServer-vtbl-Start(dhcpServer, -networkNameUtf16, -
[libvirt] [PATCH v3 11/14] vbox: Rewrite vboxNetworkUndefineDestroy
This patch rewrites two public APIs. They are vboxNetworkUndefine and vboxNetworkDestroy. They use the same core function vboxNetworkUndefineDestroy. I merged it in one patch. --- src/vbox/vbox_network.c | 109 + src/vbox/vbox_tmpl.c | 136 - src/vbox/vbox_uniformed_api.h |7 +++ 3 files changed, 156 insertions(+), 96 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index feecf0c..60fbe5e 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -34,6 +34,9 @@ VIR_LOG_INIT(vbox.vbox_network); +#define RC_SUCCEEDED(rc) NS_SUCCEEDED(rc.resultCode) +#define RC_FAILED(rc) NS_FAILED(rc.resultCode) + #define VBOX_UTF16_FREE(arg)\ do {\ if (arg) { \ @@ -625,3 +628,109 @@ virNetworkPtr vboxNetworkDefineXML(virConnectPtr conn, const char *xml) { return vboxNetworkDefineCreateXML(conn, xml, false); } + +static int +vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterface) +{ +vboxGlobalData *data = network-conn-privateData; +char *networkNameUtf8 = NULL; +PRUnichar *networkInterfaceNameUtf16 = NULL; +IHostNetworkInterface *networkInterface = NULL; +PRUnichar *networkNameUtf16 = NULL; +IDHCPServer *dhcpServer = NULL; +PRUint32 interfaceType = 0; +IHost *host = NULL; +int ret = -1; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +/* Current limitation of the function for VirtualBox 2.2.* is + * that you can't delete the default hostonly adaptor namely: + * vboxnet0 and thus all this functions does is remove the + * dhcp server configuration, but the network can still be used + * by giving the machine static IP and also it will still + * show up in the net-list in virsh + */ + +if (virAsprintf(networkNameUtf8, HostInterfaceNetworking-%s, network-name) 0) +goto cleanup; + +VBOX_UTF8_TO_UTF16(network-name, networkInterfaceNameUtf16); + +gVBoxAPI.UIHost.FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16, networkInterface); + +if (!networkInterface) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +goto cleanup; + +if (gVBoxAPI.networkRemoveInterface removeinterface) { +vboxIIDUnion iid; +IProgress *progress = NULL; +nsresult rc; +resultCodeUnion resultCode; + +VBOX_IID_INITIALIZE(iid); +rc = gVBoxAPI.UIHNInterface.GetId(networkInterface, iid); + +if (NS_FAILED(rc)) +goto cleanup; + +gVBoxAPI.UIHost.RemoveHostOnlyNetworkInterface(host, iid, progress); +vboxIIDUnalloc(iid); + +if (!progress) +goto cleanup; + +gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); +gVBoxAPI.UIProgress.GetResultCode(progress, resultCode); +if (RC_FAILED(resultCode)) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(Error while removing hostonly network interface, rc=%08x), + resultCode.uResultCode); +goto cleanup; +} +VBOX_RELEASE(progress); +} + +VBOX_UTF8_TO_UTF16(networkNameUtf8, networkNameUtf16); + +gVBoxAPI.UIVirtualBox.FindDHCPServerByNetworkName(data-vboxObj, + networkNameUtf16, + dhcpServer); +if (!dhcpServer) +goto cleanup; + +gVBoxAPI.UIDHCPServer.SetEnabled(dhcpServer, PR_FALSE); +gVBoxAPI.UIDHCPServer.Stop(dhcpServer); +if (removeinterface) +gVBoxAPI.UIVirtualBox.RemoveDHCPServer(data-vboxObj, dhcpServer); +ret = 0; +VBOX_RELEASE(dhcpServer); + + cleanup: +VBOX_UTF16_FREE(networkNameUtf16); +VBOX_RELEASE(networkInterface); +VBOX_UTF16_FREE(networkInterfaceNameUtf16); +VBOX_RELEASE(host); +VIR_FREE(networkNameUtf8); +return ret; +} + +int vboxNetworkUndefine(virNetworkPtr network) +{ +return vboxNetworkUndefineDestroy(network, true); +} + +int vboxNetworkDestroy(virNetworkPtr network) +{ +return vboxNetworkUndefineDestroy(network, false); +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 6733021..c072246 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2042,97 +2042,6 @@ _registerDomainEvent(virDriverPtr driver) * The Network Functions here on */ -static int -vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterface) -{ -VBOX_OBJECT_HOST_CHECK(network-conn, int, -1); -char *networkNameUtf8 = NULL; -PRUnichar
[libvirt] [PATCH v3 09/14] vbox: Rewrite vboxNetworkLookupByName
--- src/vbox/vbox_network.c | 49 + src/vbox/vbox_tmpl.c | 54 - src/vbox/vbox_uniformed_api.h |4 +++ 3 files changed, 69 insertions(+), 38 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 0405265..f0fa4f4 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -362,3 +362,52 @@ virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *u vboxIIDUnalloc(iid); return ret; } + +virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *name) +{ +vboxGlobalData *data = conn-privateData; +PRUnichar *nameUtf16 = NULL; +IHostNetworkInterface *networkInterface = NULL; +PRUint32 interfaceType = 0; +unsigned char uuid[VIR_UUID_BUFLEN]; +vboxIIDUnion iid; +IHost *host = NULL; +virNetworkPtr ret = NULL; +nsresult rc; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +VBOX_IID_INITIALIZE(iid); +VBOX_UTF8_TO_UTF16(name, nameUtf16); + +gVBoxAPI.UIHost.FindHostNetworkInterfaceByName(host, nameUtf16, networkInterface); + +if (!networkInterface) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +goto cleanup; + +rc = gVBoxAPI.UIHNInterface.GetId(networkInterface, iid); +if (NS_FAILED(rc)) +goto cleanup; +vboxIIDToUUID(iid, uuid); +ret = virGetNetwork(conn, name, uuid); + +VIR_DEBUG(Network Name: %s, name); +DEBUGIID(Network UUID, iid); +vboxIIDUnalloc(iid); + + cleanup: +VBOX_RELEASE(networkInterface); +VBOX_UTF16_FREE(nameUtf16); +VBOX_RELEASE(host); +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 8675182..fa55325 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2061,44 +2061,6 @@ _registerDomainEvent(virDriverPtr driver) */ static virNetworkPtr -vboxNetworkLookupByName(virConnectPtr conn, const char *name) -{ -VBOX_OBJECT_HOST_CHECK(conn, virNetworkPtr, NULL); -PRUnichar *nameUtf16= NULL; -IHostNetworkInterface *networkInterface = NULL; - -VBOX_UTF8_TO_UTF16(name, nameUtf16); - -host-vtbl-FindHostNetworkInterfaceByName(host, nameUtf16, networkInterface); - -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); - -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -unsigned char uuid[VIR_UUID_BUFLEN]; -vboxIID iid = VBOX_IID_INITIALIZER; - -networkInterface-vtbl-GetId(networkInterface, iid.value); -vboxIIDToUUID(iid, uuid); -ret = virGetNetwork(conn, name, uuid); -VIR_DEBUG(Network Name: %s, name); - -DEBUGIID(Network UUID, iid.value); -vboxIIDUnalloc(iid); -} - -VBOX_RELEASE(networkInterface); -} - -VBOX_UTF16_FREE(nameUtf16); -VBOX_RELEASE(host); - -return ret; -} - -static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start) { VBOX_OBJECT_HOST_CHECK(conn, virNetworkPtr, NULL); @@ -5861,6 +5823,14 @@ _hostFindHostNetworkInterfaceById(IHost *host, vboxIIDUnion *iidu, } static nsresult +_hostFindHostNetworkInterfaceByName(IHost *host, PRUnichar *name, +IHostNetworkInterface **networkInterface) +{ +return host-vtbl-FindHostNetworkInterfaceByName(host, name, + networkInterface); +} + +static nsresult _hnInterfaceGetInterfaceType(IHostNetworkInterface *hni, PRUint32 *interfaceType) { return hni-vtbl-GetInterfaceType(hni, interfaceType); @@ -5878,6 +5848,12 @@ _hnInterfaceGetName(IHostNetworkInterface *hni, PRUnichar **name) return hni-vtbl-GetName(hni, name); } +static nsresult +_hnInterfaceGetId(IHostNetworkInterface *hni, vboxIIDUnion *iidu) +{ +return hni-vtbl-GetId(hni, IID_MEMBER(value)); +} + static bool _machineStateOnline(PRUint32 state) { return ((state = MachineState_FirstOnline) @@ -6183,12 +6159,14 @@ static vboxUniformedIDisplay _UIDisplay = { static vboxUniformedIHost _UIHost = { .FindHostNetworkInterfaceById = _hostFindHostNetworkInterfaceById, +.FindHostNetworkInterfaceByName = _hostFindHostNetworkInterfaceByName, }; static vboxUniformedIHNInterface _UIHNInterface = { .GetInterfaceType = _hnInterfaceGetInterfaceType, .GetStatus = _hnInterfaceGetStatus, .GetName = _hnInterfaceGetName, +.GetId = _hnInterfaceGetId, }; static uniformedMachineStateChecker _machineStateChecker = { diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 2e0eb10..a14ee1c
[libvirt] [PATCH v3 13/14] vbox: Rewrite vboxNetworkGetXMLDesc
--- src/vbox/vbox_network.c | 191 + src/vbox/vbox_tmpl.c | 235 + src/vbox/vbox_uniformed_api.h |8 ++ 3 files changed, 248 insertions(+), 186 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 2fc8230..b4453a6 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -806,3 +806,194 @@ int vboxNetworkCreate(virNetworkPtr network) VIR_FREE(networkNameUtf8); return ret; } + +static int +vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16, + virSocketAddrPtr addr) +{ +int result = -1; +char *utf8 = NULL; + +VBOX_UTF16_TO_UTF8(utf16, utf8); + +if (virSocketAddrParse(addr, utf8, AF_UNSPEC) 0) { +goto cleanup; +} + +result = 0; + + cleanup: +VBOX_UTF8_FREE(utf8); + +return result; +} + +char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) +{ +vboxGlobalData *data = network-conn-privateData; +virNetworkDefPtr def = NULL; +virNetworkIpDefPtr ipdef = NULL; +char *networkNameUtf8 = NULL; +PRUnichar *networkInterfaceNameUtf16 = NULL; +IHostNetworkInterface *networkInterface = NULL; +PRUint32 interfaceType = 0; +PRUnichar *networkNameUtf16 = NULL; +IDHCPServer *dhcpServer = NULL; +vboxIIDUnion vboxnet0IID; +IHost *host = NULL; +char *ret = NULL; +nsresult rc; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +VBOX_IID_INITIALIZE(vboxnet0IID); +virCheckFlags(0, NULL); + +if (VIR_ALLOC(def) 0) +goto cleanup; +if (VIR_ALLOC(ipdef) 0) +goto cleanup; +def-ips = ipdef; +def-nips = 1; + +if (virAsprintf(networkNameUtf8, HostInterfaceNetworking-%s, network-name) 0) +goto cleanup; + +VBOX_UTF8_TO_UTF16(network-name, networkInterfaceNameUtf16); + +gVBoxAPI.UIHost.FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16, networkInterface); + +if (!networkInterface) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +goto cleanup; + +if (VIR_STRDUP(def-name, network-name) 0) +goto cleanup; + +rc = gVBoxAPI.UIHNInterface.GetId(networkInterface, vboxnet0IID); +if (NS_FAILED(rc)) +goto cleanup; +vboxIIDToUUID(vboxnet0IID, def-uuid); + +VBOX_UTF8_TO_UTF16(networkNameUtf8, networkNameUtf16); + +def-forward.type = VIR_NETWORK_FORWARD_NONE; + +gVBoxAPI.UIVirtualBox.FindDHCPServerByNetworkName(data-vboxObj, + networkNameUtf16, + dhcpServer); +if (dhcpServer) { +ipdef-nranges = 1; +if (VIR_ALLOC_N(ipdef-ranges, ipdef-nranges) = 0) { +PRUnichar *ipAddressUtf16 = NULL; +PRUnichar *networkMaskUtf16 = NULL; +PRUnichar *fromIPAddressUtf16 = NULL; +PRUnichar *toIPAddressUtf16 = NULL; +bool errorOccurred = false; + +gVBoxAPI.UIDHCPServer.GetIPAddress(dhcpServer, ipAddressUtf16); +gVBoxAPI.UIDHCPServer.GetNetworkMask(dhcpServer, networkMaskUtf16); +gVBoxAPI.UIDHCPServer.GetLowerIP(dhcpServer, fromIPAddressUtf16); +gVBoxAPI.UIDHCPServer.GetUpperIP(dhcpServer, toIPAddressUtf16); +/* Currently virtualbox supports only one dhcp server per network + * with contigious address space from start to end + */ +if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, + ipdef-address) 0 || +vboxSocketParseAddrUtf16(data, networkMaskUtf16, + ipdef-netmask) 0 || +vboxSocketParseAddrUtf16(data, fromIPAddressUtf16, + ipdef-ranges[0].start) 0 || +vboxSocketParseAddrUtf16(data, toIPAddressUtf16, + ipdef-ranges[0].end) 0) { +errorOccurred = true; +} + +VBOX_UTF16_FREE(ipAddressUtf16); +VBOX_UTF16_FREE(networkMaskUtf16); +VBOX_UTF16_FREE(fromIPAddressUtf16); +VBOX_UTF16_FREE(toIPAddressUtf16); + +if (errorOccurred) { +goto cleanup; +} +} else { +ipdef-nranges = 0; +} + +ipdef-nhosts = 1; +if (VIR_ALLOC_N(ipdef-hosts, ipdef-nhosts) = 0) { +if (VIR_STRDUP(ipdef-hosts[0].name, network-name) 0) { +VIR_FREE(ipdef-hosts); +ipdef-nhosts = 0; +} else { +PRUnichar *macAddressUtf16 = NULL; +PRUnichar *ipAddressUtf16 =
[libvirt] [PATCH v3 08/14] vbox: Rewrite vboxNetworkLookupByUUID
--- src/vbox/vbox_network.c | 65 + src/vbox/vbox_tmpl.c | 57 +--- src/vbox/vbox_uniformed_api.h |8 + 3 files changed, 86 insertions(+), 44 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 6d2ecdc..0405265 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -59,6 +59,19 @@ VIR_LOG_INIT(vbox.vbox_network); } \ } while (0) +#define vboxIIDUnalloc(iid) gVBoxAPI.UIID.vboxIIDUnalloc(data, iid) +#define vboxIIDToUUID(iid, uuid) gVBoxAPI.UIID.vboxIIDToUUID(data, iid, uuid) +#define vboxIIDFromUUID(iid, uuid) gVBoxAPI.UIID.vboxIIDFromUUID(data, iid, uuid) +#define vboxIIDIsEqual(iid1, iid2) gVBoxAPI.UIID.vboxIIDIsEqual(data, iid1, iid2) +#define DEBUGIID(msg, iid) gVBoxAPI.UIID.DEBUGIID(msg, iid) +#define vboxIIDFromArrayItem(iid, array, idx) \ +gVBoxAPI.UIID.vboxIIDFromArrayItem(data, iid, array, idx) + +#define VBOX_IID_INITIALIZE(iid) gVBoxAPI.UIID.vboxIIDInitialize(iid) + +#define ARRAY_GET_MACHINES \ +(gVBoxAPI.UArray.handleGetMachines(data-vboxObj)) + static vboxUniformedAPI gVBoxAPI; /** @@ -297,3 +310,55 @@ int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int n return ret; } + +virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) +{ +vboxGlobalData *data = conn-privateData; +PRUint32 interfaceType = 0; +char *nameUtf8 = NULL; +PRUnichar *nameUtf16 = NULL; +IHostNetworkInterface *networkInterface = NULL; +vboxIIDUnion iid; +IHost *host = NULL; +virNetworkPtr ret = NULL; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +VBOX_IID_INITIALIZE(iid); +vboxIIDFromUUID(iid, uuid); + +/* TODO: internal networks are just strings and + * thus can't do much with them + */ + +gVBoxAPI.UIHost.FindHostNetworkInterfaceById(host, iid, + networkInterface); +if (!networkInterface) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, interfaceType); + +if (interfaceType != HostNetworkInterfaceType_HostOnly) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetName(networkInterface, nameUtf16); +VBOX_UTF16_TO_UTF8(nameUtf16, nameUtf8); + +ret = virGetNetwork(conn, nameUtf8, uuid); + +VIR_DEBUG(Network Name: %s, nameUtf8); +DEBUGIID(Network UUID, iid); +VBOX_UTF8_FREE(nameUtf8); +VBOX_UTF16_FREE(nameUtf16); + + cleanup: +VBOX_RELEASE(networkInterface); +VBOX_RELEASE(host); +vboxIIDUnalloc(iid); +return ret; +} diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index ed75656..8675182 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2061,50 +2061,6 @@ _registerDomainEvent(virDriverPtr driver) */ static virNetworkPtr -vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) -{ -VBOX_OBJECT_HOST_CHECK(conn, virNetworkPtr, NULL); -vboxIID iid = VBOX_IID_INITIALIZER; - -vboxIIDFromUUID(iid, uuid); - -/* TODO: internal networks are just strings and - * thus can't do much with them - */ -IHostNetworkInterface *networkInterface = NULL; - -host-vtbl-FindHostNetworkInterfaceById(host, iid.value, networkInterface); -if (networkInterface) { -PRUint32 interfaceType = 0; - -networkInterface-vtbl-GetInterfaceType(networkInterface, interfaceType); - -if (interfaceType == HostNetworkInterfaceType_HostOnly) { -char *nameUtf8 = NULL; -PRUnichar *nameUtf16 = NULL; - -networkInterface-vtbl-GetName(networkInterface, nameUtf16); -VBOX_UTF16_TO_UTF8(nameUtf16, nameUtf8); - -ret = virGetNetwork(conn, nameUtf8, uuid); - -VIR_DEBUG(Network Name: %s, nameUtf8); -DEBUGIID(Network UUID, iid.value); - -VBOX_UTF8_FREE(nameUtf8); -VBOX_UTF16_FREE(nameUtf16); -} - -VBOX_RELEASE(networkInterface); -} - -VBOX_RELEASE(host); - -vboxIIDUnalloc(iid); -return ret; -} - -static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *name) { VBOX_OBJECT_HOST_CHECK(conn, virNetworkPtr, NULL); @@ -5897,6 +5853,14 @@ _displayTakeScreenShotPNGToArray(IDisplay *display ATTRIBUTE_UNUSED, } static nsresult +_hostFindHostNetworkInterfaceById(IHost *host, vboxIIDUnion *iidu, + IHostNetworkInterface **networkInterface) +{ +return host-vtbl-FindHostNetworkInterfaceById(host, IID_MEMBER(value), +networkInterface); +} + +static
[libvirt] [PATCH v3 14/14] vbox: New network driver
This patch seperate the domain driver and the network driver. libvirt_driver_vbox_impl.la has been linked in the network driver. So that the version specified codes in vbox_V*.c would only be compiled once. The vboxGetNetworkDriver provides a simple interface to get vbox network driver. --- src/Makefile.am | 11 -- src/vbox/vbox_driver.c|9 +++-- src/vbox/vbox_get_driver.h|1 + src/vbox/vbox_network.c | 83 + src/vbox/vbox_tmpl.c | 18 - src/vbox/vbox_uniformed_api.h | 16 6 files changed, 82 insertions(+), 56 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 34eb9f8..5e8cd4a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -519,6 +519,7 @@ DRIVER_SOURCE_FILES = \ $(TEST_DRIVER_SOURCES) \ $(UML_DRIVER_SOURCES) \ $(VBOX_DRIVER_SOURCES) \ + $(VBOX_NETWORK_DRIVER_SOURCES) \ vbox/vbox_tmpl.c \ $(VMWARE_DRIVER_SOURCES) \ $(XEN_DRIVER_SOURCES) \ @@ -678,10 +679,13 @@ VBOX_DRIVER_SOURCES = \ vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \ vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \ vbox/vbox_common.c vbox/vbox_common.h \ - vbox/vbox_network.c \ vbox/vbox_uniformed_api.h \ vbox/vbox_get_driver.h +VBOX_NETWORK_DRIVER_SOURCES = \ + vbox/vbox_driver.c vbox/vbox_driver.h \ + vbox/vbox_network.c vbox/vbox_get_driver.h + VBOX_DRIVER_EXTRA_DIST = \ vbox/vbox_tmpl.c vbox/README\ vbox/vbox_MSCOMGlue.c vbox/vbox_MSCOMGlue.h \ @@ -1186,8 +1190,9 @@ libvirt_driver_vbox_network_impl_la_CFLAGS = \ libvirt_driver_vbox_network_impl_la_LDFLAGS = $(AM_LDFLAGS) libvirt_driver_vbox_network_impl_la_LIBADD = $(DLOPEN_LIBS)\ $(MSCOM_LIBS) \ - $(LIBXML_LIBS) -libvirt_driver_vbox_network_impl_la_SOURCES = $(VBOX_DRIVER_SOURCES) + $(LIBXML_LIBS) \ + libvirt_driver_vbox_impl.la +libvirt_driver_vbox_network_impl_la_SOURCES = $(VBOX_NETWORK_DRIVER_SOURCES) libvirt_driver_vbox_storage_impl_la_CFLAGS = \ -I$(top_srcdir)/src/conf\ diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 89d49be..7d7214a 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -71,7 +71,7 @@ extern virStorageDriver vbox43_4StorageDriver; #define VIR_FROM_THIS VIR_FROM_VBOX -#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER) || defined(VBOX_STORAGE_DRIVER) +#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_STORAGE_DRIVER) static void vboxGetDrivers(virDriverPtr *driver_ret, virNetworkDriverPtr *networkDriver_ret, @@ -161,9 +161,12 @@ vboxGetDrivers(virDriverPtr *driver_ret, #if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER) int vboxNetworkRegister(void) { -virNetworkDriverPtr networkDriver; +virNetworkDriverPtr networkDriver = NULL; +uint32_t uVersion; + +if (VBoxCGlueInit(uVersion) == 0) +networkDriver = vboxGetNetworkDriver(uVersion); -vboxGetDrivers(NULL, networkDriver, NULL); if (virRegisterNetworkDriver(networkDriver) 0) return -1; return 0; diff --git a/src/vbox/vbox_get_driver.h b/src/vbox/vbox_get_driver.h index cfc8b93..a31f10c 100644 --- a/src/vbox/vbox_get_driver.h +++ b/src/vbox/vbox_get_driver.h @@ -22,5 +22,6 @@ # include internal.h virDriverPtr vboxGetDriver(uint32_t uVersion); +virNetworkDriverPtr vboxGetNetworkDriver(uint32_t uVersion); #endif /* VBOX_GET_DRIVER_H */ diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index b4453a6..35bf833 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -29,6 +29,7 @@ #include vbox_common.h #include vbox_uniformed_api.h +#include vbox_get_driver.h #define VIR_FROM_THIS VIR_FROM_VBOX @@ -83,9 +84,10 @@ static vboxUniformedAPI gVBoxAPI; * The Network Functions here on */ -virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) +static virDrvOpenStatus +vboxNetworkOpen(virConnectPtr conn, +virConnectAuthPtr auth ATTRIBUTE_UNUSED, +unsigned int flags) { vboxGlobalData *data = conn-privateData; @@ -105,14 +107,14 @@ virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn, return VIR_DRV_OPEN_DECLINED; } -int vboxNetworkClose(virConnectPtr conn) +static int vboxNetworkClose(virConnectPtr conn) { VIR_DEBUG(network uninitialized);
[libvirt] [PATCH v3 10/14] vbox: Rewrite vboxNetworkDefineCreateXML
This patch actually contains two public API, virNetworkDefineXML and virNetworkCreateXML. They use the same core function vboxNetworkDefineCreateXML. So I merged it together. --- src/vbox/vbox_common.h|1 + src/vbox/vbox_network.c | 214 + src/vbox/vbox_tmpl.c | 351 ++--- src/vbox/vbox_uniformed_api.h | 22 +++ 4 files changed, 352 insertions(+), 236 deletions(-) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 9f5385b..76288d4 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -317,5 +317,6 @@ typedef nsISupports ISnapshot; typedef nsISupports IDisplay; typedef nsISupports IHost; typedef nsISupports IHostNetworkInterface; +typedef nsISupports IDHCPServer; #endif /* VBOX_COMMON_H */ diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index f0fa4f4..feecf0c 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -24,6 +24,8 @@ #include domain_event.h #include virlog.h #include virstring.h +#include viralloc.h +#include network_conf.h #include vbox_common.h #include vbox_uniformed_api.h @@ -411,3 +413,215 @@ virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *name) VBOX_RELEASE(host); return ret; } + +static PRUnichar * +vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) +{ +char *utf8 = NULL; +PRUnichar *utf16 = NULL; + +utf8 = virSocketAddrFormat(addr); + +if (utf8 == NULL) { +return NULL; +} + +VBOX_UTF8_TO_UTF16(utf8, utf16); +VIR_FREE(utf8); + +return utf16; +} + +static virNetworkPtr +vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start) +{ +vboxGlobalData *data = conn-privateData; +PRUnichar *networkInterfaceNameUtf16 = NULL; +char *networkInterfaceNameUtf8 = NULL; +PRUnichar *networkNameUtf16 = NULL; +char *networkNameUtf8 = NULL; +IHostNetworkInterface *networkInterface = NULL; +virNetworkDefPtr def = virNetworkDefParseString(xml); +virNetworkIpDefPtr ipdef = NULL; +unsigned char uuid[VIR_UUID_BUFLEN]; +vboxIIDUnion vboxnetiid; +virSocketAddr netmask; +IHost *host = NULL; +virNetworkPtr ret = NULL; +nsresult rc; + +if (!data-vboxObj) +return ret; + +gVBoxAPI.UIVirtualBox.GetHost(data-vboxObj, host); +if (!host) +return ret; + +VBOX_IID_INITIALIZE(vboxnetiid); + +if ((!def) || +(def-forward.type != VIR_NETWORK_FORWARD_NONE) || +(def-nips == 0 || !def-ips)) +goto cleanup; + +/* Look for the first IPv4 IP address definition and use that. + * If there weren't any IPv4 addresses, ignore the network (since it's + * required below to have an IPv4 address) +*/ +ipdef = virNetworkDefGetIpByIndex(def, AF_INET, 0); +if (!ipdef) +goto cleanup; + +if (virNetworkIpDefNetmask(ipdef, netmask) 0) +goto cleanup; + +/* the current limitation of hostonly network is that you can't + * assign a name to it and it defaults to vboxnet*, for e.g: + * vboxnet0, vboxnet1, etc. Also the UUID is assigned to it + * automatically depending on the mac address and thus both + * these paramters are ignored here for now. + * + * If the vbox is in 2.x and the def-name not equal to vboxnet0, + * the function call will fail and the networkInterface set to + * NULL. (We can't assign a new name to hostonly network, only + * take the given name, say vboxnet0) + */ +gVBoxAPI.UIHost.CreateHostOnlyNetworkInterface(data, host, def-name, + networkInterface); + +if (!networkInterface) +goto cleanup; + +gVBoxAPI.UIHNInterface.GetName(networkInterface, networkInterfaceNameUtf16); +if (!networkInterfaceNameUtf16) +goto cleanup; + +VBOX_UTF16_TO_UTF8(networkInterfaceNameUtf16, networkInterfaceNameUtf8); + +if (virAsprintf(networkNameUtf8, HostInterfaceNetworking-%s, networkInterfaceNameUtf8) 0) +goto cleanup; + +VBOX_UTF8_TO_UTF16(networkNameUtf8, networkNameUtf16); + +/* Currently support only one dhcp server per network + * with contigious address space from start to end + */ +if ((ipdef-nranges = 1) +VIR_SOCKET_ADDR_VALID(ipdef-ranges[0].start) +VIR_SOCKET_ADDR_VALID(ipdef-ranges[0].end)) { +IDHCPServer *dhcpServer = NULL; + +gVBoxAPI.UIVirtualBox.FindDHCPServerByNetworkName(data-vboxObj, + networkNameUtf16, + dhcpServer); +if (!dhcpServer) { +/* create a dhcp server */ +gVBoxAPI.UIVirtualBox.CreateDHCPServer(data-vboxObj, + networkNameUtf16, + dhcpServer); +
[libvirt] [PATCH] build: fix build on non-Linux
A cygwin build of 1.2.9 fails with: util/virprocess.c:87:27: fatal error: sys/syscall.h: No such file or directory # include sys/syscall.h But in reality, the ONLY user of setns() is lxc, which is Linux-only. It's easiest to just limit the setns workarounds to Linux. * src/util/virprocess.c (setns): Limit definition to Linux. Signed-off-by: Eric Blake ebl...@redhat.com --- Pushing under the build-breaker rule. src/util/virprocess.c | 44 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 806e7f9..486123a 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -61,44 +61,48 @@ VIR_LOG_INIT(util.process); +#ifdef __linux__ /* * Workaround older glibc. While kernel may support the setns * syscall, the glibc wrapper might not exist. If that's the * case, use our own. */ -#ifndef __NR_setns -# if defined(__x86_64__) -# define __NR_setns 308 -# elif defined(__i386__) -# define __NR_setns 346 -# elif defined(__arm__) -# define __NR_setns 375 -# elif defined(__aarch64__) -# define __NR_setns 375 -# elif defined(__powerpc__) -# define __NR_setns 350 -# elif defined(__s390__) -# define __NR_setns 339 +# ifndef __NR_setns +# if defined(__x86_64__) +# define __NR_setns 308 +# elif defined(__i386__) +# define __NR_setns 346 +# elif defined(__arm__) +# define __NR_setns 375 +# elif defined(__aarch64__) +# define __NR_setns 375 +# elif defined(__powerpc__) +# define __NR_setns 350 +# elif defined(__s390__) +# define __NR_setns 339 +# endif # endif -#endif -#ifndef HAVE_SETNS -# if defined(__NR_setns) !defined(WIN32) -# include sys/syscall.h +# ifndef HAVE_SETNS +# if defined(__NR_setns) +# include sys/syscall.h static inline int setns(int fd, int nstype) { return syscall(__NR_setns, fd, nstype); } -# else /* __NR_setns !WIN32 */ +# else /* !__NR_setns */ +# error Please determine the syscall number for setns on your architecture +# endif +# endif +#else /* !__linux__ */ static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED) { virReportSystemError(ENOSYS, %s, _(Namespaces are not supported on this platform.)); return -1; } -# endif /* __NR_setns !WIN32 */ -#endif /* HAVE_SETNS */ +#endif /** * virProcessTranslateStatus: -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] increase number of libvirt threads by starting tansient guest doamin - is it a bug?
web2 wrote: Hi ursprüngliche Nachricht- Von: Michal Privoznik mpriv...@redhat.com An: web2 usterman...@web.de , libvirt-users redhat.com , libvirt-list redhat.com Datum: Wed, 01 Oct 2014 18:12:45 +0200 - On 01.10.2014 10:31, web2 wrote: Hello, sorry for my later answer. so, after i started libvirtd (no vm´s running) and attach gdb i get the following threads (gdb) info thread Id Target Id Frame 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i restore an persistent domain, i see the following in gdb: Detaching after fork from child process 20880. Detaching after fork from child process 20882. [New Thread 0x7f190893d700 (LWP 20883)] Detaching after fork from child process 20890. Detaching after fork from child process 20906. (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 7 Thread 0x7f18fcf4a700 (LWP 20699) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 6 Thread 0x7f18fc749700 (LWP 20700) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 5 Thread 0x7f18fbf48700 (LWP 20701) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 4 Thread 0x7f18fb747700 (LWP 20702) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 3 Thread 0x7f18faf46700 (LWP 20703) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 2 Thread 0x7f18fa745700 (LWP 20704) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 * 1 Thread 0x7f190892f840 (LWP 20694) libvirtd 0x7f190677d7cd in poll () at ../sysdeps/unix/syscall-template.S:81 if i now destroy this vm i get the following: (gdb) info thread Id Target Id Frame 12 Thread 0x7f190893d700 (LWP 20883) libvirtd 0x7f1906e6684d in read () at ../sysdeps/unix/syscall-template.S:81 11 Thread 0x7f18fef4e700 (LWP 20695) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 10 Thread 0x7f18fe74d700 (LWP 20696) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 9 Thread 0x7f18fdf4c700 (LWP 20697) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 8 Thread 0x7f18fd74b700 (LWP 20698) libvirtd pthread_cond_wait@@GLIBC_2.3.2 () at
Re: [libvirt] [PATCH] Make editor used for 'virsh edit' configurable
On Mon, Sep 29, 2014 at 09:47:08AM +0200, Martin Kletzander wrote: On Sun, Sep 28, 2014 at 10:35:52AM +0200, Guido Günther wrote: Debian wants to use 'sensible-editor' instead of vi other distros might want to use other defaults. This avoids distro specific patches. --- configure.ac | 9 + tools/virsh.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) ACK after freeze, Pushed. Thanks, -- Guido -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: use systemd's TerminateMachine to kill all processes
On Tue, Sep 30, 2014 at 03:22:41PM +0100, Daniel P. Berrange wrote: On Tue, Sep 30, 2014 at 10:10:51AM -0400, Cole Robinson wrote: On 09/25/2014 08:30 AM, Guido Günther wrote: If we don't properly clean up all processes in the machine-vmname.scope systemd won't remove the cgroup and subsequent vm starts fail with 'CreateMachine: File exists' Additional processes can e.g. be added via echo $PID /sys/fs/cgroup/systemd/machine.slice/machine-${VMNAME}.scope/tasks but there are other cases like http://bugs.debian.org/761521 Invoke TerminateMachine to be on the safe side since systemd tracks the cgroup anyway. This is a noop if all processes have terminated already. Thanks for the patch, I've definitely seen this a handful of times on Fedora as well. --- src/libvirt_private.syms | 1 + src/qemu/qemu_cgroup.c | 11 ++- src/qemu/qemu_cgroup.h | 2 +- src/qemu/qemu_process.c | 4 ++-- src/util/vircgroup.c | 11 +++ src/util/vircgroup.h | 5 + 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 51a692b..99ef1db 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1115,6 +1115,7 @@ virCgroupSetMemorySoftLimit; virCgroupSetMemSwapHardLimit; virCgroupSetOwner; virCgroupSupportsCpuBW; +virCgroupTerminateMachine; # util/virclosecallbacks.h diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 7c6b2c1..0ab7227 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -1188,13 +1188,22 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm) } int -qemuRemoveCgroup(virDomainObjPtr vm) +qemuRemoveCgroup(virQEMUDriverPtr driver, + virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm-privateData; +virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); if (priv-cgroup == NULL) return 0; /* Not supported, so claim success */ +if (virCgroupTerminateMachine(vm-def-name, + qemu, + cfg-privileged) 0) { +if (!virCgroupNewIgnoreError()) +VIR_DEBUG(Failed to terminate cgroup for %s, vm-def-name); +} + return virCgroupRemove(priv-cgroup); } diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h index 8a2c723..4a4f22c 100644 --- a/src/qemu/qemu_cgroup.h +++ b/src/qemu/qemu_cgroup.h @@ -66,7 +66,7 @@ int qemuSetupCgroupForIOThreads(virDomainObjPtr vm); int qemuSetupCgroupForEmulator(virQEMUDriverPtr driver, virDomainObjPtr vm, virBitmapPtr nodemask); -int qemuRemoveCgroup(virDomainObjPtr vm); +int qemuRemoveCgroup(virQEMUDriverPtr driver, virDomainObjPtr vm); int qemuAddToCgroup(virDomainObjPtr vm); #endif /* __QEMU_CGROUP_H__ */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 13614e9..e7cce1a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4131,7 +4131,7 @@ int qemuProcessStart(virConnectPtr conn, /* Ensure no historical cgroup for this VM is lying around bogus * settings */ VIR_DEBUG(Ensuring no historical cgroup is lying around); -qemuRemoveCgroup(vm); +qemuRemoveCgroup(driver, vm); for (i = 0; i vm-def-ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm-def-graphics[i]; @@ -4909,7 +4909,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, } retry: -if ((ret = qemuRemoveCgroup(vm)) 0) { +if ((ret = qemuRemoveCgroup(driver, vm)) 0) { if (ret == -EBUSY (retries++ 5)) { usleep(200*1000); goto retry; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 1dbe6f9..d69f71b 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1680,6 +1680,17 @@ virCgroupNewMachineSystemd(const char *name, } +/* + * Returns 0 on success, -1 on fatal error + */ +int virCgroupTerminateMachine(const char *name, + const char *drivername, + bool privileged) +{ +return virSystemdTerminateMachine(name, drivername, privileged); +} + + static int virCgroupNewMachineManual(const char *name, const char *drivername, diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 19e82d1..7718a07 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -106,6 +106,11 @@ int virCgroupNewMachine(const char *name, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); +int