[libvirt] [PATCH] let configure --disable-shared work once again
Per this thread: http://thread.gmane.org/gmane.comp.emulators.libvirt/19672 here's a patch that solves both problems: From 1b330b3070f904dfc1c380151afa3aaf2a121cd3 Mon Sep 17 00:00:00 2001 From: Jim Meyering j...@meyering.net Date: Thu, 7 Jan 2010 21:07:42 +0100 Subject: [PATCH] let configure --disable-shared work once again Without this change, ./autogen.sh --disable-shared make would evoke a can not build a shared library failure for libvirtmod.la. However, without the -shared link option in python/Makefile.am, it was possible to install non-functional python support. Instead, make --disable-shared also disable building python. * configure.ac: Make --disable-shared imply --without-python and silently override --with-python. * python/Makefile.am (libvirtmod_la_LDFLAGS): Do not use -shared. This reverts 8838ee39ab1c2bb7fffe93bfda220692664e8be6. --- configure.in |4 python/Makefile.am |2 +- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index 3f2f8ff..3e98035 100644 --- a/configure.in +++ b/configure.in @@ -1813,6 +1813,10 @@ AC_ARG_WITH([qemu-group], AC_DEFINE_UNQUOTED([QEMU_USER], [$QEMU_USER], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], [$QEMU_GROUP], [QEMU group account]) +if test $enable_shared:$with_python = no:yes; then + AC_MSG_WARN([you've used --disable-shared; so disabling python support]) + with_python=no +fi # Only COPYING.LIB is under version control, yet COPYING # is included as part of the distribution tarball. diff --git a/python/Makefile.am b/python/Makefile.am index 58c6729..04342b7 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -39,7 +39,7 @@ libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c libvirt.c libvirt.h # need extra flags here libvirtmod_la_CFLAGS = @WARN_PYTHON_CFLAGS@ -libvirtmod_la_LDFLAGS = -module -avoid-version -shared -L$(top_builddir)/src/.libs \ +libvirtmod_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/.libs \ @CYGWIN_EXTRA_LDFLAGS@ libvirtmod_la_LIBADD = $(mylibs) \ @CYGWIN_EXTRA_LIBADD@ @CYGWIN_EXTRA_PYTHON_LIBADD@ -- 1.6.6.425.g4dc2d -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] fix build failure with --disable-shared
Diego Elio “Flameeyes” Pettenò wrote: Il giorno gio, 07/01/2010 alle 23.03 +0100, Jim Meyering ha scritto: So your change forced all other users of --disable-shared to also configure with --without-python, but did not inform them of the new constraint. BTW, it also rendered build instructions in the FAQ invalid. I don't want to sound defensive, but I *do* feel attacked a bit here, and I don't think I made any mistake in my patch and suggestion. No attack intended. Merely explaining that your change does indeed disrupt certain workflows. Your change caused inconvenience for at least two developers I know about, and I took it upon myself to resolve the problem. If you had announced that --disable-shared must henceforth always be accompanied by --without-python, then that might have been ok, modulo the FAQ requiring an update. However, with the patch I posted, there's no need to change the FAQ or any habits/scripts. If I did “force” users to configure properly, The trouble is that your change had the undocumented side-effect of forcing people to change their previously-working-for-their-needs scripts. it was because the build system was working on a wrong assumption before. Sorry if I made it known that there is a bug there. Yes, you discovered a bug, and even sent in a patch. I do appreciate that. As for the build instructions, I had to look them up now because I definitely hadn't looked at them; if I did, I would have et you know earlier about the fact that it's a *bad* advice to give. Many programs can be configured with --disable-shared, and most of libvirt is still usable when configured that way. The bug was that the Python code was compiled in that case, and could have ended up being installed. However, do note that people familiar with the distribution guidelines warning against installing statically-linked libraries would know to avoid installing anything they had built that way. Why? Because I guess quite a few people interested in using libvirt would also be using virt-manager (especially since Daniel said that the XML files are not designed for user to edit, but for software to mangle) and that only works with proper Python bindings — and they are not generated with the suggested syntax in the FAQ. It actually can create quite a bad thing if the user tries to be smart and install the CVS (CVS? I thought it was developed in GIT) versions with make install after the configure, as the bindings and the virsh/libvirtd executables will be using very different libraries. Do I ask too much if next time, rather than noticing by chance that somebody wants to revert a change I proposed, you would reply to my own posting (which I watch more closely), letting me know it broke something? I'm pretty sure I can fix up things from there myself. I've learned that it is usually more efficient to propose a patch than to request one. I proposed to revert your change, because from my perspective it was obviously wrong. At the same time, I requested more information, because I assumed the change must have had more motivation than I could find in the mailing list and commit log. My proposing to revert your patch should not be taken as an insult or an offense, but rather as part of a request for additional justification. Once I had that, I was able to write a patch that solved both our problems. Just posted separately. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] look for DMI information in /sys/class too
Hi, attached patch looks for the DMI information in /sys/class since older kernels (e.g. 2.6.26) have it there. Cheers, -- Guido From: =?UTF-8?q?Guido=20G=C3=BCnther?= a...@sigxcpu.org Date: Thu, 7 Jan 2010 10:13:51 +0100 Subject: [PATCH] Also look for dmi information in /sys/class older kernels such as 2.6.26 have it there. --- src/node_device/node_device_udev.c |7 ++- src/node_device/node_device_udev.h |1 + 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 22c5f2b..7a9c1e5 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1407,7 +1407,12 @@ static int udevSetupSystemDev(void) device = udev_device_new_from_syspath(udev, DMI_DEVPATH); if (device == NULL) { VIR_ERROR(Failed to get udev device for syspath '%s'\n, DMI_DEVPATH); -goto out; + +device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); +if (device == NULL) { +VIR_ERROR(Failed to get udev device for syspath '%s'\n, DMI_DEVPATH_FALLBACK); +goto out; +} } data = def-caps-data; diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index 0fd39ae..6c83412 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -26,6 +26,7 @@ #define SYSFS_DATA_SIZE 4096 #define DRV_STATE_UDEV_MONITOR(ds) ((struct udev_monitor *)((ds)-privateData)) #define DMI_DEVPATH /sys/devices/virtual/dmi/id +#define DMI_DEVPATH_FALLBACK /sys/class/dmi/id #define PROPERTY_FOUND 0 #define PROPERTY_MISSING 1 #define PROPERTY_ERROR -1 -- -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] DNAT, bridge, iptables and network
Manao ahoana, Hello, Bonjour, My server has 3 public IPs: IP1, IP2, IP3. I intend to create 3 bridges: virbr1, virbr2, virbr3. Each bridge will NAT from 3 to 5 KVM guests. About IP1: I would like incoming connexion on IP1 to: - IP1:80 to be DNAT'd to one virbr1 VM, specialized on HTTP - IP1:3306 to be DNAT'd to another virbr1 VM, specialized on MySQL - IP1:53 to be DNAT'd to another virbr1 VM, specialized on DNS Same about IP2 and IP3. Should I assign a public IP address to each brdige? I think no because there will be a problem of network segment: -- What range will I give to the guests? I think my only solution is to give private IPs (192.168.X.X) to the brigdes (3 separate subnets), and use iptables with something like: iptables -t nat -A PREROUTING -p tcp -m tcp -d $IP1 --dport 80 \ -j DNAT --to-destination $VIRBR1_HTTP_GUEST iptables -t nat -A PREROUTING -p tcp -m tcp -d $IP1 --dport 3306 \ -j DNAT --to-destination $VIRBR1_MySQL_GUEST iptables -t nat -A PREROUTING -p udp -d $IP1 --dport 53 \ -j DNAT --to-destination $VIRBR1_DNS_GUEST Should be alright? More informations: I use Ubuntu 9.10 Misaotra, Thanks, Merci. -- Architecte Informatique chez Blueline/Gulfsat: Administration Systeme, Recherche Developpement +261 34 29 155 34 / +261 33 11 207 36 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Replace old CVS references with GIT
On Fri, Jan 08, 2010 at 01:45:12AM +0100, Matthias Bolte wrote: --- HACKING |6 +++--- docs/FAQ.html.in|2 +- docs/bugs.html.in |6 +++--- docs/contact.html.in|4 ++-- docs/deployment.html.in |4 ++-- docs/hacking.html.in|6 +++--- src/Makefile.am |2 +- 7 files changed, 15 insertions(+), 15 deletions(-) ACK, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
On Fri, Jan 08, 2010 at 09:05:25AM +0100, Jim Meyering wrote: Per this thread: http://thread.gmane.org/gmane.comp.emulators.libvirt/19672 here's a patch that solves both problems: From 1b330b3070f904dfc1c380151afa3aaf2a121cd3 Mon Sep 17 00:00:00 2001 From: Jim Meyering j...@meyering.net Date: Thu, 7 Jan 2010 21:07:42 +0100 Subject: [PATCH] let configure --disable-shared work once again Without this change, ./autogen.sh --disable-shared make would evoke a can not build a shared library failure for libvirtmod.la. However, without the -shared link option in python/Makefile.am, it was possible to install non-functional python support. Instead, make --disable-shared also disable building python. * configure.ac: Make --disable-shared imply --without-python and configure.in actually silently override --with-python. Looks fine * python/Makefile.am (libvirtmod_la_LDFLAGS): Do not use -shared. This reverts 8838ee39ab1c2bb7fffe93bfda220692664e8be6. I still don't understand why this need to be reverted. With the configure.in change, then ./autogen.sh --disable-shared make should not try to build the python shared lib configure.in |4 python/Makefile.am |2 +- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index 3f2f8ff..3e98035 100644 --- a/configure.in +++ b/configure.in @@ -1813,6 +1813,10 @@ AC_ARG_WITH([qemu-group], AC_DEFINE_UNQUOTED([QEMU_USER], [$QEMU_USER], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], [$QEMU_GROUP], [QEMU group account]) +if test $enable_shared:$with_python = no:yes; then + AC_MSG_WARN([you've used --disable-shared; so disabling python support]) + with_python=no +fi # Only COPYING.LIB is under version control, yet COPYING # is included as part of the distribution tarball. Seems to me just that part is sufficient, no ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] look for DMI information in /sys/class too
On Fri, Jan 08, 2010 at 09:35:36AM +0100, Guido Günther wrote: Hi, attached patch looks for the DMI information in /sys/class since older kernels (e.g. 2.6.26) have it there. Cheers, -- Guido From: =?UTF-8?q?Guido=20G=C3=BCnther?= a...@sigxcpu.org Date: Thu, 7 Jan 2010 10:13:51 +0100 Subject: [PATCH] Also look for dmi information in /sys/class older kernels such as 2.6.26 have it there. --- src/node_device/node_device_udev.c |7 ++- src/node_device/node_device_udev.h |1 + 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 22c5f2b..7a9c1e5 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1407,7 +1407,12 @@ static int udevSetupSystemDev(void) device = udev_device_new_from_syspath(udev, DMI_DEVPATH); if (device == NULL) { VIR_ERROR(Failed to get udev device for syspath '%s'\n, DMI_DEVPATH); -goto out; + +device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); +if (device == NULL) { +VIR_ERROR(Failed to get udev device for syspath '%s'\n, DMI_DEVPATH_FALLBACK); +goto out; +} } data = def-caps-data; diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index 0fd39ae..6c83412 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -26,6 +26,7 @@ #define SYSFS_DATA_SIZE 4096 #define DRV_STATE_UDEV_MONITOR(ds) ((struct udev_monitor *)((ds)-privateData)) #define DMI_DEVPATH /sys/devices/virtual/dmi/id +#define DMI_DEVPATH_FALLBACK /sys/class/dmi/id #define PROPERTY_FOUND 0 #define PROPERTY_MISSING 1 #define PROPERTY_ERROR -1 -- Looks safe to me, assuming the kernel information are exported in the same way, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
Il giorno ven, 08/01/2010 alle 09.05 +0100, Jim Meyering ha scritto: * python/Makefile.am (libvirtmod_la_LDFLAGS): Do not use -shared. This reverts 8838ee39ab1c2bb7fffe93bfda220692664e8be6. Not really necessary at this point. -- Diego Elio Pettenò — “Flameeyes” http://blog.flameeyes.eu/ If you found a .asc file in this mail and know not what it is, it's a GnuPG digital signature: http://www.gnupg.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Disallow building Python bindings if shared libraries are disabled.
Patch concept by Jim Meyering j...@meyering.net, moved before the Python testing, and changed the message a bit to explain the problem. --- configure.in |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/configure.in b/configure.in index 3f2f8ff..5275412 100644 --- a/configure.in +++ b/configure.in @@ -1466,6 +1466,11 @@ dnl AC_ARG_WITH([python], [ --with-python Build python bindings (on)],[],[with_python=yes]) +if test $enable_shared:$with_python = no:yes; then + AC_MSG_WARN([Disabling shared libraries is incompatible with building Python extensions.]) + with_python=no +fi + PYTHON_VERSION= PYTHON_INCLUDES= if test $with_python != no ; then -- 1.6.6 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] pci-stub error and MSI-X for KVM guest
On Thu, Jan 07, 2010 at 04:50:03PM -0800, Chris Wright wrote: * Fischer, Anna (anna.fisc...@hp.com) wrote: So, when setting a breakpoint for the exit() call I'm getting a bit closer to figuring where it kills my guest. Thanks, this helps clarify what is happening. Breakpoint 1, exit (status=1) at exit.c:99 99 { Current language: auto The current source language is auto; currently c. (gdb) bt #0 exit (status=1) at exit.c:99 #1 0x00470c6e in assigned_dev_pci_read_config (d=0x259c6f0, address=64, len=4) assigned_dev_pci_read_config(..., 64, 4) ^^ This is a libvirt issue. When you use virt-manager it has libvirtd fork/exec qemu-kvm. libvirtd will drop privileges and run qemu-kvm as user qemu (or perhaps root if you've edited qemu.conf). Regardless of the user, it clears capabilities. Reading PCI config space beyond just the header requires CAP_SYS_ADMIN. The above is reading the first 4 bytes of device dependent config space, and the kernel is returning 0 because qemu doesn't have CAP_SYS_ADMIN. Hmm, libvirt also chown()'s the files in /sys/bus/pci/devices/DEVICE/* to 'qemu' (and sets SELinux context) so that the unprivileged QEMU process can have full read/write access to them. I would have hoped that would avoid the need to have any capabilities like CAP_SYS_ADMIN :-( Basically, this means that device assignment w/ libvirt will break MSI/MSI-X because qemu will never be able to see that the host device has those PCI capabilities. This, in turn, renders VF device assignment useless (since a VF is required to support MSI and/or MSI-X). Granting CAP_SYS_ADMIN for each qemu instance that does device assignment would render the privilege reduction useless (CAP_SYS_ADMIN is the kitchen sink catchall of the Linux capability system). Yeah that's pretty troublesome, even when libvirt runs QEMU as 'root', it will remove all capabilities. Why is the 'CAP_SYS_ADMIN' check there - is it a mistakenly over-zealous permission check that could be removed, just relying on access controls on the sysfs /sys/bus/pci/devices/DEVICE/config file ? Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
Daniel Veillard wrote: ... * configure.ac: Make --disable-shared imply --without-python and configure.in actually Thanks. will adjust. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] don't test res == NULL after we've already dereferenced it
Daniel Veillard wrote: ... However, the point is still valid, so I'll wait for confirmation. This is still about defensive coding, i.e., ensuring that maintenance doesn't violate invariants in harder-to-diagnose ways. If you get a bug report, which would you rather hear? libvirt sometimes segfaults or I get an assertion failure on file.c:999 I guess it's mostly a matter of coding style, I'm not sure it makes such a difference in practice, libvirt output will likely be burried in a log file, unless virsh or similar CLI tool is used. We have only 4 asserts in the code currently, I think it shows that so far we are not relying on it. On one hand this mean calling exit() Is don't use assert libvirt policy? I hope not. and I prefer a good old core dump for debugging than a one line message, Same here, but there are many reasons for which a reporter will be unwilling or unable to provide a core dump. No one hesitates to include the output of a failed assertion in a bug report. on the other hand if you managed to catch that message, well this can help pinpoint if the person reporting has no debugging skills. I think there is pros and cons and that the current status quo is that we don't use asserts but more defensing coding by erroring out when this happen. The best way is not to assert() when we may dereference a NULL pointer but check for NULL at the point where we get that pointer, that's closer to the current code practice of libvirt (or well I expect so :-) and allow useful reporting (we failed to do a given operation) and a graceful error handling without exit'ing. So in general if we think we need an assert somewhere that mean that we failed to do the check at the right place, and I would No. That is not how one should use assert, and certainly not how I proposed to use it. This is not about testing for a user- or system-provokable condition, but rather about testing code invariants. See below. rather not start to get into the practice of just asserting in a zillion place instead of checking at the correct place. So in my opinion, I'm still not fond of assert(), and I would prefer to catch up problem earlier, like parameter checking on function entry points or checking return value for functions producing pointers. In that case, res being NULL means that both answer and request parameters are null after the retry: label, since the two pointers are not modified in the function this should be tested when entering the function, if ((answer == NULL) (request == NULL)) { virProxyError (NULL, VIR_ERR_INVALID_ARG, __FUNCTION__); return -1; } you get the error location, as in the assert but propagate the error back in the stack cleanly instead of exit'ing It is important to distinguish two types of errors: - conditions that may arise due to user input or environment (misbehaving client or server, malformed packet, I/O error, etc.) - internal API abuse, violation of an internal assumption or invariant Using assert is appropriate only in the latter case, for detecting conditions that typically are provoked only by developer-introduced errors. Adding error-handling code like the above is appropriate only in the first case. Somewhat along these lines, we are starting to remove certain types of tests, (e.g., conn == NULL), when conn is always non-NULL. In the case of this patch, request is always non-null, and should probably have the nonnull attribute. New patch appended below. One advantage of using assert is that it usually _reduces_ the maintenance burden (i.e., when skimming the code, you may ignore the assert statement). However, if you add expressions like the above to ensure a condition that will always be true (i.e., that should not be possible to trigger via user input), you *increase* the maintenance burden by adding a test of an always-false condition that is handled as if it *can* sometimes be true. That would increase the WTF/m rate for certain readers. (http://www.osnews.com/story/19266/WTFs_m) Such a test might even trigger new warnings from tools like clang and coverity. Whether we use an assertion in this particular case is not important, but I hope that libvirt adopts a judicious policy on the use of assert. Here's the revised patch, followed by the tiny nonnull-one. (also fixes typos s/ret/res/ in log message) From 2a7fed9238667ff75a6ecd662b663549bc8fb7b5 Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Wed, 6 Jan 2010 12:45:07 +0100 Subject: [PATCH] don't test res == NULL after we've already dereferenced res * src/xen/proxy_internal.c (xenProxyCommand): res is known to be non-NULL at that point, so remove the res == NULL guard. --- src/xen/proxy_internal.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index ec4522b..ee4678a 100644 --- a/src/xen/proxy_internal.c +++
Re: [libvirt] fix build failure with --disable-shared
On Thu, Jan 07, 2010 at 10:23:28PM +0100, Daniel Veillard wrote: On Thu, Jan 07, 2010 at 08:36:25PM +, Daniel P. Berrange wrote: On Thu, Jan 07, 2010 at 09:19:17PM +0100, Diego Elio ???Flameeyes??? Petten? wrote: Il giorno gio, 07/01/2010 alle 21.14 +0100, Jim Meyering ha scritto: The change below reverts 8838ee39ab1c2bb7fffe93bfda220692664e8be6, so Diego, if your goal (with the reverted change) was more than to avoid seemingly-unnecessary work, please tell us what it was. Well, to put it simply: you *cannot* both have the Python extension *and* disable shared libraries. --disable-shared tells libtool not to build any kind of shared object for the project; Python extensions are shared objects _only_. While you could avoid building libvirt.so (and just have libvirt.a) you cannot get Python extensions by just building libvirtmod.a. So basically --disable-shared --with-python would just produce an unusable output without my change, and produce a proper error condition with. Agreed, if we want to support --disable-shared, then we can't pretend that building python works. Either expect the error we already have which is accurate, or make configure forcably disable the whole python build. I assume Jim want to keep --disable-shared as a convenient way to force libtool to generated binaries statically linked which is easier when dealing with gdb. If that's the case what would be nice is to be able to instruct auto*/libtool to build both libraries (where possible) but force linking with static libraries. I have no idea how to do this but that would be an useful option for autogen or configure. What problems do shared libraries cause with GDB - I've never had any trouble with it at all - it 'just works' perfectly picking up any debuginfo packages from things we link against too. The only GDB issues I see are its inability to cope with -O2 optimized code. Or just disable python if --disable-shared is passed that would be fine too I think, I think that is the best option. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Qemu: ask for memory preallocation with large pages
On Thu, Jan 07, 2010 at 05:31:59PM +, Daniel P. Berrange wrote: On Thu, Jan 07, 2010 at 02:53:20PM +0100, Daniel Veillard wrote: The -mem-prealloc flag should be used when using large pages This ensures qemu tries to allocate all required memory immediately, rather than when first used. The latter mode will crash qemu if hugepages aren't available when accessed, while the former should gracefully fallback to non-hugepages. * src/qemu/qemu_conf.c: add -mem-prealloc flag to qemu command line when using large pages ACK, definitely don't want VMs crashing when attempting to page in huge pages which don't exist anymore okay, pushed, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
Il giorno ven, 08/01/2010 alle 12.12 +0100, Jim Meyering ha scritto: Using -shared in python/ would now be a little misleading, since it's useful only when building with --disable-shared, and python/ is no longer built with --disable-shared. Not at all. It was needed to avoid building the static archive. Technically, it need not be reverted, but reverting it is fine, and imho, slightly better, since using -shared there merely encodes the current limitation that statically-linked python libraries are useless. We've already done that via configure, so if ever it's relaxed, there's only one place to modify. Again, no, in the configure you avoid the configuration case where you disable shared and want python. The -shared option tells you *not to build a static copy of that module* since it makes no sense. Please refer to my original link about the option itself: http://www.flameeyes.eu/autotools-mythbuster/libtool/index.html#libtool.plugins.dlopen -- Diego Elio Pettenò — “Flameeyes” http://blog.flameeyes.eu/ If you found a .asc file in this mail and know not what it is, it's a GnuPG digital signature: http://www.gnupg.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] fix build failure with --disable-shared
Il giorno ven, 08/01/2010 alle 11.16 +, Daniel P. Berrange ha scritto: What problems do shared libraries cause with GDB - I've never had any trouble with it at all - it 'just works' perfectly picking up any debuginfo packages from things we link against too. The only GDB issues I see are its inability to cope with -O2 optimized code. I think what they meant is not much related to shared libraries (which works pretty good with gdb) but with the handling of dynamically-linked executables and libtool: launching gdb ./virsh will not work, obviously; you either launch it directly (./.libs/virsh), but most people will forget to set the proper LD_LIBRARY_PATH entries and thus debug the installed copy of the libraries, or you pass through libtool, but most people don't know that. Alas, working around problems in all kind of ways is what brought us the doom that libtool complexity is. -- Diego Elio Pettenò — “Flameeyes” http://blog.flameeyes.eu/ If you found a .asc file in this mail and know not what it is, it's a GnuPG digital signature: http://www.gnupg.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
Diego Elio “Flameeyes” Pettenò wrote: Il giorno ven, 08/01/2010 alle 12.12 +0100, Jim Meyering ha scritto: Using -shared in python/ would now be a little misleading, since it's useful only when building with --disable-shared, and python/ is no longer built with --disable-shared. Not at all. It was needed to avoid building the static archive. Oh, I see what you mean, finally. I had read only the first description of -shared in libtool documentation, and hadn't realized that was only for *compile mode*. There's a slightly different description following that, in the *link mode* options section. Thanks for persevering. Here's the revised patch. From 25dd0609205b28d8ffc2b07873b8abb75f39f2d9 Mon Sep 17 00:00:00 2001 From: Jim Meyering j...@meyering.net Date: Thu, 7 Jan 2010 21:07:42 +0100 Subject: [PATCH] let configure --disable-shared work once again Without this change, ./autogen.sh --disable-shared make would evoke a can not build a shared library failure for libvirtmod.la due to the new use of libtool's -shared link option in python/Makefile.am. Now, --disable-shared also disables building python. * configure.in: Make --disable-shared imply --without-python and silently override --with-python. --- configure.in |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/configure.in b/configure.in index 3f2f8ff..3e98035 100644 --- a/configure.in +++ b/configure.in @@ -1813,6 +1813,10 @@ AC_ARG_WITH([qemu-group], AC_DEFINE_UNQUOTED([QEMU_USER], [$QEMU_USER], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], [$QEMU_GROUP], [QEMU group account]) +if test $enable_shared:$with_python = no:yes; then + AC_MSG_WARN([you've used --disable-shared; so disabling python support]) + with_python=no +fi # Only COPYING.LIB is under version control, yet COPYING # is included as part of the distribution tarball. -- 1.6.6.425.g4dc2d -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
Il giorno ven, 08/01/2010 alle 12.44 +0100, Jim Meyering ha scritto: Oh, I see what you mean, finally. I had read only the first description of -shared in libtool documentation, and hadn't realized that was only for *compile mode*. There's a slightly different description following that, in the *link mode* options section. We all love libtool's black magic and vague documentation ;) Thanks for persevering. Here's the revised patch. If you see I should have sent one some less than an hour ago moving the check further up in the file, so that it does not even spend time to check for Python before disabling it (faster ./configure is a win). -- Diego Elio Pettenò — “Flameeyes” http://blog.flameeyes.eu/ If you found a .asc file in this mail and know not what it is, it's a GnuPG digital signature: http://www.gnupg.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] fix build failure with --disable-shared
On Fri, Jan 08, 2010 at 12:21:44PM +0100, Diego Elio ???Flameeyes??? Petten? wrote: Il giorno ven, 08/01/2010 alle 11.16 +, Daniel P. Berrange ha scritto: What problems do shared libraries cause with GDB - I've never had any trouble with it at all - it 'just works' perfectly picking up any debuginfo packages from things we link against too. The only GDB issues I see are its inability to cope with -O2 optimized code. I think what they meant is not much related to shared libraries (which works pretty good with gdb) but with the handling of dynamically-linked executables and libtool: launching gdb ./virsh will not work, obviously; you either launch it directly (./.libs/virsh), but most people will forget to set the proper LD_LIBRARY_PATH entries and thus debug the installed copy of the libraries, or you pass through libtool, but most people don't know that. Hmm using --disable-shared is really not the right solution to that problem. For people that can't rememver the long libtool command name it is easy to create a wrapper $ cat ~/usr/bin/ltrun #!/bin/sh exec libtool --mode=execute $@ Then you can just do this which isn't hard to remember or type ltrun gdb ./virsh Switching to static build to debug something is craziness, because it can and will change the behaviour of many memory-corruption related problems so that something you see fail with shared library build won't reproduce in the same way with a static build. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] don't test res == NULL after we've already dereferenced it
Daniel P. Berrange wrote: On Thu, Jan 07, 2010 at 11:03:23AM +0100, Daniel Veillard wrote: On Thu, Jan 07, 2010 at 09:37:57AM +0100, Jim Meyering wrote: However, the point is still valid, so I'll wait for confirmation. This is still about defensive coding, i.e., ensuring that maintenance doesn't violate invariants in harder-to-diagnose ways. If you get a bug report, which would you rather hear? libvirt sometimes segfaults or I get an assertion failure on file.c:999 I guess it's mostly a matter of coding style, I'm not sure it makes such a difference in practice, libvirt output will likely be burried in a log file, unless virsh or similar CLI tool is used. We have only 4 asserts in the code currently, I think it shows that so far we are not relying on it. On one hand this mean calling exit() and I prefer a good old core dump for debugging than a one line message, on the other hand if you managed to catch that message, well this can help pinpoint if the person reporting has no debugging skills. I think there is pros and cons and that the current status quo is that we don't use asserts but more defensing coding by erroring out when this happen. The best way is not to assert() when we may dereference a NULL pointer but check for NULL at the point where we get that pointer, that's closer to the current code practice of libvirt (or well I expect so :-) and allow useful reporting (we failed to do a given operation) and a graceful error handling without exit'ing. So in general if we think we need an assert somewhere that mean that we failed to do the check at the right place, and I would rather not start to get into the practice of just asserting in a zillion place instead of checking at the correct place. So in my opinion, I'm still not fond of assert(), and I would prefer to catch up problem earlier, like parameter checking on function entry points or checking return value for functions producing pointers. The other reason for adding assert(), is if the code leading upto a particular point is too complex to reliably understand whether a variable is NULL. I think that applies in this case. I don't think adding an assert() is the right way to deal with that complexity though. I think it is better to make the code clearer/easier to follow understand I agree and have looked at the code in question (the somewhat duplicated if/else blocks in proxy_internal.c lines 385-443) http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/xen/proxy_internal.c#l385 and don't see off hand why these if-blocks differ: res = request; if (res-len != sizeof(virProxyPacket)) { virProxyError(conn, VIR_ERR_INTERNAL_ERROR, _(Communication error with proxy: expected %d bytes got %d\n), (int) sizeof(virProxyPacket), res-len); goto error; } res = (virProxyPacketPtr) answer; if ((res-len sizeof(virProxyPacket)) || (res-len sizeof(virProxyFullPacket))) { virProxyError(conn, VIR_ERR_INTERNAL_ERROR, _(Communication error with proxy: got %d bytes packet\n), res-len); goto error; } -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Disallow building Python bindings if shared libraries are disabled.
Diego Elio Pettenò wrote: Patch concept by Jim Meyering j...@meyering.net, moved before the Python testing, and changed the message a bit to explain the problem. --- configure.in |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/configure.in b/configure.in index 3f2f8ff..5275412 100644 --- a/configure.in +++ b/configure.in @@ -1466,6 +1466,11 @@ dnl AC_ARG_WITH([python], [ --with-python Build python bindings (on)],[],[with_python=yes]) +if test $enable_shared:$with_python = no:yes; then + AC_MSG_WARN([Disabling shared libraries is incompatible with building Python extensions.]) + with_python=no +fi Moving the test up is good, but changing the warning like that is less so, since it no longer says what the code is doing. Your diagnostic would be appropriate if it were for a fatal error. However, when overriding a user-supplied option (--with-python), the warning should say what it's doing, so the user does not wonder if instead we've turned on --enable-shared. From 6c558e1f2cfb0bb127f2939d70480a43a20dc9fd Mon Sep 17 00:00:00 2001 From: Jim Meyering j...@meyering.net Date: Thu, 7 Jan 2010 21:07:42 +0100 Subject: [PATCH] let configure --disable-shared work once again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change, ./autogen.sh --disable-shared make would evoke a can not build a shared library failure for libvirtmod.la due to the new use of libtool's -shared link option in python/Makefile.am. Now, --disable-shared also disables building python. * configure.in: Make --disable-shared imply --without-python and silently override --with-python. Improved by: Diego Elio Pettenò flamee...@gmail.com --- configure.in |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index 3f2f8ff..012a96f 100644 --- a/configure.in +++ b/configure.in @@ -1466,6 +1466,12 @@ dnl AC_ARG_WITH([python], [ --with-python Build python bindings (on)],[],[with_python=yes]) +if test $enable_shared:$with_python = no:yes; then + AC_MSG_WARN([Disabling shared libraries is incompatible with building Python extensions.]) + AC_MSG_WARN([Ignoring --with-python.]) + with_python=no +fi + PYTHON_VERSION= PYTHON_INCLUDES= if test $with_python != no ; then @@ -1813,7 +1819,6 @@ AC_ARG_WITH([qemu-group], AC_DEFINE_UNQUOTED([QEMU_USER], [$QEMU_USER], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], [$QEMU_GROUP], [QEMU group account]) - # Only COPYING.LIB is under version control, yet COPYING # is included as part of the distribution tarball. # Copy one to the other, but only if this is a srcdir-build. -- 1.6.6.425.g4dc2d -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] let configure --disable-shared work once again
Daniel Veillard wrote: ... Sure, ACK :-) Thanks. Diego proposed an improvement, so I expect to push this instead: http://thread.gmane.org/gmane.comp.emulators.libvirt/19696/focus=19710 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] don't test res == NULL after we've already dereferenced it
On Fri, Jan 08, 2010 at 12:13:24PM +0100, Jim Meyering wrote: Daniel Veillard wrote: ... However, the point is still valid, so I'll wait for confirmation. This is still about defensive coding, i.e., ensuring that maintenance doesn't violate invariants in harder-to-diagnose ways. If you get a bug report, which would you rather hear? libvirt sometimes segfaults or I get an assertion failure on file.c:999 I guess it's mostly a matter of coding style, I'm not sure it makes such a difference in practice, libvirt output will likely be burried in a log file, unless virsh or similar CLI tool is used. We have only 4 asserts in the code currently, I think it shows that so far we are not relying on it. On one hand this mean calling exit() Is don't use assert libvirt policy? I hope not. The policy is use defensive programming rather than exit or crash this means that assert has his place only in very untractable cases. It is important to distinguish two types of errors: - conditions that may arise due to user input or environment (misbehaving client or server, malformed packet, I/O error, etc.) - internal API abuse, violation of an internal assumption or invariant Using assert is appropriate only in the latter case, for detecting conditions that typically are provoked only by developer-introduced errors. Hum, that's where we disagree. If libvirtd goes down because the configuration for one VM used a little used construct which happened to trigger a bug, exiting gives troubles to all the running domains. We must be more permissive to developer-introduced errors than for a single user program instance. The key point is that the error is being reported while avoiding crashing. Here's the revised patch, followed by the tiny nonnull-one. (also fixes typos s/ret/res/ in log message) From 2a7fed9238667ff75a6ecd662b663549bc8fb7b5 Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Wed, 6 Jan 2010 12:45:07 +0100 Subject: [PATCH] don't test res == NULL after we've already dereferenced res * src/xen/proxy_internal.c (xenProxyCommand): res is known to be non-NULL at that point, so remove the res == NULL guard. --- src/xen/proxy_internal.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index ec4522b..ee4678a 100644 --- a/src/xen/proxy_internal.c +++ b/src/xen/proxy_internal.c @@ -1,7 +1,7 @@ /* * proxy_client.c: client side of the communication with the libvirt proxy. * - * Copyright (C) 2006, 2008, 2009 Red Hat, Inc. + * Copyright (C) 2006, 2008, 2009, 2010 Red Hat, Inc. * * See COPYING.LIB for the License of this software * @@ -444,7 +444,7 @@ retry: /* * do more checks on the incoming packet. */ -if ((res == NULL) || (res-version != PROXY_PROTO_VERSION) || +if ((res-version != PROXY_PROTO_VERSION) || (res-len sizeof(virProxyPacket))) { virProxyError(conn, VIR_ERR_INTERNAL_ERROR, %s, _(Communication error with proxy: malformed packet\n)); -- 1.6.6.425.g4dc2d From eb6f7f0478ce510de8dc5fc9add4eaaca1c2bfc1 Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Thu, 7 Jan 2010 19:48:05 +0100 Subject: [PATCH] proxy_internal.c: mark request parameter as nonnull * src/xen/proxy_internal.c (xenProxyCommand): Mark request as an always-non-NULL parameter. --- src/xen/proxy_internal.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index ee4678a..73a0469 100644 --- a/src/xen/proxy_internal.c +++ b/src/xen/proxy_internal.c @@ -340,7 +340,7 @@ xenProxyClose(virConnectPtr conn) return 0; } -static int +static int ATTRIBUTE_NONNULL(2) xenProxyCommand(virConnectPtr conn, virProxyPacketPtr request, virProxyFullPacketPtr answer, int quiet) { static int serial = 0; -- 1.6.6.425.g4dc2d ACK, fine by me, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [virt-tools-list] Questions about virt-manager running on Arch of Itanium 64
On 01/07/2010 11:53 PM, Dustin Xiong wrote: Date: Thu, 7 Jan 2010 09:15:32 -0500 From: crobi...@redhat.com To: x_k_...@hotmail.com CC: berra...@redhat.com; libvirt-l...@redhat.com Subject: Re: [libvirt] [virt-tools-list] Questions about virt-manager running on Arch of Itanium 64 On 01/07/2010 01:03 AM, Dustin Xiong wrote: I sloved the problem. I modify the libvirt /src/qemu_conf.c. Add the arch ia64 into the static const struct qemu_arch_info const arch_info_hvm[] = {} as berrange said. So the libvirt passing -M ia64. But the kvm binary only experts '-M itanium'. So i replaced the ia64 by itanium in the file /src/qemu_conf.c. Then the virt-manager finally could work on the arch of Itanium. Thank you for your help. Thank you, everyone here. -Dustin Can you provide a diff of your changes so we can apply it to upstream libvirt code? Thanks, Cole OK. But there is a problem. I modify the libvirt-0.6.3-20.el5.ia64.src.rpm(from the rhel-server-5.4-ia64-source.iso). The libvirt could work.But when i download the libvirt-0.6.3-20.tar.gz, then ./configure, make, make install. The libvirt couldn't work. The error as below: [r...@kvm bin]# ./virsh error: unable to connect to '/usr/local/libvirt/var/run/libvirt/libvirt-sock': No such file or directory error: failed to connect to the hypervisor Then I download the lastest libvirt-0.7.5, make it. The error still remains. So if you need I provide a diff of my changes about the libvirt-0.6.3-20.el5.ia64.src.rpm, I am pleasure to do this. -Dustin Building an RPM knows the correct location to put all the files, but a default upstream build will put them into /usr/local which can cause some problems. Your original diff should be fine, I'll fix it up to apply against current upstream. - Cole -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] RFC: Create a separate libvirt users mailing list ?
Hi Folks, We've been brainstorming ways to improve/broaden the libvirt community and one (of many) ideas is to create a separate libvirt users mailing list. The rationale is that this list is 95% patch submission from developers, often very high traffic and thus it may not be appealing for ordinary users to subscribe just to ask a question about libvirt usage. Although there is the virt-tools mailing list, that is really focused on the virt-manager family of apps, not a general purpose libvirt users community. Thus we're considering creating a new list libvirt-us...@redhat.com To serve as a home for discussions relating to - Administrators/users of libvirt / libvirtd / virsh - Developers building applications on top of libvirt - Anyone else wishing to ask/talk about libvirt architecture / concepts / etc in real world deployment While the current list libvir-list@redhat.com To serve as continued home for most current traffic, specifically - Development of libvirt itself (libvirtd, hypervisor drivers, etc) - Development of libvirt language bindings (perl, python, java, etc) - Patch submission for libvirt language bindings Essentially all libvirt code patches would be on libvir-list, while libvirt-users would be for app developer / end user admin discussions. For this to work of course, a significant number developers of libvirt currently on this list would also have to join libvirt-users, so we have people on the new list who are able to answer questions :-) Before we create a new list we'd like to hear from people on this list as to wether they think this would be beneficial. In particular we'd like your opinion if you are someone who's likely to switch to be exclusively on the libvirt-users list. Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] RFC: Create a separate libvirt users mailing list ?
Il 08/01/10 15.56, Daniel P. Berrange ha scritto: - Development of libvirt itself (libvirtd, hypervisor drivers, etc) - Development of libvirt language bindings (perl, python, java, etc) - Patch submission for libvirt language bindings I would like to add “Inter-distribution collaboration on integration of libvirt” ;) -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] RFC: Create a separate libvirt users mailing list ?
Daniel P. Berrange a écrit : Hi Folks, Hello [...] Thus we're considering creating a new list libvirt-us...@redhat.com [...] Excellent idea. I was thinking to unsubscribe from the actual list because of the hudge dev traffic. If such a list is started, I will switch. Regards -- Daniel -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Replace old CVS references with GIT
2010/1/8 Daniel Veillard veill...@redhat.com: On Fri, Jan 08, 2010 at 01:45:12AM +0100, Matthias Bolte wrote: --- HACKING | 6 +++--- docs/FAQ.html.in | 2 +- docs/bugs.html.in | 6 +++--- docs/contact.html.in | 4 ++-- docs/deployment.html.in | 4 ++-- docs/hacking.html.in | 6 +++--- src/Makefile.am | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) ACK, thanks ! Daniel Thanks, pushed. Matthias -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] esx: Warn if the ESX server is in maintenance mode
On Tue, Jan 05, 2010 at 03:00:06AM +0100, Matthias Bolte wrote: --- src/esx/esx_driver.c | 38 +++--- 1 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index f86654a..ddda66e 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -401,6 +401,32 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) } } +/* Query the host for maintenance mode and vCenter IP address */ +if (esxVI_String_AppendValueListToList(conn, propertyNameList, + runtime.inMaintenanceMode\0 + summary.managementServerIp\0) 0 || +esxVI_LookupHostSystemByIp(conn, priv-host, hostIpAddress, + propertyNameList, hostSystem) 0) { +goto failure; +} + +/* Warn if host is in maintenance mode */ +for (dynamicProperty = hostSystem-propSet; dynamicProperty != NULL; + dynamicProperty = dynamicProperty-_next) { +if (STREQ(dynamicProperty-name, runtime.inMaintenanceMode)) { +if (esxVI_AnyType_ExpectType(conn, dynamicProperty-val, + esxVI_Type_Boolean) 0) { +goto failure; +} + +if (dynamicProperty-val-boolean == esxVI_Boolean_True) { +VIR_WARN0(The server is in maintenance mode); +} + +break; +} +} + /* Login to vCenter */ if (vCenter != NULL) { VIR_FREE(url); @@ -415,17 +441,9 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) } /* Lookup the vCenter from the ESX host */ -if (esxVI_String_AppendValueToList - (conn, propertyNameList, summary.managementServerIp) 0 || -esxVI_LookupHostSystemByIp(conn, priv-host, hostIpAddress, - propertyNameList, hostSystem) 0) { -goto failure; -} - for (dynamicProperty = hostSystem-propSet; dynamicProperty != NULL; dynamicProperty = dynamicProperty-_next) { -if (STREQ(dynamicProperty-name, - summary.managementServerIp)) { +if (STREQ(dynamicProperty-name, summary.managementServerIp)) { if (esxVI_AnyType_ExpectType(conn, dynamicProperty-val, esxVI_Type_String) 0) { goto failure; @@ -461,8 +479,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) } break; -} else { -VIR_WARN(Unexpected '%s' property, dynamicProperty-name); } } Looks like the fix for the problem Rich reported, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] RFC: Create a separate libvirt users mailing list ?
On Fri, Jan 08, 2010 at 04:06:49PM +0100, Diego E. “Flameeyes” Pettenò wrote: Il 08/01/10 15.56, Daniel P. Berrange ha scritto: - Development of libvirt itself (libvirtd, hypervisor drivers, etc) - Development of libvirt language bindings (perl, python, java, etc) - Patch submission for libvirt language bindings I would like to add “Inter-distribution collaboration on integration of libvirt” ;) Then you're on the right list :- ! Keep going :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 00/34] Add device addressing and disk controller support
This series is a merge of two previous series I posted http://www.redhat.com/archives/libvir-list/2009-December/msg00232.html http://www.redhat.com/archives/libvir-list/2009-December/msg00392.html It accomplishes quite a lot of things, having major impact on the QEMU driver, hopefully all in a postive way :-) In particular it does * Add standard XML syntax for addressing of PCI devices, and disk drives * Add support for disk controllers as a managed device in XML * Add support for disk controller hotplug/unplug * Convert everything over to use QEMU's -device flag where available * Add PCI addressing when using -device * Introduce a way to give every device a unique 'alias' name in the XML format I can't promise it works perfectly, but i've done quite alot of positive testing with it now believe all the back comptability stuff is working right. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 04/34] Add address info to sound, video and watchdog devices
Add the virDomainDeviceAddress information to the sound, video and watchdog devices. This means all of them gain the new XML element address / This brings them upto par with disk/net/hostdev devices which already have address info * src/conf/domain_conf.h: Add virDomainDeviceAddress to sound, video watchdog device struts. * src/conf/domain_conf.c: Hook up parsing/formatting for virDomainDeviceAddress in sound, video watchdog devices * docs/schemas/domain.rng: Associate device address info with sound, video watchdog --- docs/schemas/domain.rng |9 +++ src/conf/domain_conf.c | 54 +++--- src/conf/domain_conf.h |3 ++ 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index f426587..dd729c0 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -907,6 +907,9 @@ /optional /element /optional + optional +ref name=address/ + /optional /element /define !-- @@ -1043,6 +1046,9 @@ valueac97/value /choice /attribute + optional +ref name=address/ + /optional /element /define define name=watchdog @@ -1064,6 +1070,9 @@ /choice /attribute /optional + optional +ref name=address/ + /optional /element /define define name=parallel diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d7b1aa1..27d0613 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -465,6 +465,8 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def) if (!def) return; +virDomainDeviceInfoClear(def-info); + VIR_FREE(def); } @@ -473,6 +475,8 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def) if (!def) return; +virDomainDeviceInfoClear(def-info); + VIR_FREE(def); } @@ -481,6 +485,8 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def) if (!def) return; +virDomainDeviceInfoClear(def-info); + VIR_FREE(def-accel); VIR_FREE(def); } @@ -2259,8 +2265,8 @@ error: static virDomainSoundDefPtr virDomainSoundDefParseXML(virConnectPtr conn, const xmlNodePtr node, - int flags ATTRIBUTE_UNUSED) { - + int flags) +{ char *model; virDomainSoundDefPtr def; @@ -2276,6 +2282,9 @@ virDomainSoundDefParseXML(virConnectPtr conn, goto error; } +if (virDomainDeviceInfoParseXML(conn, node, def-info, flags) 0) +goto error; + cleanup: VIR_FREE(model); @@ -2291,7 +2300,8 @@ error: static virDomainWatchdogDefPtr virDomainWatchdogDefParseXML(virConnectPtr conn, const xmlNodePtr node, - int flags ATTRIBUTE_UNUSED) { + int flags) +{ char *model = NULL; char *action = NULL; @@ -2327,6 +2337,9 @@ virDomainWatchdogDefParseXML(virConnectPtr conn, } } +if (virDomainDeviceInfoParseXML(conn, node, def-info, flags) 0) +goto error; + cleanup: VIR_FREE (action); VIR_FREE (model); @@ -2439,7 +2452,7 @@ static virDomainVideoDefPtr virDomainVideoDefParseXML(virConnectPtr conn, const xmlNodePtr node, virDomainDefPtr dom, - int flags ATTRIBUTE_UNUSED) { + int flags) { virDomainVideoDefPtr def; xmlNodePtr cur; char *type = NULL; @@ -2499,6 +2512,9 @@ virDomainVideoDefParseXML(virConnectPtr conn, def-heads = 1; } +if (virDomainDeviceInfoParseXML(conn, node, def-info, flags) 0) +goto error; + VIR_FREE(type); VIR_FREE(vram); VIR_FREE(heads); @@ -2927,8 +2943,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, goto error; } else if (xmlStrEqual(node-name, BAD_CAST watchdog)) { dev-type = VIR_DOMAIN_DEVICE_WATCHDOG; -if (!(dev-data.watchdog = virDomainWatchdogDefParseXML(conn, node, -flags))) +if (!(dev-data.watchdog = virDomainWatchdogDefParseXML(conn, node, flags))) goto error; } else if (xmlStrEqual(node-name, BAD_CAST video)) { dev-type = VIR_DOMAIN_DEVICE_VIDEO; @@ -3637,7 +3652,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } if (n 0) { virDomainWatchdogDefPtr watchdog = -virDomainWatchdogDefParseXML (conn, nodes[0], flags); +virDomainWatchdogDefParseXML(conn, nodes[0], flags); if (!watchdog) goto error; @@ -4550,9 +4565,18 @@ virDomainSoundDefFormat(virConnectPtr conn, return -1; } -virBufferVSprintf(buf, sound model='%s'/\n, +virBufferVSprintf(buf, sound model='%s',
[libvirt] [PATCH 06/34] Add new domain device: controller
From: Wolfgang Mauerer wolfgang.maue...@siemens.com This augments virDomainDevice with a controller element that is used to represent disk controllers (e.g., scsi controllers). The XML format is given by controller type=scsi index=num address type=pci domain=0xNUM bus=0xNUM slot=0xNUM/ /controller where type denotes the disk interface (scsi, ide,...), index is an integer that identifies the controller for association with disks, and the address element specifies the controller address on the PCI bus as described in previous commits The address element can be omitted; in this case, an address will be assigned automatically. Most of the code in this patch is from Wolfgang Mauerer's previous disk controller series * docs/schemas/domain.rng: Define syntax for controller XML element * src/conf/domain_conf.c, src/conf/domain_conf.h: Define virDomainControllerDef struct, and routines for parsing and formatting XML * src/libvirt_private.syms: Add virDomainControllerInsert and virDomainControllerDefFree --- docs/schemas/domain.rng | 20 + src/conf/domain_conf.c | 192 +- src/conf/domain_conf.h | 31 src/libvirt_private.syms |2 + 4 files changed, 244 insertions(+), 1 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index dd729c0..a32ce45 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -521,6 +521,25 @@ /choice /attribute /define + define name=controller +element name=controller + optional +attribute name=type + choice +valuefdc/value +valueide/value +valuescsi/value + /choice +/attribute + /optional + attribute name=index +ref name=unsignedInt/ + /attribute + optional + ref name=address/ + /optional +/element + /define define name=filesystem element name=filesystem choice @@ -1225,6 +1244,7 @@ zeroOrMore choice ref name=disk/ +ref name=controller/ ref name=filesystem/ ref name=interface/ ref name=input/ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 662ff81..dd10f36 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -86,7 +86,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, sound, video, hostdev, - watchdog) + watchdog, + controller) VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, none, @@ -119,6 +120,12 @@ VIR_ENUM_IMPL(virDomainDiskCache, VIR_DOMAIN_DISK_CACHE_LAST, writethrough, writeback) +VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST, + ide, + fdc, + scsi, + sata) + VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST, mount, block, @@ -367,6 +374,16 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def) VIR_FREE(def); } +void virDomainControllerDefFree(virDomainControllerDefPtr def) +{ +if (!def) +return; + +virDomainDeviceInfoClear(def-info); + +VIR_FREE(def); +} + void virDomainFSDefFree(virDomainFSDefPtr def) { if (!def) @@ -528,6 +545,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) case VIR_DOMAIN_DEVICE_WATCHDOG: virDomainWatchdogDefFree(def-data.watchdog); break; +case VIR_DOMAIN_DEVICE_CONTROLLER: +virDomainControllerDefFree(def-data.controller); +break; } VIR_FREE(def); @@ -561,6 +581,10 @@ void virDomainDefFree(virDomainDefPtr def) virDomainDiskDefFree(def-disks[i]); VIR_FREE(def-disks); +for (i = 0 ; i def-ncontrollers ; i++) +virDomainControllerDefFree(def-controllers[i]); +VIR_FREE(def-controllers); + for (i = 0 ; i def-nfss ; i++) virDomainFSDefFree(def-fss[i]); VIR_FREE(def-fss); @@ -1335,6 +1359,63 @@ cleanup: } +/* Parse the XML definition for a controller + * @param node XML nodeset to parse for controller definition + */ +static virDomainControllerDefPtr +virDomainControllerDefParseXML(virConnectPtr conn, + xmlNodePtr node, + int flags) +{ +virDomainControllerDefPtr def; +char *type = NULL; +char *idx = NULL; + +if (VIR_ALLOC(def) 0) { +virReportOOMError(conn); +return NULL; +} + +type = virXMLPropString(node, type); +if (type) { +if ((def-type = virDomainDiskBusTypeFromString(type)) 0) { +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _(unknown disk controller type '%s'), type); +goto error; +} +} + +idx = virXMLPropString(node, index); +if (idx) { +
[libvirt] [PATCH 14/34] Fixed char device stuff
Temp hack --- src/qemu/qemu_monitor_text.c |9 +++-- 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 52cd97c..2b8c1e8 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -1678,14 +1678,12 @@ cleanup: int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon, virHashTablePtr paths) { -const char *cmd = info chardev; char *reply = NULL; int ret = -1; -if (qemuMonitorCommand(mon, cmd, reply) 0) { -qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(failed to retrieve chardev info in qemu with '%s'), - cmd); +if (qemuMonitorCommand(mon, info chardev, reply) 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, %s, + _(failed to retrieve chardev info in qemu with 'info chardev')); goto cleanup; } @@ -1747,7 +1745,6 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon, ret = 0; cleanup: -VIR_FREE(cmd); VIR_FREE(reply); return ret; } -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 02/34] Introduce a standardized data structure for device addresses
All guest devices now use a common device address structure summarized by: enum virDomainDeviceAddressType { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, }; struct _virDomainDevicePCIAddress { unsigned int domain; unsigned int bus; unsigned int slot; unsigned int function; }; struct _virDomainDeviceInfo { int type; union { virDomainDevicePCIAddress pci; } addr; }; This replaces the anonymous structs in Disk/Net/Hostdev data structures. Where available, the address is *always* printed in the XML file, instead of being hidden in the internal state file. address type='pci' domain='0x' bus='0x1e' slot='0x07' function='0x0'/ The structure definition is based on Wolfgang Mauerer's disk controller patch series. * docs/schemas/domain.rng: Define the address syntax and associate it with disk/net/hostdev devices * src/conf/domain_conf.h, src/conf/domain_conf.c, src/libvirt_private.syms: APIs for parsing/formatting address information. Also remove the QEMU specific 'pci_addr' attributes * src/qemu/qemu_driver.c: Replace use of 'pci_addr' attrs with new standardized format. --- docs/schemas/domain.rng | 55 +-- src/conf/domain_conf.c | 420 +- src/conf/domain_conf.h | 84 +- src/libvirt_private.syms |6 + src/qemu/qemu_driver.c | 64 --- 5 files changed, 428 insertions(+), 201 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 566b117..7e00e7f 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -385,6 +385,9 @@ optional ref name=encryption/ /optional +optional + ref name=address/ +/optional /define !-- A disk description can be either of type file or block @@ -715,6 +718,9 @@ empty/ /element /optional + optional + ref name=address/ + /optional /interleave /define !-- @@ -1134,10 +1140,15 @@ choice ref name=usbproduct/ ref name=usbaddress/ -ref name=pciaddress/ +element name=address + ref name=pciaddress/ +/element /choice /element /group + optional +ref name=address/ + /optional /element /define define name=usbproduct @@ -1163,22 +1174,20 @@ /element /define define name=pciaddress -element name=address - optional -attribute name=domain - ref name=pciDomain/ -/attribute - /optional - attribute name=bus -ref name=pciBus/ - /attribute - attribute name=slot -ref name=pciSlot/ - /attribute - attribute name=function -ref name=pciFunc/ +optional + attribute name=domain +ref name=pciDomain/ /attribute -/element +/optional +attribute name=bus + ref name=pciBus/ +/attribute +attribute name=slot + ref name=pciSlot/ +/attribute +attribute name=function + ref name=pciFunc/ +/attribute /define !-- Devices attached to a domain. @@ -1286,6 +1295,20 @@ /interleave /element /define + + define name=address +element name=address + choice + group + attribute name=type + valuepci/value + /attribute + ref name=pciaddress/ + /group + /choice +/element + /define + !-- Type library diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0b4fe8b..f199c08 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -88,6 +88,10 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, hostdev, watchdog) +VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, + none, + pci) + VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST, block, file, @@ -357,6 +361,7 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def) VIR_FREE(def-driverName); VIR_FREE(def-driverType); virStorageEncryptionFree(def-encryption); +virDomainDeviceInfoClear(def-info); VIR_FREE(def); } @@ -408,8 +413,10 @@ void virDomainNetDefFree(virDomainNetDefPtr def) } VIR_FREE(def-ifname); -VIR_FREE(def-nic_name); VIR_FREE(def-hostnet_name); + +virDomainDeviceInfoClear(def-info); + VIR_FREE(def); } @@ -483,6 +490,7 @@ void virDomainHostdevDefFree(virDomainHostdevDefPtr def) return; VIR_FREE(def-target); +virDomainDeviceInfoClear(def-info); VIR_FREE(def); } @@ -731,6 +739,220 @@ void virDomainRemoveInactive(virDomainObjListPtr doms, } +int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, + int type) +{ +if (info-type != type) +return 0; + +switch (info-type) { +case
[libvirt] [PATCH 15/34] Auto-add disk controllers based on defined disks
Existing applications using libvirt are not aware of the disk controller concept. Thus, after parsing the disk definitions in the XML, it is neccessary to create controller elements to satisfy all requested disks, as per their defined drive addresses * src/conf/domain_conf.c, src/conf/domain_conf.h, src/libvirt_private.syms: Add virDomainDefAddDiskControllers() method for populating disk controllers, and call it after parsing disk definitions. * src/qemu/qemu_conf.c: Call virDomainDefAddDiskControllers() when doing ARGV - XML conversion * tests/qemuxml2argvdata/qemuxml2argv*.xml: Add disk controller data to all data files which don't have it already --- src/conf/domain_conf.c | 96 src/conf/domain_conf.h |2 + src/libvirt_private.syms |1 + src/qemu/qemu_conf.c |3 + tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml |1 + .../qemuxml2argvdata/qemuxml2argv-boot-floppy.xml |2 + .../qemuxml2argvdata/qemuxml2argv-boot-network.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml |1 + .../qemuxml2argv-channel-guestfwd.xml |1 + .../qemuxml2argv-clock-localtime.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml |1 + .../qemuxml2argv-console-compat-chardev.xml|1 + .../qemuxml2argv-console-compat.xml|1 + .../qemuxml2argv-disk-cdrom-empty.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml |1 + .../qemuxml2argv-disk-drive-boot-cdrom.xml |1 + .../qemuxml2argv-disk-drive-boot-disk.xml |1 + .../qemuxml2argv-disk-drive-cache-v1-none.xml |1 + .../qemuxml2argv-disk-drive-cache-v1-wb.xml|1 + .../qemuxml2argv-disk-drive-cache-v1-wt.xml|1 + .../qemuxml2argv-disk-drive-cache-v2-none.xml |1 + .../qemuxml2argv-disk-drive-cache-v2-wb.xml|1 + .../qemuxml2argv-disk-drive-cache-v2-wt.xml|1 + .../qemuxml2argv-disk-drive-fat.xml|1 + .../qemuxml2argv-disk-drive-fmt-qcow.xml |1 + .../qemuxml2argv-disk-drive-shared.xml |1 + .../qemuxml2argvdata/qemuxml2argv-disk-floppy.xml |2 + tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-disk-usb.xml |1 + .../qemuxml2argvdata/qemuxml2argv-disk-virtio.xml |1 + .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml |1 + .../qemuxml2argv-floppy-drive-fat.xml |2 + .../qemuxml2argv-graphics-sdl-fullscreen.xml |1 + .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml |1 + .../qemuxml2argv-graphics-vnc-sasl.xml |1 + .../qemuxml2argv-graphics-vnc-tls.xml |1 + .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml |1 + .../qemuxml2argv-hostdev-pci-address.xml |1 + .../qemuxml2argv-hostdev-usb-address.xml |1 + .../qemuxml2argv-hostdev-usb-product.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml |1 + .../qemuxml2argv-input-usbmouse.xml|1 + .../qemuxml2argv-input-usbtablet.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml |1 + .../qemuxml2argv-machine-aliases1.xml |1 + .../qemuxml2argv-machine-aliases2.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-migrate.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-minimal.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml |1 + .../qemuxml2argv-misc-no-reboot.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml |1 + .../qemuxml2argv-net-eth-ifname.xml|1 + .../qemuxml2argv-net-eth-names.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-net-user.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-net-virtio.xml |1 + .../qemuxml2argv-parallel-tcp-chardev.xml |1 + .../qemuxml2argvdata/qemuxml2argv-parallel-tcp.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml |1 + .../qemuxml2argv-serial-dev-chardev.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml |1 + .../qemuxml2argv-serial-file-chardev.xml |1 + .../qemuxml2argvdata/qemuxml2argv-serial-file.xml |1 + .../qemuxml2argv-serial-many-chardev.xml |1 + .../qemuxml2argvdata/qemuxml2argv-serial-many.xml |1 + .../qemuxml2argv-serial-pty-chardev.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml |1 + .../qemuxml2argv-serial-tcp-chardev.xml|1 + .../qemuxml2argv-serial-tcp-telnet-chardev.xml |1 +
[libvirt] [PATCH 16/34] Clear assigned PCI devices at shutdown
The PCI device addresses are only valid while the VM is running, since they are auto-assigned by QEMU. After shutdown they must all be cleared. Future QEMU driver enhancement will allow for persistent PCI address assignment * src/conf/domain_conf.h, src/conf/domain_conf.c, src/libvirt_private.syms Add virDomainDefClearPCIAddresses() method for wiping out auto assigned PCI addresses * src/qemu/qemu_driver.c: Clear PCI addresses at VM shutdown --- src/conf/domain_conf.c | 36 src/conf/domain_conf.h |2 ++ src/libvirt_private.syms |1 + src/qemu/qemu_driver.c |2 ++ 4 files changed, 41 insertions(+), 0 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5edd060..ef5dbe9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -816,6 +816,42 @@ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) } +static void virDomainDeviceInfoClearField(virDomainDeviceInfoPtr info) +{ +if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +memset(info-addr, 0, sizeof(info-addr)); +info-type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; +} +} + + +static void virDomainDefClearDeviceInfo(virDomainDefPtr def) +{ +int i; + +for (i = 0; i def-ndisks ; i++) +virDomainDeviceInfoClearField(def-disks[i]-info); +for (i = 0; i def-nnets ; i++) +virDomainDeviceInfoClearField(def-nets[i]-info); +for (i = 0; i def-nsounds ; i++) +virDomainDeviceInfoClearField(def-sounds[i]-info); +for (i = 0; i def-nhostdevs ; i++) +virDomainDeviceInfoClearField(def-hostdevs[i]-info); +for (i = 0; i def-nvideos ; i++) +virDomainDeviceInfoClearField(def-videos[i]-info); +for (i = 0; i def-ncontrollers ; i++) +virDomainDeviceInfoClearField(def-controllers[i]-info); +if (def-watchdog) +virDomainDeviceInfoClearField(def-watchdog-info); +} + + +void virDomainDefClearPCIAddresses(virDomainDefPtr def) +{ +virDomainDefClearDeviceInfo(def); +} + + /* Generate a string representation of a device address * @param address Device address to stringify */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1831d17..a6f7ab2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -736,6 +736,8 @@ int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr); int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr); int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info); void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); +void virDomainDefClearPCIAddresses(virDomainDefPtr def); + void virDomainDefFree(virDomainDefPtr vm); void virDomainObjRef(virDomainObjPtr vm); /* Returns 1 if the object was freed, 0 if more refs exist */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a4a02e7..678d610 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -187,6 +187,7 @@ virDomainControllerTypeToString; virDomainControllerDefFree; virDomainDeviceAddressTypeToString; virDomainDefAddDiskControllers; +virDomainDefClearPCIAddresses; # domain_event.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cd406ec..6a3af61 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3032,6 +3032,8 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, VIR_FREE(vm-def-seclabel.imagelabel); } +virDomainDefClearPCIAddresses(vm-def); + if (qemuDomainSetAllDeviceOwnership(conn, driver, vm-def, 1) 0) VIR_WARN(Failed to restore all device ownership for %s, vm-def-name); -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 28/34] Convert USB input devices to -device
--- src/qemu/qemu_conf.c | 34 -- 1 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 1ea61a9..3b39a91 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -2268,6 +2268,28 @@ error: } +static char *qemuBuildUSBInputDevStr(virDomainInputDefPtr dev) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferVSprintf(buf, %s, + dev-type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? + usb-mouse : usb-tablet); +virBufferVSprintf(buf, ,id=%s, dev-info.alias); + +if (virBufferError(buf)) { +virReportOOMError(NULL); +goto error; +} + +return virBufferContentAndReset(buf); + +error: +virBufferFreeAndReset(buf); +return NULL; +} + + static char * qemuBuildSoundDevStr(virDomainSoundDefPtr sound) { @@ -3273,8 +3295,16 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainInputDefPtr input = def-inputs[i]; if (input-bus == VIR_DOMAIN_INPUT_BUS_USB) { -ADD_ARG_LIT(-usbdevice); -ADD_ARG_LIT(input-type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? mouse : tablet); +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +char *optstr; +ADD_ARG_LIT(-device); +if (!(optstr = qemuBuildUSBInputDevStr(input))) +goto error; +ADD_ARG(optstr); +} else { +ADD_ARG_LIT(-usbdevice); +ADD_ARG_LIT(input-type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? mouse : tablet); +} } } -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 08/34] Split code for building QEMU -drive arg in separate method
To enable it to be called from multiple locations, split out the code for building the -drive arg string. This will be needed by later patches which do drive hotplug, the conversion to use -device, and the conversion to controller/bus/unit addressing * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add qemuBuildDriveStr for building -drive arg string --- src/qemu/qemu_conf.c | 191 ++--- src/qemu/qemu_conf.h |5 ++ 2 files changed, 106 insertions(+), 90 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c575d63..94f4cc0 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1523,6 +1523,104 @@ qemuAssignNetNames(virDomainDefPtr def, return 0; } +#define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \ + abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ + +static int +qemuSafeSerialParamValue(virConnectPtr conn, + const char *value) +{ +if (strspn(value, QEMU_SERIAL_PARAM_ACCEPTED_CHARS) != strlen (value)) { +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(driver serial '%s' contains unsafe characters), + value); +return -1; +} + +return 0; +} + + +char * +qemuBuildDriveStr(virDomainDiskDefPtr disk, + int bootable, + int qemuCmdFlags) +{ +virBuffer opt = VIR_BUFFER_INITIALIZER; +const char *bus = virDomainDiskQEMUBusTypeToString(disk-bus); +int idx = virDiskNameToIndex(disk-dst); + +if (idx 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unsupported disk type '%s'), disk-dst); +goto error; +} + +if (disk-src) { +if (disk-type == VIR_DOMAIN_DISK_TYPE_DIR) { +/* QEMU only supports magic FAT format for now */ +if (disk-driverType +STRNEQ(disk-driverType, fat)) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unsupported disk driver type for '%s'), + disk-driverType); +goto error; +} +if (!disk-readonly) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(cannot create virtual FAT disks in read-write mode)); +goto error; +} +if (disk-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) +virBufferVSprintf(opt, file=fat:floppy:%s,, disk-src); +else +virBufferVSprintf(opt, file=fat:%s,, disk-src); +} else { +virBufferVSprintf(opt, file=%s,, disk-src); +} +} +virBufferVSprintf(opt, if=%s, bus); +if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM) +virBufferAddLit(opt, ,media=cdrom); +virBufferVSprintf(opt, ,index=%d, idx); +if (bootable +disk-device == VIR_DOMAIN_DISK_DEVICE_DISK) +virBufferAddLit(opt, ,boot=on); +if (disk-driverType +disk-type != VIR_DOMAIN_DISK_TYPE_DIR +qemuCmdFlags QEMUD_CMD_FLAG_DRIVE_FORMAT) +virBufferVSprintf(opt, ,format=%s, disk-driverType); +if (disk-serial +(qemuCmdFlags QEMUD_CMD_FLAG_DRIVE_SERIAL)) { +if (qemuSafeSerialParamValue(NULL, disk-serial) 0) +goto error; +virBufferVSprintf(opt, ,serial=%s, disk-serial); +} + +if (disk-cachemode) { +const char *mode = +(qemuCmdFlags QEMUD_CMD_FLAG_DRIVE_CACHE_V2) ? +qemuDiskCacheV2TypeToString(disk-cachemode) : +qemuDiskCacheV1TypeToString(disk-cachemode); + +virBufferVSprintf(opt, ,cache=%s, mode); +} else if (disk-shared !disk-readonly) { +virBufferAddLit(opt, ,cache=off); +} + +if (virBufferError(opt)) { +virReportOOMError(NULL); +goto error; +} + +return virBufferContentAndReset(opt); + +error: +virBufferFreeAndReset(opt); +return NULL; +} + + int qemuBuildNicStr(virConnectPtr conn, virDomainNetDefPtr net, @@ -1866,23 +1964,6 @@ no_memory: } -#define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \ - abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ - -static int -qemuSafeSerialParamValue(virConnectPtr conn, - const char *value) -{ -if (strspn(value, QEMU_SERIAL_PARAM_ACCEPTED_CHARS) != strlen (value)) { -qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _(driver serial '%s' contains unsafe characters), - value); -return -1; -} - -return 0; -} - /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -2273,12 +2354,9 @@ int qemudBuildCommandLine(virConnectPtr conn, } for (i = 0 ; i def-ndisks ; i++) { -virBuffer opt =
[libvirt] [PATCH 03/34] Extend the virDomainDeviceAddress struture to allow disk controller addresses
Introduce a new structure struct _virDomainDeviceDriveAddress { unsigned int controller; unsigned int bus; unsigned int unit; }; and plug that into virDomainDeviceAddress and generates XML that looks like address type='drive' controller='1' bus='0' unit='5'/ This syntax will be used by the QEMU driver to explicitly control how drives are attached to the bus * src/conf/domain_conf.h, src/conf/domain_conf.c: Parsing and formatting of drive addresses * docs/schemas/domain.rng: Define new address format for drives --- docs/schemas/domain.rng | 36 +++ src/conf/domain_conf.c | 87 ++- src/conf/domain_conf.h | 13 +++ 3 files changed, 135 insertions(+), 1 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 7e00e7f..f426587 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -1189,6 +1189,21 @@ ref name=pciFunc/ /attribute /define + define name=driveaddress +optional + attribute name=controller +ref name=driveController/ + /attribute +/optional +optional + attribute name=bus + ref name=driveBus/ + /attribute +/optional +attribute name=unit + ref name=driveUnit/ +/attribute + /define !-- Devices attached to a domain. -- @@ -1305,6 +1320,12 @@ /attribute ref name=pciaddress/ /group + group + attribute name=type + valuedrive/value + /attribute + ref name=driveaddress/ + /group /choice /element /define @@ -1434,6 +1455,21 @@ param name=pattern(0x)?[0-7]/param /data /define + define name=driveController +data type=string + param name=pattern[0-9]{1,2}/param +/data + /define + define name=driveBus +data type=string + param name=pattern[0-9]{1,2}/param +/data + /define + define name=driveUnit +data type=string + param name=pattern[0-9]{1,2}/param +/data + /define define name=featureName data type=string param name='pattern'[a-zA-Z0-9\-_]+/param diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f199c08..d7b1aa1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -90,7 +90,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, none, - pci) + pci, + drive); VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST, block, @@ -748,6 +749,9 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, switch (info-type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: return virDomainDevicePCIAddressIsValid(info-addr.pci); + +case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: +return virDomainDeviceDriveAddressIsValid(info-addr.drive); } return 0; @@ -760,6 +764,13 @@ int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr) } +int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr ATTRIBUTE_UNUSED) +{ +/*return addr-controller || addr-bus || addr-unit;*/ +return 1; /* 0 is valid for all fields, so any successfully parsed addr is valid */ +} + + int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info) { if (info-type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) @@ -803,6 +814,13 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf, info-addr.pci.function); break; +case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: +virBufferVSprintf(buf, controller='%d' bus='%d' unit='%d', + info-addr.drive.controller, + info-addr.drive.bus, + info-addr.drive.unit); +break; + default: virDomainReportError(NULL, VIR_ERR_INTERNAL_ERROR, _(unknown address type '%d'), info-type); @@ -828,6 +846,18 @@ int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a, } +int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a, + virDomainDeviceDriveAddressPtr b) +{ +if (a-controller == b-controller +a-bus == b-bus +a-unit == b-unit) +return 1; + +return 0; +} + + static int virDomainDevicePCIAddressParseXML(virConnectPtr conn, xmlNodePtr node, @@ -888,6 +918,56 @@ cleanup: } +static int +virDomainDeviceDriveAddressParseXML(virConnectPtr conn, +xmlNodePtr node, +virDomainDeviceDriveAddressPtr addr) +{ +char *bus, *unit, *controller; +int ret = -1; + +memset(addr, 0, sizeof(*addr)); + +controller = virXMLPropString(node, controller); +bus = virXMLPropString(node, bus); +
[libvirt] [PATCH 20/34] Assign device aliases for all devices at startup
When starting a guest, give every device a unique alias. This will be used for the 'id' parameter in -device args in later patches. It can also be used to uniquely identify devices in the monitor For old QEMU without -device, assign disk names based on QEMU's historical naming scheme. * src/qemu/qemu_conf.c: Assign unique device aliases * src/qemu/qemu_driver.c: Remove obsolete qemudDiskDeviceName and use the device alias in eject blockstats commands --- src/qemu/qemu_conf.c | 173 src/qemu/qemu_driver.c | 104 ++--- 2 files changed, 195 insertions(+), 82 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3718470..5dcd50f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1460,6 +1460,173 @@ cleanup: return tapfd; } + +static int +qemuAssignDeviceAliases(virDomainDefPtr def) +{ +int i; + +for (i = 0; i def-ndisks ; i++) { +const char *prefix = virDomainDiskBusTypeToString(def-disks[i]-bus); +if (def-disks[i]-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { +if (virAsprintf(def-disks[i]-info.alias, %s%d-%d-%d, prefix, +def-disks[i]-info.addr.drive.controller, +def-disks[i]-info.addr.drive.bus, +def-disks[i]-info.addr.drive.unit) 0) +goto no_memory; +} else { +int idx = virDiskNameToIndex(def-disks[i]-dst); +if (virAsprintf(def-disks[i]-info.alias, %s-disk%d, prefix, idx) 0) +goto no_memory; +} +} +for (i = 0; i def-nnets ; i++) { +if (def-nets[i]-model) { +if (virAsprintf(def-nets[i]-info.alias, %s-nic%d, def-nets[i]-model, i) 0) +goto no_memory; +} else { +if (virAsprintf(def-nets[i]-info.alias, nic%d, i) 0) +goto no_memory; +} +} + +for (i = 0; i def-nsounds ; i++) { +if (virAsprintf(def-sounds[i]-info.alias, sound%d, i) 0) +goto no_memory; +} +for (i = 0; i def-nhostdevs ; i++) { +if (def-hostdevs[i]-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { +const char *prefix = virDomainHostdevSubsysTypeToString +(def-hostdevs[i]-source.subsys.type); +if (virAsprintf(def-hostdevs[i]-info.alias, host%s%d, prefix, i) 0) +goto no_memory; +} else { +if (virAsprintf(def-hostdevs[i]-info.alias, host%d,i) 0) +goto no_memory; +} +} +for (i = 0; i def-nvideos ; i++) { +if (virAsprintf(def-videos[i]-info.alias, video%d, i) 0) +goto no_memory; +} +for (i = 0; i def-ncontrollers ; i++) { +const char *prefix = virDomainControllerTypeToString(def-controllers[i]-type); +if (virAsprintf(def-controllers[i]-info.alias, %s%d, prefix, i) 0) +goto no_memory; +} +for (i = 0; i def-ninputs ; i++) { +if (virAsprintf(def-inputs[i]-info.alias, input%d, i) 0) +goto no_memory; +} +for (i = 0; i def-nparallels ; i++) { +if (virAsprintf(def-parallels[i]-info.alias, parallel%d, i) 0) +goto no_memory; +} +for (i = 0; i def-nserials ; i++) { +if (virAsprintf(def-serials[i]-info.alias, serial%d, i) 0) +goto no_memory; +} +for (i = 0; i def-nchannels ; i++) { +if (virAsprintf(def-channels[i]-info.alias, channel%d, i) 0) +goto no_memory; +} +if (def-watchdog) { +if (virAsprintf(def-watchdog-info.alias, watchdog%d, 0) 0) +goto no_memory; +} + +return 0; + +no_memory: +virReportOOMError(NULL); +return -1; +} + + +static char *qemuDiskLegacyName(const virDomainDiskDefPtr disk) +{ +char *devname; + +if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM +STREQ(disk-dst, hdc)) +devname = strdup(cdrom); +else +devname = strdup(disk-dst); + +if (!devname) +virReportOOMError(NULL); + +return NULL; +} + +/* Return the -drive QEMU disk name for use in monitor commands */ +static char *qemuDiskDriveName(const virDomainDiskDefPtr disk) +{ +int busid, devid; +int ret; +char *devname; + +if (virDiskNameToBusDeviceIndex(disk, busid, devid) 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(cannot convert disk '%s' to bus/device index), + disk-dst); +return NULL; +} + +switch (disk-bus) { +case VIR_DOMAIN_DISK_BUS_IDE: +if (disk-device== VIR_DOMAIN_DISK_DEVICE_DISK) +ret = virAsprintf(devname, ide%d-hd%d, busid, devid); +else +ret = virAsprintf(devname, ide%d-cd%d, busid, devid); +break; +case VIR_DOMAIN_DISK_BUS_SCSI: +if
[libvirt] [PATCH 34/34] Convert VirtIO balloon over to -device syntax
Replace -balloon virtio With -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 This allows it to get correct assigned PCI address as declared in previous patch * src/qemu/qemu_conf.c: Convert Virtio ballon to -device and give it an explicit PCI address * tests/qemuxml2argvdata/qemuxml2argv-*args: Add in virtio balloon where appropriate --- src/qemu/qemu_conf.c |8 +++- .../qemuxml2argv-channel-guestfwd.args |2 +- .../qemuxml2argv-console-compat-chardev.args |2 +- .../qemuxml2argv-disk-usb-device.args |2 +- .../qemuxml2argv-hostdev-pci-address-device.args |2 +- .../qemuxml2argv-hostdev-usb-address-device.args |2 +- .../qemuxml2argv-net-virtio-device.args|2 +- .../qemuxml2argv-parallel-tcp-chardev.args |2 +- .../qemuxml2argv-serial-dev-chardev.args |2 +- .../qemuxml2argv-serial-file-chardev.args |2 +- .../qemuxml2argv-serial-many-chardev.args |2 +- .../qemuxml2argv-serial-pty-chardev.args |2 +- .../qemuxml2argv-serial-tcp-chardev.args |2 +- .../qemuxml2argv-serial-tcp-telnet-chardev.args|2 +- .../qemuxml2argv-serial-udp-chardev.args |2 +- .../qemuxml2argv-serial-unix-chardev.args |2 +- .../qemuxml2argv-serial-vc-chardev.args|2 +- .../qemuxml2argv-sound-device.args |2 +- .../qemuxml2argv-watchdog-device.args |2 +- 19 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 415e6da..40c9e4b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -3748,8 +3748,14 @@ int qemudBuildCommandLine(virConnectPtr conn, /* QEMU changed its default behavior to not include the virtio balloon * device. Explicitly request it to ensure it will be present. + * + * NB: Earlier we declared that VirtIO balloon will always be in + * slot 0x3 on bus 0x0 */ -if (qemuCmdFlags QEMUD_CMD_FLAG_BALLOON) { +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +ADD_ARG_LIT(-device); +ADD_ARG_LIT(virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3); +} else if (qemuCmdFlags QEMUD_CMD_FLAG_BALLOON) { ADD_ARG_LIT(-balloon); ADD_ARG_LIT(virtio); } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args index e93e934..4102dd5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev pipe,id=channel0,path=/tmp/guestfwd -netdev user,guestfwd=tcp:10.0.2.1:4600,chardev=channel0,id=user-channel0 -usb +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev pipe,id=channel0,path=/tmp/guestfwd -netdev user,guestfwd=tcp:10.0.2.1:4600,chardev=channel0,id=user-channel0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args index 81ca364..a0c48ea 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args index d12d61c..9a41f66 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1
[libvirt] [PATCH 01/34] Make test suite output less verbose
Only print out '.' for each test case, full test output can be re-enabled with VIR_TEST_VERBOSE=1, or VIR_TEST_DEBUG= Sample output now looks like TEST: statstest 40 ... 75 OK PASS: statstest TEST: qparamtest 32 OK PASS: qparamtest TEST: 12 OK --- tests/capabilityschematest |5 ++- tests/daemon-conf | 27 ++ tests/domainschematest |5 ++- tests/esxutilstest.c|2 +- tests/eventtest.c | 78 ++--- tests/interfaceschematest |5 ++- tests/networkschematest |5 ++- tests/nodedevschematest |5 ++- tests/schematestutils.sh| 20 tests/statstest.c |4 +- tests/storagepoolschematest |5 ++- tests/storagevolschematest |5 ++- tests/test-lib.sh | 64 +++ tests/test_conf.sh | 23 +++-- tests/testutils.c | 117 +-- tests/testutils.h |4 +- tests/testutilsqemu.c |2 +- tests/virsh-all | 25 ++--- 18 files changed, 277 insertions(+), 124 deletions(-) diff --git a/tests/capabilityschematest b/tests/capabilityschematest index 3a1acc5..e32f85d 100755 --- a/tests/capabilityschematest +++ b/tests/capabilityschematest @@ -1,6 +1,9 @@ #!/bin/sh -. ./schematestutils.sh +test -z $srcdir srcdir=$(pwd) + +. $srcdir/test-lib.sh +. $abs_srcdir/schematestutils.sh DIRS=capabilityschemadata xencapsdata SCHEMA=capability.rng diff --git a/tests/daemon-conf b/tests/daemon-conf index 722fe4e..1eb4be1 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -2,15 +2,14 @@ # Get coverage of libvirtd's config-parsing code. test -z $srcdir srcdir=$(pwd) -test -z $abs_top_srcdir abs_top_srcdir=$(pwd)/.. -test -z $abs_top_builddir abs_top_builddir=$(pwd)/.. +LC_ALL=C +. $srcdir/test-lib.sh -if test $VERBOSE = yes; then - set -x +if test $verbose = yes; then $abs_top_builddir/daemon/libvirtd --version fi -. $srcdir/test-lib.sh +test_intro $this_test test -z $CONFIG_HEADER CONFIG_HEADER=$abs_top_builddir/config.h @@ -30,10 +29,12 @@ sed -n 's/^#\([^ #]\)/\1/p' $conf tmp.conf # time and running libvirtd with the resulting config. Each libvirtd # invocation must fail. n=$(wc -l tmp.conf) -i=1 +i=0 +fail=0 while :; do + i=$(expr $i + 1) + param_name=$(sed -n $i's/ = .*//p' tmp.conf) - printf testing with corrupted config: $param_name\n 12 rhs=$(sed -n $i's/.* = \(.*\)/\1/p' tmp.conf) f=in$i.conf case $rhs in @@ -59,9 +60,8 @@ while :; do # Check that the diagnostic we want appears grep $msg err 1/dev/null 21 RET=$? + test_result $i corrupted config $param_name $RET test $RET = 0 || fail=1 - - i=$(expr $i + 1) done # Run with the unmodified config file. @@ -76,13 +76,18 @@ sed 's,^log_outputs.*,log_outputs=3:file:'$(pwd)/log',' tmp.conf k \ || fail=1 mv k tmp.conf || fail=1 -printf running libvirtd with a valid config file ($sleep_secs seconds)\n 12 $abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf log 21 pid=$! sleep $sleep_secs kill $pid +RET=0 # Expect an orderly shut-down and successful exit. -wait $pid || fail=1 +wait $pid || RET=1 + +test_result $i valid config file (sleeping $sleep_secs seconds) $RET +test $RET = 0 || fail=1 + +test_final $i $fail # cat log would print this for non-root: # Cannot set group when not running as root diff --git a/tests/domainschematest b/tests/domainschematest index 28ee69a..41a5f47 100755 --- a/tests/domainschematest +++ b/tests/domainschematest @@ -1,6 +1,9 @@ #!/bin/sh -. ./schematestutils.sh +test -z $srcdir srcdir=$(pwd) + +. $srcdir/test-lib.sh +. $abs_srcdir/schematestutils.sh DIRS=domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata SCHEMA=domain.rng diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c index 058280d..f73df48 100644 --- a/tests/esxutilstest.c +++ b/tests/esxutilstest.c @@ -75,7 +75,7 @@ testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED) k = virDiskNameToIndex(name); if (k != i) { -if (virtTestGetDebug() 0) { +if (virTestGetDebug() 0) { fprintf(stderr, \nExpect [%d]\n, i); fprintf(stderr, Actual [%d]\n, k); } diff --git a/tests/eventtest.c b/tests/eventtest.c index 90c60bb..067e365 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -139,7 +139,7 @@ static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) { static int -verifyFired(int handle, int timer) +verifyFired(const char *name, int handle, int timer) { int handleFired = 0; int timerFired = 0; @@ -147,25 +147,25 @@ verifyFired(int handle, int timer) for (i = 0 ; i NUM_FDS ; i++) {
Re: [libvirt] [PATCH] esx: Dump the raw response in case of an SOAP fault
On Tue, Jan 05, 2010 at 03:01:06AM +0100, Matthias Bolte wrote: Currently only the faultcode and faultstring are deserialized, the detail part is ignored. The implementation of many new SOAP types would be necessary to deserialize the detail part correctly. As an intermediate solution the raw response is dumped to the debug log. --- src/esx/esx_vi.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index bad987c..9cade3d 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -692,6 +692,12 @@ esxVI_Context_Execute(virConnectPtr conn, esxVI_Context *ctx, HTTP response code %d for call to '%s'. Fault: %s - %s, (*response)-responseCode, methodName, fault-faultcode, fault-faultstring); + +/* FIXME: Dump raw response until detail part gets deserialized */ +VIR_DEBUG(HTTP response code %d for call to '%s' %s, + (*response)-responseCode, methodName, + (*response)-content); + goto failure; } else { if (virAsprintf(xpathExpression, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 10/34] Implement SCSI controller hotplug/unplug for QEMU
From: Wolfgang Mauerer wolfgang.maue...@siemens.com This patch allows for explicit hotplug/unplug of SCSI controllers. Ordinarily this is not required, since QEMU/libvirt will attach a new SCSI controller whenever one is required. Allowing explicit hotplug of controllers though, enables the caller to specify a static PCI address, instead of auto-assigning the next available PCI slot. Or it will when we have static PCI addressing. This patch is derived from Wolfgang Mauerer's disk controller patch series. * src/qemu/qemu_driver.c: Support hotplug unplug of SCSI controllers * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h, src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add new API for attaching PCI SCSI controllers --- src/libvirt_private.syms |2 + src/qemu/qemu_driver.c | 118 ++ src/qemu/qemu_monitor.c | 16 ++ src/qemu/qemu_monitor.h |4 ++ src/qemu/qemu_monitor_json.c | 40 ++ src/qemu/qemu_monitor_json.h |4 ++ src/qemu/qemu_monitor_text.c | 45 src/qemu/qemu_monitor_text.h |5 ++ 8 files changed, 234 insertions(+), 0 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a346aa5..fa8825f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -183,6 +183,8 @@ virDomainDeviceAddressIsValid; virDomainDevicePCIAddressIsValid; virDomainDeviceInfoIsSet; virDomainDeviceAddressClear; +virDomainControllerTypeToString; +virDomainControllerDefFree; # domain_event.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8c2e6d6..9dcbe25 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5111,6 +5111,45 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, return ret; } +static int qemudDomainAttachPciControllerDevice(virConnectPtr conn, +struct qemud_driver *driver, +virDomainObjPtr vm, +virDomainControllerDefPtr def) +{ +int i, ret; +const char* type = virDomainControllerTypeToString(def-type); +qemuDomainObjPrivatePtr priv = vm-privateData; + +for (i = 0 ; i vm-def-ncontrollers ; i++) { +if ((vm-def-controllers[i]-type == def-type) +(vm-def-controllers[i]-idx == def-idx)) { +qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, + _(target %s:%d already exists), + type, def-idx); +return -1; +} +} + +if (VIR_REALLOC_N(vm-def-controllers, vm-def-ncontrollers+1) 0) { +virReportOOMError(conn); +return -1; +} + +qemuDomainObjEnterMonitorWithDriver(driver, vm); +ret = qemuMonitorAttachPCIDiskController(priv-mon, + type, + def-info.addr.pci); +qemuDomainObjExitMonitorWithDriver(driver, vm); + +if (ret == 0) { +def-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; +virDomainControllerInsertPreAlloced(vm-def, def); +} + +return ret; +} + + static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, @@ -5496,6 +5535,15 @@ static int qemudDomainAttachDevice(virDomainPtr dom, virCgroupDenyDevicePath(cgroup, dev-data.disk-src); } +} else if (dev-type == VIR_DOMAIN_DEVICE_CONTROLLER) { +if (dev-data.controller-type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { +ret = qemudDomainAttachPciControllerDevice(dom-conn, driver, vm, dev-data.controller); +} else { +qemudReportError(dom-conn, dom, NULL, VIR_ERR_NO_SUPPORT, + _(disk controller bus '%s' cannot be hotplugged.), + virDomainControllerTypeToString(dev-data.controller-type)); +/* fallthrough */ +} } else if (dev-type == VIR_DOMAIN_DEVICE_NET) { ret = qemudDomainAttachNetDevice(dom-conn, driver, vm, dev, qemuCmdFlags); } else if (dev-type == VIR_DOMAIN_DEVICE_HOSTDEV) { @@ -5587,6 +5635,67 @@ cleanup: return ret; } +static int qemudDomainDetachPciControllerDevice(virConnectPtr conn, +struct qemud_driver *driver, +virDomainObjPtr vm, +virDomainDeviceDefPtr dev) +{ +int i, ret = -1; +virDomainControllerDefPtr detach = NULL; +qemuDomainObjPrivatePtr priv = vm-privateData; + +for (i = 0 ; i vm-def-ncontrollers ; i++) { +if
[libvirt] [PATCH 05/34] Set default disk controller/bus/unit props
When parsing the disk element specification, if no address is provided for the disk, then automatically assign one based on the target dev='sdXX'/ device name. This provides for backwards compatability with existing applications using libvirt, while also allowing new apps to have complete fine grained control. * src/conf/domain_conf.h, src/conf/domain_conf.c, src/libvirt_private.syms: Add virDomainDiskDefAssignAddress() for assigning a controller/bus/unit address based on disk target * src/qemu/qemu_conf.c: Call virDomainDiskDefAssignAddress() after generating XML from ARGV * tests/qemuxml2argvdata/*.xml: Add in drive address information to all XML files --- src/conf/domain_conf.c | 44 +++- src/conf/domain_conf.h |1 + src/libvirt_private.syms |1 + src/qemu/qemu_conf.c |4 ++ tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml |1 + .../qemuxml2argvdata/qemuxml2argv-boot-floppy.xml |2 + .../qemuxml2argvdata/qemuxml2argv-boot-network.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml |1 + .../qemuxml2argv-channel-guestfwd.xml |1 + .../qemuxml2argv-clock-localtime.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml |1 + .../qemuxml2argv-console-compat-chardev.xml|1 + .../qemuxml2argv-console-compat.xml|1 + .../qemuxml2argv-disk-cdrom-empty.xml |2 + tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml |2 + .../qemuxml2argv-disk-drive-boot-cdrom.xml |2 + .../qemuxml2argv-disk-drive-boot-disk.xml |2 + .../qemuxml2argv-disk-drive-cache-v1-none.xml |2 + .../qemuxml2argv-disk-drive-cache-v1-wb.xml|2 + .../qemuxml2argv-disk-drive-cache-v1-wt.xml|2 + .../qemuxml2argv-disk-drive-cache-v2-none.xml |2 + .../qemuxml2argv-disk-drive-cache-v2-wb.xml|2 + .../qemuxml2argv-disk-drive-cache-v2-wt.xml|2 + .../qemuxml2argv-disk-drive-fat.xml|1 + .../qemuxml2argv-disk-drive-fmt-qcow.xml |2 + .../qemuxml2argv-disk-drive-shared.xml |2 + .../qemuxml2argvdata/qemuxml2argv-disk-floppy.xml |3 + tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml |4 ++ tests/qemuxml2argvdata/qemuxml2argv-disk-usb.xml |1 + .../qemuxml2argvdata/qemuxml2argv-disk-virtio.xml |3 + .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml |2 + .../qemuxml2argv-floppy-drive-fat.xml |1 + .../qemuxml2argv-graphics-sdl-fullscreen.xml |1 + .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml |1 + .../qemuxml2argv-graphics-vnc-sasl.xml |1 + .../qemuxml2argv-graphics-vnc-tls.xml |1 + .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml |1 + .../qemuxml2argv-hostdev-pci-address.xml |1 + .../qemuxml2argv-hostdev-usb-address.xml |1 + .../qemuxml2argv-hostdev-usb-product.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml |1 + .../qemuxml2argv-input-usbmouse.xml|1 + .../qemuxml2argv-input-usbtablet.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml |1 + .../qemuxml2argv-machine-aliases1.xml |1 + .../qemuxml2argv-machine-aliases2.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-migrate.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-minimal.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml |1 + .../qemuxml2argv-misc-no-reboot.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml |1 + .../qemuxml2argv-net-eth-ifname.xml|1 + .../qemuxml2argv-net-eth-names.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-net-user.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-net-virtio.xml |1 + .../qemuxml2argv-parallel-tcp-chardev.xml |1 + .../qemuxml2argvdata/qemuxml2argv-parallel-tcp.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml |1 + tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml |1 + .../qemuxml2argv-serial-dev-chardev.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml |1 + .../qemuxml2argv-serial-file-chardev.xml |1 + .../qemuxml2argvdata/qemuxml2argv-serial-file.xml |1 + .../qemuxml2argv-serial-many-chardev.xml |1 + .../qemuxml2argvdata/qemuxml2argv-serial-many.xml |1 + .../qemuxml2argv-serial-pty-chardev.xml|1 + tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml |1 + .../qemuxml2argv-serial-tcp-chardev.xml|1 + .../qemuxml2argv-serial-tcp-telnet-chardev.xml |1 +
[libvirt] [PATCH 12/34] Detect PCI addresses at QEMU startup
Hotunplug of devices requires that we know their PCI address. Even hotplug of SCSI drives, required that we know the PCI address of the SCSI controller to attach the drive to. We can find this out by running 'info pci' and then correlating the vendor/product IDs with the devices we booted with. Although this approach is somewhat fragile, it is the only viable option with QEMU 0.12, since there is no way for libvirto set explicit PCI addresses when creating devices in the first place. For QEMU 0.12, this code will not be used. * src/qemu/qemu_driver.c: Assign all dynamic PCI addresses on startup of QEMU VM, matching vendor/product IDs * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h, src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add API for fetching PCI device address mapping --- src/qemu/qemu_driver.c | 361 ++ src/qemu/qemu_monitor.c | 13 ++ src/qemu/qemu_monitor.h | 11 ++ src/qemu/qemu_monitor_json.c |7 + src/qemu/qemu_monitor_json.h |3 + src/qemu/qemu_monitor_text.c | 129 +++ src/qemu/qemu_monitor_text.h |2 + 7 files changed, 526 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 33c96d6..cd406ec 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1677,6 +1677,364 @@ qemuInitPasswords(struct qemud_driver *driver, } +#define QEMU_PCI_VENDOR_INTEL 0x8086 +#define QEMU_PCI_VENDOR_LSI_LOGIC 0x1000 +#define QEMU_PCI_VENDOR_REDHAT0x1af4 +#define QEMU_PCI_VENDOR_CIRRUS0x1013 +#define QEMU_PCI_VENDOR_REALTEK 0x10ec +#define QEMU_PCI_VENDOR_AMD 0x1022 +#define QEMU_PCI_VENDOR_ENSONIQ 0x1274 +#define QEMU_PCI_VENDOR_VMWARE0x15ad +#define QEMU_PCI_VENDOR_QEMU 0x1234 + +#define QEMU_PCI_PRODUCT_DISK_VIRTIO 0x1001 + +#define QEMU_PCI_PRODUCT_NIC_NE2K 0x8029 +#define QEMU_PCI_PRODUCT_NIC_PCNET0x2000 +#define QEMU_PCI_PRODUCT_NIC_RTL8139 0x8139 +#define QEMU_PCI_PRODUCT_NIC_E10000x100E +#define QEMU_PCI_PRODUCT_NIC_VIRTIO 0x1000 + +#define QEMU_PCI_PRODUCT_VGA_CIRRUS 0x00b8 +#define QEMU_PCI_PRODUCT_VGA_VMWARE 0x0405 +#define QEMU_PCI_PRODUCT_VGA_STDVGA 0x + +#define QEMU_PCI_PRODUCT_AUDIO_AC970x2415 +#define QEMU_PCI_PRODUCT_AUDIO_ES1370 0x5000 + +#define QEMU_PCI_PRODUCT_CONTROLLER_PIIX 0x7010 +#define QEMU_PCI_PRODUCT_CONTROLLER_LSI 0x0012 + +#define QEMU_PCI_PRODUCT_WATCHDOG_I63000ESB 0x25ab + +static int +qemuAssignNextPCIAddress(virDomainDeviceInfo *info, + int vendor, + int product, + qemuMonitorPCIAddress *addrs, + int naddrs) +{ +int found = 0; +int i; + +VIR_DEBUG(Look for %x:%x out of %d, vendor, product, naddrs); + +for (i = 0 ; (i naddrs) !found; i++) { +VIR_DEBUG(Maybe %x:%x, addrs[i].vendor, addrs[i].product); +if (addrs[i].vendor == vendor +addrs[i].product == product) { +VIR_DEBUG(Match %d, i); +found = 1; +break; +} +} +if (!found) { +return -1; +} + +/* Blank it out so this device isn't matched again */ +addrs[i].vendor = 0; +addrs[i].product = 0; + +if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +info-type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + +if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +info-addr.pci.domain = addrs[i].addr.domain; +info-addr.pci.bus = addrs[i].addr.bus; +info-addr.pci.slot = addrs[i].addr.slot; +info-addr.pci.function = addrs[i].addr.function; +} + +return 0; +} + +static int +qemuGetPCIDiskVendorProduct(virDomainDiskDefPtr def, +unsigned *vendor, +unsigned *product) +{ +switch (def-bus) { +case VIR_DOMAIN_DISK_BUS_VIRTIO: +*vendor = QEMU_PCI_VENDOR_REDHAT; +*product = QEMU_PCI_PRODUCT_DISK_VIRTIO; +break; + +default: +return -1; +} + +return 0; +} + +static int +qemuGetPCINetVendorProduct(virDomainNetDefPtr def, +unsigned *vendor, +unsigned *product) +{ +if (!def-model) +return -1; + +if (STREQ(def-model, ne2k_pci)) { +*vendor = QEMU_PCI_VENDOR_REALTEK; +*product = QEMU_PCI_PRODUCT_NIC_NE2K; +} else if (STREQ(def-model, pcnet)) { +*vendor = QEMU_PCI_VENDOR_AMD; +*product = QEMU_PCI_PRODUCT_NIC_PCNET; +} else if (STREQ(def-model, rtl8139)) { +*vendor = QEMU_PCI_VENDOR_REALTEK; +*product = QEMU_PCI_PRODUCT_NIC_RTL8139; +} else if (STREQ(def-model, e1000)) { +*vendor = QEMU_PCI_VENDOR_INTEL; +*product = QEMU_PCI_PRODUCT_NIC_E1000; +} else if (STREQ(def-model, virtio)) { +*vendor = QEMU_PCI_VENDOR_REDHAT; +*product =
[libvirt] [PATCH 07/34] Convert monitor over to use virDomainDeviceAddress
Convert the QEMU monitor APIs over to use virDomainDeviceAddress structs for passing addresses in/out, instead of individual bits. This makes the number of parameters smaller easier to deal with. No functional change * src/qemu/qemu_driver.c, src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Change monitor hotplug APIs to take an explicit address ptr for all host/guest addresses --- src/qemu/qemu_driver.c | 35 +--- src/qemu/qemu_monitor.c | 60 -- src/qemu/qemu_monitor.h | 21 +++--- src/qemu/qemu_monitor_json.c | 55 +- src/qemu/qemu_monitor_json.h | 22 +++ src/qemu/qemu_monitor_text.c | 56 ++- src/qemu/qemu_monitor_text.h | 22 +++ 7 files changed, 90 insertions(+), 181 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3588531..8c2e6d6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5080,6 +5080,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, int i, ret; const char* type = virDomainDiskBusTypeToString(dev-data.disk-bus); qemuDomainObjPrivatePtr priv = vm-privateData; +virDomainDevicePCIAddress guestAddr; for (i = 0 ; i vm-def-ndisks ; i++) { if (STREQ(vm-def-disks[i]-dst, dev-data.disk-dst)) { @@ -5098,13 +5099,12 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, ret = qemuMonitorAddPCIDisk(priv-mon, dev-data.disk-src, type, -dev-data.disk-info.addr.pci.domain, -dev-data.disk-info.addr.pci.bus, -dev-data.disk-info.addr.pci.slot); +guestAddr); qemuDomainObjExitMonitorWithDriver(driver, vm); if (ret == 0) { dev-data.disk-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; +memcpy(dev-data.disk-info.addr.pci, guestAddr, sizeof(guestAddr)); virDomainDiskInsertPreAlloced(vm-def, dev-data.disk); } @@ -5161,6 +5161,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, char *nicstr = NULL; char *netstr = NULL; int ret = -1; +virDomainDevicePCIAddress guestAddr; if (!(qemuCmdFlags QEMUD_CMD_FLAG_HOST_NET_ADD)) { qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, %s, @@ -5229,13 +5230,12 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuMonitorAddPCINetwork(priv-mon, nicstr, - net-info.addr.pci.domain, - net-info.addr.pci.bus, - net-info.addr.pci.slot) 0) { + guestAddr) 0) { qemuDomainObjExitMonitorWithDriver(driver, vm); goto try_remove; } net-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; +memcpy(net-info.addr.pci, guestAddr, sizeof(guestAddr)); qemuDomainObjExitMonitorWithDriver(driver, vm); ret = 0; @@ -5287,6 +5287,7 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn, virDomainHostdevDefPtr hostdev = dev-data.hostdev; pciDevice *pci; int ret; +virDomainDevicePCIAddress guestAddr; if (VIR_REALLOC_N(vm-def-hostdevs, vm-def-nhostdevs+1) 0) { virReportOOMError(conn); @@ -5314,17 +5315,13 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn, qemuDomainObjEnterMonitorWithDriver(driver, vm); ret = qemuMonitorAddPCIHostDevice(priv-mon, - hostdev-source.subsys.u.pci.domain, - hostdev-source.subsys.u.pci.bus, - hostdev-source.subsys.u.pci.slot, - hostdev-source.subsys.u.pci.function, - hostdev-info.addr.pci.domain, - hostdev-info.addr.pci.bus, - hostdev-info.addr.pci.slot); + hostdev-source.subsys.u.pci, + guestAddr); qemuDomainObjExitMonitorWithDriver(driver, vm); if (ret 0) goto error; hostdev-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; +memcpy(hostdev-info.addr.pci, guestAddr, sizeof(guestAddr)); vm-def-hostdevs[vm-def-nhostdevs++] = hostdev; @@ -5563,9 +5560,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuMonitorRemovePCIDevice(priv-mon, - detach-info.addr.pci.domain, - detach-info.addr.pci.bus, -
[libvirt] [PATCH 21/34] Convert character devices over to use -device
The current character device syntax uses either -serial tty,path=/dev/ttyS2 Or -chardev tty,id=serial0,path=/dev/ttyS2 -serial chardev:serial0 With the new -device support, we now prefer -chardev file,id=serial0,path=/tmp/serial.log -device isa-serial,chardev=serial0 This patch changes the existing -chardev syntax to use this new scheme, and fallbacks to the old plain -serial syntax for old QEMU. The monitor device changes to -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor In addition, this patch adds --nodefaults, which kills off the default serial, parallel, vga and nic devices. THis avoids the need for us to explicitly turn each off --- src/qemu/qemu_conf.c | 97 +-- src/qemu/qemu_driver.c |7 ++ .../qemuxml2argv-channel-guestfwd.args |2 +- .../qemuxml2argv-console-compat-chardev.args |2 +- .../qemuxml2argv-parallel-tcp-chardev.args |2 +- .../qemuxml2argv-serial-dev-chardev.args |2 +- .../qemuxml2argv-serial-file-chardev.args |2 +- .../qemuxml2argv-serial-many-chardev.args |2 +- .../qemuxml2argv-serial-pty-chardev.args |2 +- .../qemuxml2argv-serial-tcp-chardev.args |2 +- .../qemuxml2argv-serial-tcp-telnet-chardev.args|2 +- .../qemuxml2argv-serial-udp-chardev.args |2 +- .../qemuxml2argv-serial-unix-chardev.args |2 +- .../qemuxml2argv-serial-vc-chardev.args|2 +- tests/qemuxml2argvtest.c | 29 +++--- 15 files changed, 81 insertions(+), 76 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 5dcd50f..eded887 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1592,6 +1592,9 @@ static char *qemuDiskDriveName(const virDomainDiskDefPtr disk) case VIR_DOMAIN_DISK_BUS_VIRTIO: ret = virAsprintf(devname, virtio%d, devid); break; +case VIR_DOMAIN_DISK_BUS_XEN: +ret = virAsprintf(devname, xenblk%d, devid); +break; default: qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, _(Unsupported disk name mapping for bus '%s'), @@ -1991,43 +1994,42 @@ qemuBuildHostNetStr(virConnectPtr conn, /* This function outputs a -chardev command line option which describes only the * host side of the character device */ static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev, - const char *const id, virBufferPtr buf) { bool telnet; switch(dev-type) { case VIR_DOMAIN_CHR_TYPE_NULL: -virBufferVSprintf(buf, null,id=%s, id); +virBufferVSprintf(buf, null,id=%s, dev-info.alias); break; case VIR_DOMAIN_CHR_TYPE_VC: -virBufferVSprintf(buf, vc,id=%s, id); +virBufferVSprintf(buf, vc,id=%s, dev-info.alias); break; case VIR_DOMAIN_CHR_TYPE_PTY: -virBufferVSprintf(buf, pty,id=%s, id); +virBufferVSprintf(buf, pty,id=%s, dev-info.alias); break; case VIR_DOMAIN_CHR_TYPE_DEV: -virBufferVSprintf(buf, tty,id=%s,path=%s, id, dev-data.file.path); +virBufferVSprintf(buf, tty,id=%s,path=%s, dev-info.alias, dev-data.file.path); break; case VIR_DOMAIN_CHR_TYPE_FILE: -virBufferVSprintf(buf, file,id=%s,path=%s, id, dev-data.file.path); +virBufferVSprintf(buf, file,id=%s,path=%s, dev-info.alias, dev-data.file.path); break; case VIR_DOMAIN_CHR_TYPE_PIPE: -virBufferVSprintf(buf, pipe,id=%s,path=%s, id, dev-data.file.path); +virBufferVSprintf(buf, pipe,id=%s,path=%s, dev-info.alias, dev-data.file.path); break; case VIR_DOMAIN_CHR_TYPE_STDIO: -virBufferVSprintf(buf, stdio,id=%s, id); +virBufferVSprintf(buf, stdio,id=%s, dev-info.alias); break; case VIR_DOMAIN_CHR_TYPE_UDP: virBufferVSprintf(buf, udp,id=%s,host=%s,port=%s,localaddr=%s,localport=%s, - id, + dev-info.alias, dev-data.udp.connectHost, dev-data.udp.connectService, dev-data.udp.bindHost, @@ -2038,7 +2040,7 @@ static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev, telnet = dev-data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; virBufferVSprintf(buf, socket,id=%s,host=%s,port=%s%s%s, - id, + dev-info.alias, dev-data.tcp.host, dev-data.tcp.service, telnet ? ,telnet : , @@ -2048,7 +2050,7 @@ static void
[libvirt] [PATCH 23/34] Convert audio devices over to -device syntax
The current syntax for audio devices is a horrible multiplexed arg -soundhw sb16,pcspk,ac97 The new syntax is -device sb16,id=sound0 or -device AC97,id=sound1,addr=PCI SLOT NB, pcspk still uses the old -soundhw syntax --- src/qemu/qemu_conf.c | 97 .../qemuxml2argv-sound-device.args |1 + .../qemuxml2argvdata/qemuxml2argv-sound-device.xml | 26 + tests/qemuxml2argvtest.c |1 + 4 files changed, 106 insertions(+), 19 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-sound-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index fa16f8c..067fe42 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -2052,7 +2052,44 @@ error: return NULL; } -/* this function outputs a -chardev command line option which describes only the + +static char * +qemuBuildSoundDevStr(virDomainSoundDefPtr sound) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; +const char *model = virDomainSoundModelTypeToString(sound-model); + +if (!model) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + %s, _(invalid sound model)); +goto error; +} + +/* Hack for 2 wierdly unusal devices name in QEMU */ +if (STREQ(model, es1370)) +model = ES1370; +else if (STREQ(model, ac97)) +model = AC97; + +virBufferVSprintf(buf, %s, model); +virBufferVSprintf(buf, ,id=%s, sound-info.alias); +if (qemuBuildDeviceAddressStr(buf, sound-info) 0) +goto error; + +if (virBufferError(buf)) { +virReportOOMError(NULL); +goto error; +} + +return virBufferContentAndReset(buf); + +error: +virBufferFreeAndReset(buf); +return NULL; +} + + +/* This function outputs a -chardev command line option which describes only the * host side of the character device */ static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev, virBufferPtr buf) @@ -3121,27 +3158,49 @@ int qemudBuildCommandLine(virConnectPtr conn, /* Add sound hardware */ if (def-nsounds) { -int size = 100; -char *modstr; -if (VIR_ALLOC_N(modstr, size+1) 0) -goto no_memory; +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +for (i = 0 ; i def-nsounds ; i++) { +virDomainSoundDefPtr sound = def-sounds[i]; +char *str = NULL; + +/* Sadly pcspk device doesn't use -device syntax. Fortunately + * we don't need to set any PCI address on it, so we don't + * mind too much */ +if (sound-model == VIR_DOMAIN_SOUND_MODEL_PCSPK) { +ADD_ARG_LIT(-soundhw); +ADD_ARG_LIT(pcspk); +} else { +ADD_ARG_LIT(-device); -for (i = 0 ; i def-nsounds size 0 ; i++) { -virDomainSoundDefPtr sound = def-sounds[i]; -const char *model = virDomainSoundModelTypeToString(sound-model); -if (!model) { -VIR_FREE(modstr); -qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - %s, _(invalid sound model)); -goto error; +if (!(str = qemuBuildSoundDevStr(sound))) +goto error; + +ADD_ARG(str); +} +} +} else { +int size = 100; +char *modstr; +if (VIR_ALLOC_N(modstr, size+1) 0) +goto no_memory; + +for (i = 0 ; i def-nsounds size 0 ; i++) { +virDomainSoundDefPtr sound = def-sounds[i]; +const char *model = virDomainSoundModelTypeToString(sound-model); +if (!model) { +VIR_FREE(modstr); +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + %s, _(invalid sound model)); +goto error; +} +strncat(modstr, model, size); +size -= strlen(model); +if (i (def-nsounds - 1)) +strncat(modstr, ,, size--); } -strncat(modstr, model, size); -size -= strlen(model); -if (i (def-nsounds - 1)) - strncat(modstr, ,, size--); +ADD_ARG_LIT(-soundhw); +ADD_ARG(modstr); } -ADD_ARG_LIT(-soundhw); -ADD_ARG(modstr); } /* Add watchdog hardware */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args new file mode 100644 index 000..31ac0ee --- /dev/null +++
[libvirt] [PATCH 11/34] Properly support SCSI drive hotplug
The current SCSI hotplug support attaches a brand new SCSI controller for every disk. This is broken because the semantics differ from those used when starting the VM initially. In the latter case, each SCSI controller is filled before a new one is added. If the user specifies an high drive index (sdazz) then at initial startup, many intermediate SCSI controllers may be added with no drives. This patch changes SCSI hotplug so that it exactly matches the behaviour of initial startup. First the SCSI controller number is determined for the drive to be hotplugged. If any controller upto and including that controller number is not yet present, it is attached. Then finally the drive is attached to the last controller. NB, this breaks SCSI hotunplug, because there is no 'drive_del' command in current QEMU. Previous SCSI hotunplug was broken in any case because it was unplugging the entire controller, not just the drive in question. A future QEMU will allow proper SCSI hotunplug of a drive. This patch is derived from work done by Wolfgang Mauerer on disk controllers. * src/qemu/qemu_driver.c: Fix SCSI hotplug to add a drive to the correct controller, instead of just attaching a new controller. * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h, src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add support for 'drive_add' command --- src/libvirt_private.syms |1 + src/qemu/qemu_driver.c | 123 +++-- src/qemu/qemu_monitor.c | 20 +++ src/qemu/qemu_monitor.h |5 ++ src/qemu/qemu_monitor_json.c | 81 +--- src/qemu/qemu_monitor_json.h |5 ++ src/qemu/qemu_monitor_text.c | 102 ++ src/qemu/qemu_monitor_text.h |5 ++ 8 files changed, 329 insertions(+), 13 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fa8825f..ad57c49 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -185,6 +185,7 @@ virDomainDeviceInfoIsSet; virDomainDeviceAddressClear; virDomainControllerTypeToString; virDomainControllerDefFree; +virDomainDeviceAddressTypeToString; # domain_event.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9dcbe25..33c96d6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5149,6 +5149,116 @@ static int qemudDomainAttachPciControllerDevice(virConnectPtr conn, return ret; } +static virDomainControllerDefPtr +qemuDomainFindOrCreateSCSIDiskController(virConnectPtr conn, + struct qemud_driver *driver, + virDomainObjPtr vm, + int controller) +{ +int i; +virDomainControllerDefPtr cont; +for (i = 0 ; i vm-def-ncontrollers ; i++) { +cont = vm-def-controllers[i]; + +if (cont-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI) +continue; + +if (cont-idx == controller) +return cont; +} + +/* No SCSI controller present, for back compatability we + * now hotplug a controller */ +if (VIR_ALLOC(cont) 0) { +virReportOOMError(conn); +return NULL; +} +cont-type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI; +cont-idx = 0; + +VIR_INFO0(No SCSI controller present, hotplugging one); +if (qemudDomainAttachPciControllerDevice(conn, driver, + vm, cont) 0) { +VIR_FREE(cont); +return NULL; +} +return cont; +} + +static int qemudDomainAttachSCSIDisk(virConnectPtr conn, + struct qemud_driver *driver, + virDomainObjPtr vm, + virDomainDiskDefPtr dev, + int qemuCmdFlags) +{ +int i; +qemuDomainObjPrivatePtr priv = vm-privateData; +virDomainDeviceDriveAddress driveAddr; +virDomainControllerDefPtr cont; +char *drivestr = NULL; +int ret = -1; + +for (i = 0 ; i vm-def-ndisks ; i++) { +if (STREQ(vm-def-disks[i]-dst, dev-dst)) { +qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, + _(target %s already exists), dev-dst); +goto cleanup; +} +} + +/* This func allocates the bus/unit IDs so must be before + * we search for controller + */ +if (!(drivestr = qemuBuildDriveStr(dev, 0, qemuCmdFlags))) +goto cleanup; + + +/* We should have an adddress now, so make sure */ +if (dev-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unexpected disk address type %s), + virDomainDeviceAddressTypeToString(dev-info.type)); +goto cleanup; +} + +for (i = 0 ; i
[libvirt] [PATCH 25/34] Convert NICs over to use -device -netdev where possible
The current syntax uses a pair of args -net nic,macaddr=52:54:00:56:6c:55,vlan=3,model=pcnet,name=pcnet.0 -net user,vlan=3,name=user.0 The new syntax does not need the vlan craziness anymore, and so has a simplified pair of args -netdev user,id=user.0 -device pcnet,netdev=user.0,id=pcnet.0,mac=52:54:00:56:6c:55,addr=PCI SLOT --- src/qemu/qemu_conf.c | 175 .../qemuxml2argv-net-virtio-device.args|1 + .../qemuxml2argv-net-virtio-device.xml | 26 +++ tests/qemuxml2argvtest.c |1 + 4 files changed, 174 insertions(+), 29 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-device.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8b8455d..709c3f4 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1488,6 +1488,8 @@ qemuAssignDeviceAliases(virDomainDefPtr def) if (virAsprintf(def-nets[i]-info.alias, nic%d, i) 0) goto no_memory; } +if (virAsprintf(def-nets[i]-hostnet_name, netdev%d, i) 0) +goto no_memory; } for (i = 0; i def-nsounds ; i++) { @@ -2021,6 +2023,41 @@ qemuBuildNicStr(virConnectPtr conn, return 0; } +static char * +qemuBuildNicDevStr(virDomainNetDefPtr net) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; +const char *nic; + +if (!net-model) { +nic = rtl8139; +} else if (STREQ(net-model, virtio)) { +nic = virtio-net-pci; +} else { +nic = net-model; +} + +virBufferVSprintf(buf, %s,netdev=%s, nic, net-hostnet_name); +virBufferVSprintf(buf, ,id=%s, net-info.alias); +virBufferVSprintf(buf, ,mac=%02x:%02x:%02x:%02x:%02x:%02x, + net-mac[0], net-mac[1], + net-mac[2], net-mac[3], + net-mac[4], net-mac[5]); +if (qemuBuildDeviceAddressStr(buf, net-info) 0) +goto error; + +if (virBufferError(buf)) { +virReportOOMError(NULL); +goto error; +} + +return virBufferContentAndReset(buf); + +error: +virBufferFreeAndReset(buf); +return NULL; +} + int qemuBuildHostNetStr(virConnectPtr conn, virDomainNetDefPtr net, @@ -2118,6 +2155,88 @@ qemuBuildHostNetStr(virConnectPtr conn, } +static int +qemuBuildNetDevStr(virConnectPtr conn, + virDomainNetDefPtr net, + const char *tapfd, + char **str) +{ +switch (net-type) { +case VIR_DOMAIN_NET_TYPE_NETWORK: +case VIR_DOMAIN_NET_TYPE_BRIDGE: +if (virAsprintf(str, tap,fd=%s,id=%s, +tapfd, net-hostnet_name) 0) { +virReportOOMError(conn); +return -1; +} +break; + +case VIR_DOMAIN_NET_TYPE_ETHERNET: +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(buf, tap); +if (net-ifname) +virBufferVSprintf(buf, ,ifname=%s, net-ifname); +if (net-data.ethernet.script) +virBufferVSprintf(buf, ,script=%s, + net-data.ethernet.script); +if (net-hostnet_name) +virBufferVSprintf(buf, ,id=%s, + net-hostnet_name); +if (virBufferError(buf)) { +virBufferFreeAndReset(buf); +virReportOOMError(conn); +return -1; +} + +*str = virBufferContentAndReset(buf); +} +break; + +case VIR_DOMAIN_NET_TYPE_CLIENT: +case VIR_DOMAIN_NET_TYPE_SERVER: +case VIR_DOMAIN_NET_TYPE_MCAST: +{ +const char *mode = NULL; + +switch (net-type) { +case VIR_DOMAIN_NET_TYPE_CLIENT: +mode = connect; +break; +case VIR_DOMAIN_NET_TYPE_SERVER: +mode = listen; +break; +case VIR_DOMAIN_NET_TYPE_MCAST: +mode = mcast; +break; +} + +if (virAsprintf(str, socket,%s=%s:%d,id=%s, +mode, +net-data.socket.address, +net-data.socket.port, +net-hostnet_name) 0) { +virReportOOMError(conn); +return -1; +} +} +break; + +case VIR_DOMAIN_NET_TYPE_USER: +default: +if (virAsprintf(str, user,id=%s, +net-hostnet_name) 0) { +virReportOOMError(conn); +return -1; +} +break; +} + +return 0; +} + + static char *qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -2961,27 +3080,10 @@ int
[libvirt] [PATCH 24/34] Convert disk drive over to use -device where available
The current preferred syntax for disk drives uses -drive file=/vms/plain.qcow,if=virtio,index=0,boot=on,format=qcow The new syntax splits this up into a pair of linked args -drive file=/vms/plain.qcow,if=none,id=drive-virtio-0,format=qcow2 -device virtio-blk-pci,drive=drive-virtio-0,id=virtio-0,addr=PCI SLOT SCSI/IDE devices also get a bus property linking them to the controller -device scsi-disk,drive=drive-scsi0-0-0,id=scsi0-0-0,bus=scsi0.0,scsi-id=0 -device ide-drive,drive=drive-ide0-0-0,id=ide0-0-0,bus=ide0,unit=0 --- src/qemu/qemu_conf.c | 157 +++--- 1 files changed, 148 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 067fe42..8b8455d 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1852,17 +1852,26 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferVSprintf(opt, file=%s,, disk-src); } } -virBufferVSprintf(opt, if=%s, bus); +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) +virBufferAddLit(opt, if=none); +else +virBufferVSprintf(opt, if=%s, bus); + if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM) virBufferAddLit(opt, ,media=cdrom); -if (busid == -1 unitid == -1) { -if (idx != -1) -virBufferVSprintf(opt, ,index=%d, idx); + +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +virBufferVSprintf(opt, ,id=drive-%s, disk-info.alias); } else { -if (busid != -1) -virBufferVSprintf(opt, ,bus=%d, busid); -if (unitid != -1) -virBufferVSprintf(opt, ,unit=%d, unitid); +if (busid == -1 unitid == -1) { +if (idx != -1) +virBufferVSprintf(opt, ,index=%d, idx); +} else { +if (busid != -1) +virBufferVSprintf(opt, ,bus=%d, busid); +if (unitid != -1) +virBufferVSprintf(opt, ,unit=%d, unitid); +} } if (bootable disk-device == VIR_DOMAIN_DISK_DEVICE_DISK) @@ -1901,6 +1910,91 @@ error: return NULL; } +static int +qemuBuildDriveDevStr(virConnectPtr conn, + virDomainDiskDefPtr disk, + char **str) +{ +virBuffer opt = VIR_BUFFER_INITIALIZER; +const char *bus = virDomainDiskQEMUBusTypeToString(disk-bus); +int idx = virDiskNameToIndex(disk-dst); + +if (idx 0) { +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unsupported disk type '%s'), disk-dst); +goto error; +} + +switch (disk-bus) { +case VIR_DOMAIN_DISK_BUS_IDE: +virBufferAddLit(opt, ide-drive); +virBufferVSprintf(opt, ,bus=ide.%d,unit=%d, + disk-info.addr.drive.bus, + disk-info.addr.drive.unit); +break; +case VIR_DOMAIN_DISK_BUS_SCSI: +virBufferAddLit(opt, scsi-disk); +virBufferVSprintf(opt, ,bus=scsi%d.%d,scsi-id=%d, + disk-info.addr.drive.controller, + disk-info.addr.drive.bus, + disk-info.addr.drive.unit); +break; +case VIR_DOMAIN_DISK_BUS_VIRTIO: +virBufferAddLit(opt, virtio-blk-pci); +qemuBuildDeviceAddressStr(opt, disk-info); +break; + +default: +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unsupported disk bus '%s' with device setup), bus); +goto error; +} +virBufferVSprintf(opt, ,drive=drive-%s, disk-info.alias); +virBufferVSprintf(opt, ,id=%s, disk-info.alias); + +*str = virBufferContentAndReset(opt); +return 0; + +error: +virBufferFreeAndReset(opt); +*str = NULL; +return -1; +} + + +static char * +qemuBuildControllerDevStr(virDomainControllerDefPtr def) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; + +switch (def-type) { +case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: +virBufferAddLit(buf, lsi); +virBufferVSprintf(buf, ,id=scsi%d, def-idx); +break; + +case VIR_DOMAIN_CONTROLLER_TYPE_IDE: +virBufferAddLit(buf, piix4-ide); +virBufferVSprintf(buf, ,id=ide%d, def-idx); +break; + +default: +goto error; +} + +if (qemuBuildDeviceAddressStr(buf, def-info) 0) +goto error; + +if (virBufferError(buf)) +goto error; + +return virBufferContentAndReset(buf); + +error: +virBufferFreeAndReset(buf); +return NULL; +} + int qemuBuildNicStr(virConnectPtr conn, @@ -2692,6 +2786,21 @@ int qemudBuildCommandLine(virConnectPtr conn, } } +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +for (i = 0 ; i def-ncontrollers ; i++) { +char *scsi; +if (def-controllers[i]-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI) +continue; + +ADD_ARG_LIT(-device); + +if (!(scsi =
[libvirt] [PATCH 09/34] Specify bus/unit instead of index for disks with QEMU
The current code for using -drive simply sets the -drive 'index' parameter. QEMU internally converts this to bus/unit depending on the type of drive. This does not give us precise control over the bus/unit assignment though. This change switches over to make libvirt explicitly calculate the bus/unit number. In addition bus/unit/index are actually irrelevant for VirtIO disks, since each virtio disk is a separate PCI device. No disk controller is involved. Doing the conversion to bus/unit in libvirt allows us to correctly attach SCSI controllers when required. * src/qemu/qemu_conf.c: Specify bus/unit instead of index for disks * tests/qemuxml2argvdata/qemuxml2argv-disk*.args: Switch over from using index=, to bus=NN, unit=NN for SCSI/IDE/Floppy disks --- src/qemu/qemu_conf.c | 134 +++- .../qemuxml2argv-disk-cdrom-empty.args |2 +- .../qemuxml2argv-disk-drive-boot-cdrom.args|2 +- .../qemuxml2argv-disk-drive-boot-disk.args |2 +- .../qemuxml2argv-disk-drive-cache-v1-none.args |2 +- .../qemuxml2argv-disk-drive-cache-v1-wb.args |2 +- .../qemuxml2argv-disk-drive-cache-v1-wt.args |2 +- .../qemuxml2argv-disk-drive-cache-v2-none.args |2 +- .../qemuxml2argv-disk-drive-cache-v2-wb.args |2 +- .../qemuxml2argv-disk-drive-cache-v2-wt.args |2 +- .../qemuxml2argv-disk-drive-fat.args |2 +- .../qemuxml2argv-disk-drive-fmt-qcow.args |2 +- .../qemuxml2argv-disk-drive-shared.args|2 +- .../qemuxml2argvdata/qemuxml2argv-disk-virtio.args |2 +- .../qemuxml2argvdata/qemuxml2argv-disk-virtio.xml |2 +- .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args |2 +- .../qemuxml2argv-floppy-drive-fat.args |2 +- 17 files changed, 145 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 94f4cc0..26baece 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1549,6 +1549,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk-bus); int idx = virDiskNameToIndex(disk-dst); +int busid = -1, unitid = -1; if (idx 0) { qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, @@ -1556,6 +1557,74 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, goto error; } +switch (disk-bus) { +case VIR_DOMAIN_DISK_BUS_SCSI: +if (disk-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(unexpected address type for scsi disk)); +goto error; +} + +/* Setting bus= attr for SCSI drives, causes a controller + * to be created. Yes this is slightly odd. It is not possible + * to have 1 bus on a SCSI controller (yet). */ +if (disk-info.addr.drive.bus != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(SCSI controller only supports 1 bus)); +goto error; +} +busid = disk-info.addr.drive.controller; +unitid = disk-info.addr.drive.unit; +break; + +case VIR_DOMAIN_DISK_BUS_IDE: +if (disk-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(unexpected address type for ide disk)); +goto error; +} +/* We can only have 1 IDE controller (currently) */ +if (disk-info.addr.drive.controller != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(Only 1 %s controller is supported), bus); +goto error; +} +busid = disk-info.addr.drive.bus; +unitid = disk-info.addr.drive.unit; +break; + +case VIR_DOMAIN_DISK_BUS_FDC: +if (disk-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(unexpected address type for fdc disk)); +goto error; +} +/* We can only have 1 FDC controller (currently) */ +if (disk-info.addr.drive.controller != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(Only 1 %s controller is supported), bus); +goto error; +} +/* We can only have 1 FDC bus (currently) */ +if (disk-info.addr.drive.bus != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(Only 1 %s bus is supported), bus); +goto error; +} +unitid = disk-info.addr.drive.unit; + +break; + +case VIR_DOMAIN_DISK_BUS_VIRTIO: +
[libvirt] [PATCH 13/34] Remove restriction on duplicated sound devices in parser
It is perfectly acceptable to have multiple sound devices of same type in guest configuration. If the underlying hypervisor does not like this, it is its job to complain, not the XML parser's * src/conf/domain_conf.c: Remove hack which deleted duplicated sound device models. * tests/xml2sexprdata/xml2sexpr-fv-sound.xml: Remove duplicate models --- src/conf/domain_conf.c | 11 --- tests/xml2sexprdata/xml2sexpr-fv-sound.xml |3 --- 2 files changed, 0 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dd10f36..5caf2ca 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3756,23 +3756,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (n VIR_ALLOC_N(def-sounds, n) 0) goto no_memory; for (i = 0 ; i n ; i++) { -int collision = 0, j; virDomainSoundDefPtr sound = virDomainSoundDefParseXML(conn, nodes[i], flags); if (!sound) goto error; -/* Verify there's no duplicated sound card */ -for (j = 0 ; j def-nsounds ; j++) { -if (def-sounds[j]-model == sound-model) -collision = 1; -} -if (collision) { -virDomainSoundDefFree(sound); -continue; -} - def-sounds[def-nsounds++] = sound; } VIR_FREE(nodes); diff --git a/tests/xml2sexprdata/xml2sexpr-fv-sound.xml b/tests/xml2sexprdata/xml2sexpr-fv-sound.xml index 0fe92fe..75c295c 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv-sound.xml +++ b/tests/xml2sexprdata/xml2sexpr-fv-sound.xml @@ -32,9 +32,6 @@ /disk graphics type='vnc' port='5917' keymap='ja'/ sound model='sb16'/ -sound model='sb16'/ -sound model='es1370'/ -sound model='sb16'/ sound model='es1370'/ /devices /domain -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 26/34] Convert USB disks over to -device
The previous syntax was severely limited in its options -usbdevice disk:/home/berrange/output.img The new syntax is the same as for other disk types -drive file=/home/berrange/output.img,if=none,id=usb-1,index=1 -device usb-storage,drive=usb-1 Again, the index= arg is wrong here, and will be removed in a later merge --- src/qemu/qemu_conf.c |9 +- .../qemuxml2argv-disk-usb-device.args |1 + .../qemuxml2argv-disk-usb-device.xml | 26 tests/qemuxml2argvtest.c |1 + 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 709c3f4..53866eb 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1945,7 +1945,9 @@ qemuBuildDriveDevStr(virConnectPtr conn, virBufferAddLit(opt, virtio-blk-pci); qemuBuildDeviceAddressStr(opt, disk-info); break; - +case VIR_DOMAIN_DISK_BUS_USB: +virBufferAddLit(opt, usb-storage); +break; default: qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _(unsupported disk bus '%s' with device setup), bus); @@ -2947,7 +2949,10 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainDiskDefPtr disk = def-disks[i]; int withDeviceArg = 0; -if (disk-bus == VIR_DOMAIN_DISK_BUS_USB) { +/* Unless we have -device, then USB disks need special + handling */ +if ((disk-bus == VIR_DOMAIN_DISK_BUS_USB) +!(qemuCmdFlags QEMUD_CMD_FLAG_DEVICE)) { if (disk-device == VIR_DOMAIN_DISK_DEVICE_DISK) { ADD_USBDISK(disk-src); } else { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args new file mode 100644 index 000..d12d61c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/usbdisk.img,if=none,id=drive-usb-disk0 -device usb-storage,drive=drive-usb-disk0,id=usb-disk0 -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.xml new file mode 100644 index 000..d59e1c0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.xml @@ -0,0 +1,26 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219200/memory + currentMemory219200/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ +/disk +disk type='file' device='disk' + source file='/tmp/usbdisk.img'/ + target dev='sda' bus='usb'/ +/disk + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 645f6b4..8c88a79 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -235,6 +235,7 @@ mymain(int argc, char **argv) DO_TEST(disk-drive-cache-v2-none, QEMUD_CMD_FLAG_DRIVE | QEMUD_CMD_FLAG_DRIVE_CACHE_V2 | QEMUD_CMD_FLAG_DRIVE_FORMAT); DO_TEST(disk-usb, 0); +DO_TEST(disk-usb-device, QEMUD_CMD_FLAG_DRIVE | QEMUD_CMD_FLAG_DEVICE); DO_TEST(graphics-vnc, 0); driver.vncSASL = 1; -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 17/34] Introduce device aliases
This patch introduces the support for giving all devices a short, unique name, henceforth known as a 'device alias'. These aliases are not set by the end user, instead being assigned by the hypervisor if it decides it want to support this concept. The QEMU driver sets them whenever using the -device arg syntax and uses them for improved hotplug/hotunplug. it is the intent that other APIs (block / interface stats device hotplug) be able to accept device alias names in the future. The XML syntax is alias name=video0/ This may appear in any type of device that supports device info. * src/conf/domain_conf.c, src/conf/domain_conf.h: Add a 'alias' field to virDomainDeviceInfo struct parse/format it in XML * src/libvirt_private.syms: Export virDomainDefClearDeviceAliases * src/qemu/qemu_conf.c: Replace use of nic_name field with the standard device alias * src/qemu/qemu_driver.c: Clear device aliases at shutdown --- src/conf/domain_conf.c | 110 +++--- src/conf/domain_conf.h |4 +- src/libvirt_private.syms |1 + src/qemu/qemu_conf.c |8 ++-- src/qemu/qemu_driver.c |1 + 5 files changed, 82 insertions(+), 42 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ef5dbe9..7c5abde 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -805,50 +805,61 @@ int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info) { if (info-type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) return 1; +if (info-alias) +return 1; return 0; } void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) { +VIR_FREE(info-alias); memset(info-addr, 0, sizeof(info-addr)); info-type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; } -static void virDomainDeviceInfoClearField(virDomainDeviceInfoPtr info) +static void virDomainDeviceInfoClearField(virDomainDeviceInfoPtr info, int alias, int pciaddr) { -if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +if (alias) +VIR_FREE(info-alias); +if (pciaddr +info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { memset(info-addr, 0, sizeof(info-addr)); info-type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; } } -static void virDomainDefClearDeviceInfo(virDomainDefPtr def) +static void virDomainDefClearDeviceInfo(virDomainDefPtr def, int alias, int pciaddr) { int i; for (i = 0; i def-ndisks ; i++) -virDomainDeviceInfoClearField(def-disks[i]-info); +virDomainDeviceInfoClearField(def-disks[i]-info, alias, pciaddr); for (i = 0; i def-nnets ; i++) -virDomainDeviceInfoClearField(def-nets[i]-info); +virDomainDeviceInfoClearField(def-nets[i]-info, alias, pciaddr); for (i = 0; i def-nsounds ; i++) -virDomainDeviceInfoClearField(def-sounds[i]-info); +virDomainDeviceInfoClearField(def-sounds[i]-info, alias, pciaddr); for (i = 0; i def-nhostdevs ; i++) -virDomainDeviceInfoClearField(def-hostdevs[i]-info); +virDomainDeviceInfoClearField(def-hostdevs[i]-info, alias, pciaddr); for (i = 0; i def-nvideos ; i++) -virDomainDeviceInfoClearField(def-videos[i]-info); +virDomainDeviceInfoClearField(def-videos[i]-info, alias, pciaddr); for (i = 0; i def-ncontrollers ; i++) -virDomainDeviceInfoClearField(def-controllers[i]-info); +virDomainDeviceInfoClearField(def-controllers[i]-info, alias, pciaddr); if (def-watchdog) -virDomainDeviceInfoClearField(def-watchdog-info); +virDomainDeviceInfoClearField(def-watchdog-info, alias, pciaddr); } void virDomainDefClearPCIAddresses(virDomainDefPtr def) { -virDomainDefClearDeviceInfo(def); +virDomainDefClearDeviceInfo(def, 0, 1); +} + +void virDomainDefClearDeviceAliases(virDomainDefPtr def) +{ +virDomainDefClearDeviceInfo(def, 1, 0); } @@ -856,7 +867,8 @@ void virDomainDefClearPCIAddresses(virDomainDefPtr def) * @param address Device address to stringify */ static int virDomainDeviceInfoFormat(virBufferPtr buf, - virDomainDeviceInfoPtr info) + virDomainDeviceInfoPtr info, + int flags) { if (!info) { virDomainReportError(NULL, VIR_ERR_INTERNAL_ERROR, %s, @@ -864,6 +876,11 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf, return -1; } +if (info-alias +!(flags VIR_DOMAIN_XML_INACTIVE)) { +virBufferVSprintf(buf, alias name='%s'/\n, info-alias); +} + if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) return 0; @@ -1041,10 +1058,11 @@ static int virDomainDeviceInfoParseXML(virConnectPtr conn, xmlNodePtr node, virDomainDeviceInfoPtr info, -unsigned int flags ATTRIBUTE_UNUSED) +
[libvirt] [PATCH 18/34] Add device info to serial, parallel, channel, input fs devices
Although the serial, parallel, chanel, input fs devices do not have PCI address info, they can all have device aliases. Thus it neccessary to associate the virDomainDeviceInfo data with them all. * src/conf/domain_conf.c, src/conf/domain_conf.h: Add hooks for parsing / formatting device info for serial, parallel, channel input and fs devices. * docs/schemas/domain.rng: Associate device info with character devices, input fs device --- docs/schemas/domain.rng | 12 src/conf/domain_conf.c | 67 ++ src/conf/domain_conf.h |4 +++ 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index a32ce45..f4bef7b 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -600,6 +600,9 @@ /interleave /group /choice + optional + ref name=address/ + /optional /element /define define name=filesystemtgt @@ -990,6 +993,9 @@ /optional /element /optional + optional + ref name=address/ + /optional /interleave /define define name=qemucdevSrcType @@ -1119,6 +1125,9 @@ interleave ref name=qemucdevSrcDef/ ref name=guestfwdTarget/ + optional + ref name=address/ + /optional /interleave /element /define @@ -1139,6 +1148,9 @@ /choice /attribute /optional + optional + ref name=address/ + /optional /element /define define name=hostdev diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7c5abde..9c03aab 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -355,6 +355,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def) if (!def) return; +virDomainDeviceInfoClear(def-info); VIR_FREE(def); } @@ -391,6 +392,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def) VIR_FREE(def-src); VIR_FREE(def-dst); +virDomainDeviceInfoClear(def-info); VIR_FREE(def); } @@ -474,6 +476,8 @@ void virDomainChrDefFree(virDomainChrDefPtr def) break; } +virDomainDeviceInfoClear(def-info); + VIR_FREE(def); } @@ -844,11 +848,23 @@ static void virDomainDefClearDeviceInfo(virDomainDefPtr def, int alias, int pcia for (i = 0; i def-nhostdevs ; i++) virDomainDeviceInfoClearField(def-hostdevs[i]-info, alias, pciaddr); for (i = 0; i def-nvideos ; i++) -virDomainDeviceInfoClearField(def-videos[i]-info, alias, pciaddr); +virDomainDeviceInfoClearField(def-videos[i]-info, alias, pciaddr); for (i = 0; i def-ncontrollers ; i++) -virDomainDeviceInfoClearField(def-controllers[i]-info, alias, pciaddr); +virDomainDeviceInfoClearField(def-controllers[i]-info, alias, pciaddr); +for (i = 0; i def-nserials ; i++) +virDomainDeviceInfoClearField(def-serials[i]-info, alias, pciaddr); +for (i = 0; i def-nparallels ; i++) +virDomainDeviceInfoClearField(def-parallels[i]-info, alias, pciaddr); +for (i = 0; i def-nchannels ; i++) +virDomainDeviceInfoClearField(def-channels[i]-info, alias, pciaddr); +for (i = 0; i def-ninputs ; i++) +virDomainDeviceInfoClearField(def-inputs[i]-info, alias, pciaddr); +for (i = 0; i def-nfss ; i++) +virDomainDeviceInfoClearField(def-fss[i]-info, alias, pciaddr); if (def-watchdog) virDomainDeviceInfoClearField(def-watchdog-info, alias, pciaddr); +if (def-console) +virDomainDeviceInfoClearField(def-console-info, alias, pciaddr); } @@ -1485,7 +1501,7 @@ cleanup: static virDomainFSDefPtr virDomainFSDefParseXML(virConnectPtr conn, xmlNodePtr node, - int flags ATTRIBUTE_UNUSED) { + int flags) { virDomainFSDefPtr def; xmlNodePtr cur; char *type = NULL; @@ -1549,6 +1565,9 @@ virDomainFSDefParseXML(virConnectPtr conn, def-dst = target; target = NULL; +if (virDomainDeviceInfoParseXML(conn, node, def-info, flags) 0) +goto error; + cleanup: VIR_FREE(type); VIR_FREE(target); @@ -1890,7 +1909,7 @@ error: static virDomainChrDefPtr virDomainChrDefParseXML(virConnectPtr conn, xmlNodePtr node, -int flags ATTRIBUTE_UNUSED) { +int flags) { xmlNodePtr cur; char *type = NULL; char *bindHost = NULL; @@ -2184,6 +2203,9 @@ virDomainChrDefParseXML(virConnectPtr conn, break; } +if (virDomainDeviceInfoParseXML(conn, node, def-info, flags) 0) +goto error; + cleanup: VIR_FREE(mode); VIR_FREE(protocol); @@ -2210,7 +2232,7 @@ static virDomainInputDefPtr virDomainInputDefParseXML(virConnectPtr conn, const char *ostype, xmlNodePtr node, -
[libvirt] [PATCH 31/34] Add support for explicit -sdl flag to QEMU
Not all QEMU builds default to SDL graphics for their display. Newer QEMU now has an explicit -sdl flag, which we can use to explicitly request SDL intead of relying on the default. This protects libvirt against unexpected changes in graphics default * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Probe for -sdl flag and use it if it is found * tests/qemuhelptest.c: Add SDL flag to tests --- src/qemu/qemu_conf.c |8 src/qemu/qemu_conf.h |1 + tests/qemuhelptest.c | 13 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9cd53f9..b87b170 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1117,6 +1117,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_BALLOON; if (strstr(help, -device)) flags |= QEMUD_CMD_FLAG_DEVICE; +if (strstr(help, -sdl)) +flags |= QEMUD_CMD_FLAG_SDL; if (version = 9000) flags |= QEMUD_CMD_FLAG_VNC_COLON; @@ -3425,6 +3427,12 @@ int qemudBuildCommandLine(virConnectPtr conn, */ ADD_ENV_COPY(QEMU_AUDIO_DRV); ADD_ENV_COPY(SDL_AUDIODRIVER); + +/* New QEMU has this flag to let us explicitly ask for + * SDL graphics. This is better than relying on the + * default, since the default changes :-( */ +if (qemuCmdFlags QEMUD_CMD_FLAG_SDL) +ADD_ARG_LIT(-sdl); } if (def-nvideos) { diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 174d397..4a862d1 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -79,6 +79,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_MONITOR_JSON = (1 24), /* JSON mode for monitor */ QEMUD_CMD_FLAG_BALLOON = (1 25), /* -balloon available */ QEMUD_CMD_FLAG_DEVICE= (1 26), /* Is the new -chardev arg available */ +QEMUD_CMD_FLAG_SDL = (1 27), /* Is the new -sdl arg available */ }; /* Main driver state */ diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index c2d7942..5ae14a6 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -140,7 +140,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_DRIVE_SERIAL | QEMUD_CMD_FLAG_VGA | QEMUD_CMD_FLAG_0_10 | -QEMUD_CMD_FLAG_ENABLE_KVM, +QEMUD_CMD_FLAG_ENABLE_KVM | +QEMUD_CMD_FLAG_SDL, 10005, 0, 0); DO_TEST(qemu-kvm-0.10.5, QEMUD_CMD_FLAG_VNC_COLON | @@ -159,7 +160,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_VGA | QEMUD_CMD_FLAG_0_10 | QEMUD_CMD_FLAG_PCIDEVICE | -QEMUD_CMD_FLAG_MEM_PATH, +QEMUD_CMD_FLAG_MEM_PATH | +QEMUD_CMD_FLAG_SDL, 10005, 1, 0); DO_TEST(kvm-86, QEMUD_CMD_FLAG_VNC_COLON | @@ -177,7 +179,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_DRIVE_SERIAL | QEMUD_CMD_FLAG_VGA | QEMUD_CMD_FLAG_0_10 | -QEMUD_CMD_FLAG_PCIDEVICE, +QEMUD_CMD_FLAG_PCIDEVICE | +QEMUD_CMD_FLAG_SDL, 10050, 1, 0); DO_TEST(qemu-kvm-0.11.0-rc2, QEMUD_CMD_FLAG_VNC_COLON | @@ -198,7 +201,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_PCIDEVICE | QEMUD_CMD_FLAG_MEM_PATH | QEMUD_CMD_FLAG_ENABLE_KVM | -QEMUD_CMD_FLAG_BALLOON, +QEMUD_CMD_FLAG_BALLOON | +QEMUD_CMD_FLAG_SDL, 10092, 1, 0); DO_TEST(qemu-0.12.1, QEMUD_CMD_FLAG_VNC_COLON | @@ -214,6 +218,7 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_VGA | QEMUD_CMD_FLAG_0_10 | QEMUD_CMD_FLAG_ENABLE_KVM | +QEMUD_CMD_FLAG_SDL | QEMUD_CMD_FLAG_XEN_DOMID | QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX | QEMUD_CMD_FLAG_CHARDEV | -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 32/34] Pass -vga none if no video card specified
QEMU always configures a VGA card. If no video card is included in the libvirt XML, it is neccessary to explicitly turn off the default using -vga none * src/qemu/qemu_conf.c: Pass -vga none if no video card is configured * tests/qemuargv2xmltest.c, tests/qemuxml2argvtest.c: Test for handling -vga none. * tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.args, tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.xml: Test data files --- src/qemu/qemu_conf.c | 25 +-- tests/qemuargv2xmltest.c |1 + .../qemuxml2argv-nographics-vga.args |1 + .../qemuxml2argv-nographics-vga.xml| 24 +++ tests/qemuxml2argvtest.c |1 + 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b87b170..bb6e90f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -89,8 +89,8 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, std, cirrus, vmware, - NULL, /* no arg needed for xen */ - NULL /* don't support vbox */); + , /* no arg needed for xen */ + /* don't support vbox */); #define PROC_MOUNT_BUF_LEN 255 @@ -3447,7 +3447,7 @@ int qemudBuildCommandLine(virConnectPtr conn, /* nothing - vga has no effect on Xen pvfb */ } else { const char *vgastr = qemuVideoTypeToString(def-videos[0]-type); -if (!vgastr) { +if (!vgastr || STREQ(vgastr, )) { qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _(video type %s is not supported with QEMU), virDomainVideoTypeToString(def-videos[0]-type)); @@ -3480,6 +3480,13 @@ int qemudBuildCommandLine(virConnectPtr conn, goto error; } } +} else { +/* If we have -device, then we set -nodefault already */ +if (!(qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) +(qemuCmdFlags QEMUD_CMD_FLAG_VGA)) { +ADD_ARG_LIT(-vga); +ADD_ARG_LIT(none); +} } /* Add sound hardware */ @@ -5017,11 +5024,13 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, video = VIR_DOMAIN_VIDEO_TYPE_VGA; } else if (STREQ(arg, -vga)) { WANT_VALUE(); -video = qemuVideoTypeFromString(val); -if (video 0) { -qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _(unknown video adapter type '%s'), val); -goto error; +if (STRNEQ(val, none)) { +video = qemuVideoTypeFromString(val); +if (video 0) { +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _(unknown video adapter type '%s'), val); +goto error; +} } } else if (STREQ(arg, -cpu)) { WANT_VALUE(); diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 7f62bac..8326c57 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -185,6 +185,7 @@ mymain(int argc, char **argv) DO_TEST(graphics-sdl, 0); DO_TEST(graphics-sdl-fullscreen, 0); +DO_TEST(nographics-vga, QEMUD_CMD_FLAG_VGA); DO_TEST(input-usbmouse, 0); DO_TEST(input-usbtablet, 0); /* Can't rountrip xenner arch */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.args b/tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.args new file mode 100644 index 000..b8f10bb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vga none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.xml b/tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.xml new file mode 100644 index 000..533ea59 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.xml @@ -0,0 +1,24 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219200/memory + currentMemory219200/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk
[libvirt] [PATCH 33/34] Auto-assign PCI addresses
Instead of relying on QEMU to assign PCI addresses and then querying them with 'info pci', manually assign all PCI addresses before starting the guest. These addresses are not stable across reboots. That will come in a later patch NB, the PIIX3 (IDE, FDC, ISA-Bridge) will always have slot 1 and VGA will always have slot 2. We declare the Virtio Balloon gets slot 3, and then all remaining slots are for configured devices. * src/qemu/qemu_conf.c: If -device is supported, then assign all PCI addresses when building the command line * src/qemu/qemu_driver.c: Don't query monitor for PCI addresses if they have already been assigned * tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args, tests/qemuxml2argvdata/qemuxml2argv-net-virtio-device.args, tests/qemuxml2argvdata/qemuxml2argv-sound-device.args, tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.args: Update to include PCI slot/bus information --- src/qemu/qemu_conf.c | 108 +++- src/qemu/qemu_driver.c | 13 ++- .../qemuxml2argv-hostdev-pci-address-device.args |2 +- .../qemuxml2argv-net-virtio-device.args|2 +- .../qemuxml2argv-sound-device.args |2 +- .../qemuxml2argv-watchdog-device.args |2 +- 6 files changed, 121 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index bb6e90f..415e6da 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1547,6 +1547,108 @@ qemuAssignDeviceAliases(virDomainDefPtr def) } +static void +qemuAssignDevicePCISlot(virDomainDeviceInfoPtr info, +int slot) +{ +info-type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; +info-addr.pci.domain = 0; +info-addr.pci.bus = 0; +info-addr.pci.slot = slot; +info-addr.pci.function = 0; +} + +static void +qemuAssignDevicePCISlots(virDomainDefPtr def) +{ +int i; +/* + * slot = 0 - Host bridge + * slot = 1 - PIIX3 (ISA bridge, IDE controller, something else unknown, USB controller) + * slot = 2 - VGA + * slot = 3 - VirtIO Balloon + */ +int nextslot = 4; + +for (i = 0; i def-ndisks ; i++) { +if (def-disks[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +continue; + +/* Only VirtIO disks use PCI addrs */ +if (def-disks[i]-bus != VIR_DOMAIN_DISK_BUS_VIRTIO) +continue; + +qemuAssignDevicePCISlot(def-disks[i]-info, nextslot++); +} + +for (i = 0; i def-nnets ; i++) { +if (def-nets[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +continue; +qemuAssignDevicePCISlot(def-nets[i]-info, nextslot++); +} + +for (i = 0; i def-nsounds ; i++) { +if (def-sounds[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +continue; +/* Skip ISA sound card, and PCSPK */ +if (def-sounds[i]-model == VIR_DOMAIN_SOUND_MODEL_SB16 || +def-sounds[i]-model == VIR_DOMAIN_SOUND_MODEL_PCSPK) +continue; + +qemuAssignDevicePCISlot(def-sounds[i]-info, nextslot++); +} + +for (i = 0; i def-nhostdevs ; i++) { +if (def-hostdevs[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +continue; +if (def-hostdevs[i]-mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || +def-hostdevs[i]-source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) +continue; + +qemuAssignDevicePCISlot(def-hostdevs[i]-info, nextslot++); +} +for (i = 0; i def-nvideos ; i++) { +/* First VGA is hardcoded slot=2 */ +if (i == 0) +qemuAssignDevicePCISlot(def-videos[i]-info, 2); +else +qemuAssignDevicePCISlot(def-videos[i]-info, nextslot++); +} +for (i = 0; i def-ncontrollers ; i++) { +if (def-controllers[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +continue; +/* FDC lives behind the ISA bridge */ +if (def-controllers[i]-type == VIR_DOMAIN_CONTROLLER_TYPE_FDC) +continue; + +/* First IDE controller lives on the PIIX3 at slot=1, function=1 */ +if (def-controllers[i]-type == VIR_DOMAIN_CONTROLLER_TYPE_IDE +def-controllers[i]-idx == 0) { +qemuAssignDevicePCISlot(def-controllers[i]-info, 1); +def-controllers[i]-info.addr.pci.function = 1; +} else { +qemuAssignDevicePCISlot(def-controllers[i]-info, nextslot++); +} +} +for (i = 0; i def-ninputs ; i++) { +/* Nada - none are PCI based (yet) */ +} +for (i = 0; i def-nparallels ; i++) { +/* Nada - none are PCI based (yet) */ +} +for (i = 0; i def-nserials ; i++) { +/* Nada - none are PCI based (yet) */ +} +for (i = 0; i def-nchannels ; i++) { +/* Nada - none are PCI based (yet) */ +/* XXX virtio-serial will need one */ +} +if
[libvirt] [PATCH 22/34] Convert watchdog to -device
The current syntax for watchdogs is -watchdog i6300esb The new syntax will now be -device i6300esb,id=watchdogNN,addr=PCI-SLOT --- src/qemu/qemu_conf.c | 91 ++-- .../qemuxml2argv-watchdog-device.args |1 + .../qemuxml2argv-watchdog-device.xml | 23 + tests/qemuxml2argvtest.c |2 + 4 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index eded887..fa16f8c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1629,6 +1629,38 @@ qemuAssignDiskAliases(virDomainDefPtr def, int qemuCmdFlags) return 0; } +static int +qemuBuildDeviceAddressStr(virBufferPtr buf, + virDomainDeviceInfoPtr info) +{ +if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +if (info-addr.pci.domain != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(Only PCI device addresses with domain=0 are supported)); +return -1; +} +if (info-addr.pci.bus != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(Only PCI device addresses with bus=0 are supported)); +return -1; +} +if (info-addr.pci.function != 0) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, %s, + _(Only PCI device addresses with function=0 are supported)); +return -1; +} + +/* XXX + * When QEMU grows support for 1 PCI bus, then pci.0 changes + * to pci.1, pci.2, etc + * When QEMU grows support for 1 PCI domain, then pci.0 change + * to pciNN.0 where NN is the domain number + */ +virBufferVSprintf(buf, ,bus=pci.0,addr=0x%x, info-addr.pci.slot); +} +return 0; +} + static const char * qemuNetTypeToHostNet(int type) @@ -1991,7 +2023,36 @@ qemuBuildHostNetStr(virConnectPtr conn, return 0; } -/* This function outputs a -chardev command line option which describes only the + +static char *qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; + +const char *model = virDomainWatchdogModelTypeToString(dev-model); +if (!model) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + %s, _(missing watchdog model)); +goto error; +} + +virBufferVSprintf(buf, %s, model); +virBufferVSprintf(buf, ,id=%s, dev-info.alias); +if (qemuBuildDeviceAddressStr(buf, dev-info) 0) +goto error; + +if (virBufferError(buf)) { +virReportOOMError(NULL); +goto error; +} + +return virBufferContentAndReset(buf); + +error: +virBufferFreeAndReset(buf); +return NULL; +} + +/* this function outputs a -chardev command line option which describes only the * host side of the character device */ static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev, virBufferPtr buf) @@ -3086,14 +3147,28 @@ int qemudBuildCommandLine(virConnectPtr conn, /* Add watchdog hardware */ if (def-watchdog) { virDomainWatchdogDefPtr watchdog = def-watchdog; -const char *model = virDomainWatchdogModelTypeToString(watchdog-model); -if (!model) { -qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - %s, _(invalid watchdog model)); -goto error; +char *optstr; + +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +ADD_ARG_LIT(-device); + +optstr = qemuBuildWatchdogDevStr(watchdog); +if (!optstr) +goto error; +} else { +ADD_ARG_LIT(-watchdog); + +const char *model = virDomainWatchdogModelTypeToString(watchdog-model); +if (!model) { +qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + %s, _(missing watchdog model)); +goto error; +} + +if (!(optstr = strdup(model))) +goto no_memory; } -ADD_ARG_LIT(-watchdog); -ADD_ARG_LIT(model); +ADD_ARG(optstr); const char *action = virDomainWatchdogActionTypeToString(watchdog-action); if (!action) { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.args b/tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.args new file mode 100644 index 000..5f3a428 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test
[libvirt] [PATCH 27/34] Convert USB hostdevices over to -device
The old syntax was -usbdevice host:PRODUCT:VENDOR Or -usbdevice host:BUS.DEV The new syntax is -device usb-host,product=PRODUCT,vendor=VENDOR Or -device usb-host,hostbus=BUS,hostaddr=DEV --- src/qemu/qemu_conf.c | 32 ++- .../qemuxml2argv-hostdev-usb-address-device.args |1 + .../qemuxml2argv-hostdev-usb-address-device.xml| 27 tests/qemuxml2argvtest.c |1 + 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 53866eb..1ea61a9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -3510,22 +3510,36 @@ int qemudBuildCommandLine(virConnectPtr conn, /* USB */ if (hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { -if(hostdev-source.subsys.u.usb.vendor) { -ret = virAsprintf(usbdev, host:%.4x:%.4x, - hostdev-source.subsys.u.usb.vendor, - hostdev-source.subsys.u.usb.product); +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +ADD_ARG_LIT(-device); +if (hostdev-source.subsys.u.usb.vendor) { +ret = virAsprintf(usbdev, usb-host,vendor=%.4x,product=%.4x,id=%s, + hostdev-source.subsys.u.usb.vendor, + hostdev-source.subsys.u.usb.product, + hostdev-info.alias); +} else { +ret = virAsprintf(usbdev, usb-host,hostbus=%.3d,hostaddr=%.3d,id=%s, + hostdev-source.subsys.u.usb.bus, + hostdev-source.subsys.u.usb.device, + hostdev-info.alias); +} } else { +ADD_ARG_LIT(-usbdevice); +if (hostdev-source.subsys.u.usb.vendor) { +ret = virAsprintf(usbdev, host:%.4x:%.4x, + hostdev-source.subsys.u.usb.vendor, + hostdev-source.subsys.u.usb.product); +} else { ret = virAsprintf(usbdev, host:%.3d.%.3d, - hostdev-source.subsys.u.usb.bus, - hostdev-source.subsys.u.usb.device); + hostdev-source.subsys.u.usb.bus, + hostdev-source.subsys.u.usb.device); +} } if (ret 0) goto error; -ADD_ARG_LIT(-usbdevice); -ADD_ARG_LIT(usbdev); -VIR_FREE(usbdev); +ADD_ARG(usbdev); } /* PCI */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args new file mode 100644 index 000..70f48c4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -device usb-host,hostbus=014,hostaddr=006,id=hostusb0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.xml new file mode 100644 index 000..61bb2a2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.xml @@ -0,0 +1,27 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219200/memory + currentMemory219200/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ +/disk +hostdev mode='subsystem' type='usb' managed='no' + source +address bus='14' device='6'/ + /source +/hostdev + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8c88a79..2042e2a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -299,6 +299,7 @@ mymain(int argc, char **argv) DO_TEST(hostdev-usb-product, 0); DO_TEST(hostdev-usb-address, 0); +DO_TEST(hostdev-usb-address-device,
[libvirt] [PATCH 29/34] Convert PCI device assignment over to -device
The old syntax is -pcidevice host=BUS:SLOT:FUNCTION The new syntax is -device pci-assign,host=BUS:SLOT:FUNCTION,addr=PCI SLOT,id=host0 --- src/qemu/qemu_conf.c | 51 +++- .../qemuxml2argv-hostdev-pci-address-device.args |1 + .../qemuxml2argv-hostdev-pci-address-device.xml| 27 ++ tests/qemuxml2argvtest.c |1 + 4 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3b39a91..a09fb62 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -2326,6 +2326,32 @@ error: } +static char * +qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(buf, pci-assign); +virBufferVSprintf(buf, ,host=%.2x:%.2x.%.1x, + dev-source.subsys.u.pci.bus, + dev-source.subsys.u.pci.slot, + dev-source.subsys.u.pci.function); +virBufferVSprintf(buf, ,id=%s, dev-info.alias); +if (qemuBuildDeviceAddressStr(buf, dev-info) 0) +goto error; + +if (virBufferError(buf)) { +virReportOOMError(NULL); +goto error; +} + +return virBufferContentAndReset(buf); + +error: +virBufferFreeAndReset(buf); +return NULL; +} + /* This function outputs a -chardev command line option which describes only the * host side of the character device */ static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev, @@ -3575,22 +3601,23 @@ int qemudBuildCommandLine(virConnectPtr conn, /* PCI */ if (hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { -if (!(qemuCmdFlags QEMUD_CMD_FLAG_PCIDEVICE)) { +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) { +ADD_ARG_LIT(-device); +if (!(pcidev = qemuBuildPCIHostdevDevStr(hostdev))) +goto error; +} else if (qemuCmdFlags QEMUD_CMD_FLAG_PCIDEVICE) { +ADD_ARG_LIT(-pcidevice); +if (virAsprintf(pcidev, host=%.2x:%.2x.%.1x, +hostdev-source.subsys.u.pci.bus, +hostdev-source.subsys.u.pci.slot, +hostdev-source.subsys.u.pci.function) 0) +goto no_memory; +} else { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, %s, _(PCI device assignment is not supported by this version of qemu)); goto error; } -ret = virAsprintf(pcidev, host=%.2x:%.2x.%.1x, - hostdev-source.subsys.u.pci.bus, - hostdev-source.subsys.u.pci.slot, - hostdev-source.subsys.u.pci.function); -if (ret 0) { -pcidev = NULL; -goto no_memory; -} -ADD_ARG_LIT(-pcidevice); -ADD_ARG_LIT(pcidev); -VIR_FREE(pcidev); +ADD_ARG(pcidev); } } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args new file mode 100644 index 000..f1865ee --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest2 -usb -device pci-assign,host=06:12.5,id=hostpci0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml new file mode 100644 index 000..ac5ad47 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml @@ -0,0 +1,27 @@ +domain type='qemu' + nameQEMUGuest2/name + uuidc7a5fdbd-edaf-9466-926a-d65c16db1809/uuid + memory219200/memory + currentMemory219200/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest2'/ + target dev='hda' bus='ide'/ +/disk +hostdev mode='subsystem' type='pci' managed='yes' + source +address domain='0x' bus='0x06' slot='0x12' function='0x5'/ + /source +/hostdev + /devices +/domain diff --git
[libvirt] [PATCH 30/34] Convert guestfwd to -device, and add -sdl explicit args
The old syntax was -chardev SOMECONFIG -nic user,guestfwd=tcp:IP:PORT-chardev:CHARDEV The new syntax is -chardev SOMECONFIG -netdev user,guestfwd=tcp:IP:PORT,chardev=ID,id=user-ID --- src/qemu/qemu_conf.c | 11 ++- .../qemuxml2argv-channel-guestfwd.args |2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index a09fb62..9cd53f9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -3283,9 +3283,10 @@ int qemudBuildCommandLine(virConnectPtr conn, switch(channel-targetType) { case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: -if (!(qemuCmdFlags QEMUD_CMD_FLAG_CHARDEV)) { +if (!(qemuCmdFlags QEMUD_CMD_FLAG_CHARDEV) || +!(qemuCmdFlags QEMUD_CMD_FLAG_DEVICE)) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - %s, _(guestfwd requires QEMU to support -chardev)); + %s, _(guestfwd requires QEMU to support -chardev -device)); goto error; } @@ -3301,8 +3302,9 @@ int qemudBuildCommandLine(virConnectPtr conn, const char *addr = virSocketFormatAddr(channel-target.addr); int port = virSocketGetPort(channel-target.addr); -virBufferVSprintf(buf, user,guestfwd=tcp:%s:%i-chardev:%s, - addr, port, channel-info.alias); +ADD_ARG_LIT(-netdev); +virBufferVSprintf(buf, user,guestfwd=tcp:%s:%i,chardev=%s,id=user-%s, + addr, port, channel-info.alias, channel-info.alias); VIR_FREE(addr); @@ -3311,7 +3313,6 @@ int qemudBuildCommandLine(virConnectPtr conn, goto no_memory; } -ADD_ARG_LIT(-net); ADD_ARG(virBufferContentAndReset(buf)); } } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args index c3148df..e93e934 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev pipe,id=channel0,path=/tmp/guestfwd -net user,guestfwd=tcp:10.0.2.1:4600-chardev:channel0 -usb +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev pipe,id=channel0,path=/tmp/guestfwd -netdev user,guestfwd=tcp:10.0.2.1:4600,chardev=channel0,id=user-channel0 -usb -- 1.6.5.2 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 19/34] Probe for -device and use -nodefaults
Probe for the new -device flag and if available set the -nodefaults flag, instead of using -net none, -serial none or -parallel none. Other device types will be converted to use -device in later patches. The -nodefaults flag will help avoid unwelcome surprises from future QEMU releases * src/qemu/qemu_conf.c: Probe for -device. Add -nodefaults flag. Remove -net none, -serial none or -parallel none * src/qemu/qemu_conf.h: Define QEMU_CMD_FLAG_DEVICE * tests/qemuhelpdata/qemu-0.12.1: New data file for 0.12.1 QEMU * tests/qemuhelptest.c: Test feature extraction from 0.12.1 QEMU --- src/qemu/qemu_conf.c | 26 - src/qemu/qemu_conf.h |1 + tests/qemuhelpdata/qemu-0.12.1 | 203 tests/qemuhelptest.c | 42 - 4 files changed, 264 insertions(+), 8 deletions(-) create mode 100644 tests/qemuhelpdata/qemu-0.12.1 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 6548b4a..3718470 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1115,6 +1115,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_CHARDEV; if (strstr(help, -balloon)) flags |= QEMUD_CMD_FLAG_BALLOON; +if (strstr(help, -device)) +flags |= QEMUD_CMD_FLAG_DEVICE; if (version = 9000) flags |= QEMUD_CMD_FLAG_VNC_COLON; @@ -2308,6 +2310,9 @@ int qemudBuildCommandLine(virConnectPtr conn, if (!def-graphics) ADD_ARG_LIT(-nographic); +if (qemuCmdFlags QEMUD_CMD_FLAG_DEVICE) +ADD_ARG_LIT(-nodefaults); + if (monitor_chr) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -2530,8 +2535,11 @@ int qemudBuildCommandLine(virConnectPtr conn, } if (!def-nnets) { -ADD_ARG_LIT(-net); -ADD_ARG_LIT(none); +/* If we have -device, then we set -nodefault already */ +if (!(qemuCmdFlags QEMUD_CMD_FLAG_DEVICE)) { +ADD_ARG_LIT(-net); +ADD_ARG_LIT(none); +} } else { for (i = 0 ; i def-nnets ; i++) { virDomainNetDefPtr net = def-nets[i]; @@ -2590,8 +2598,11 @@ int qemudBuildCommandLine(virConnectPtr conn, } if (!def-nserials) { -ADD_ARG_LIT(-serial); -ADD_ARG_LIT(none); +/* If we have -device, then we set -nodefault already */ +if (!(qemuCmdFlags QEMUD_CMD_FLAG_DEVICE)) { +ADD_ARG_LIT(-serial); +ADD_ARG_LIT(none); +} } else { for (i = 0 ; i def-nserials ; i++) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -2637,8 +2648,11 @@ int qemudBuildCommandLine(virConnectPtr conn, } if (!def-nparallels) { -ADD_ARG_LIT(-parallel); -ADD_ARG_LIT(none); +/* If we have -device, then we set -nodefault already */ +if (!(qemuCmdFlags QEMUD_CMD_FLAG_DEVICE)) { +ADD_ARG_LIT(-parallel); +ADD_ARG_LIT(none); +} } else { for (i = 0 ; i def-nparallels ; i++) { virBuffer buf = VIR_BUFFER_INITIALIZER; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 3dbe1c8..174d397 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -78,6 +78,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_ENABLE_KVM= (1 23), /* Is the -enable-kvm flag available to enable KVM full virtualization support */ QEMUD_CMD_FLAG_MONITOR_JSON = (1 24), /* JSON mode for monitor */ QEMUD_CMD_FLAG_BALLOON = (1 25), /* -balloon available */ +QEMUD_CMD_FLAG_DEVICE= (1 26), /* Is the new -chardev arg available */ }; /* Main driver state */ diff --git a/tests/qemuhelpdata/qemu-0.12.1 b/tests/qemuhelpdata/qemu-0.12.1 new file mode 100644 index 000..748625b --- /dev/null +++ b/tests/qemuhelpdata/qemu-0.12.1 @@ -0,0 +1,203 @@ +QEMU PC emulator version 0.12.1, Copyright (c) 2003-2008 Fabrice Bellard +usage: qemu [options] [disk_image] + +'disk_image' is a raw hard image image for IDE hard disk 0 + +Standard options: +-h or -help display this help and exit +-versiondisplay version information and exit +-M machine select emulated machine (-M ? for list) +-cpu cpuselect CPU (-cpu ? for list) +-smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets] +set the number of CPUs to 'n' [default=1] +maxcpus= maximum number of total cpus, including + offline CPUs for hotplug etc. +cores= number of CPU cores on one socket +threads= number of threads on one CPU core +sockets= number of discrete sockets in the system +-numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node] +-fda/-fdb file use 'file' as floppy disk 0/1 image +-hda/-hdb file use 'file' as IDE hard disk 0/1 image +-hdc/-hdd file use 'file' as IDE hard disk 2/3 image +-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) +-drive
[libvirt] [PATCH] Only use pseudo-random generator for uuid if using /dev/random fails.
The original code. would only print the warning message if using /dev/random failed, but would still go ahead and call virUUIDGeneratePseudoRandomBytes in all cases anyway. --- src/util/uuid.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/uuid.c b/src/util/uuid.c index 002a64d..846581c 100644 --- a/src/util/uuid.c +++ b/src/util/uuid.c @@ -104,9 +104,9 @@ virUUIDGenerate(unsigned char *uuid) VIR_WARN(_(Falling back to pseudorandom UUID, failed to generate random bytes: %s), virStrerror(err, ebuf, sizeof ebuf)); +err = virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN); } - -return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN); +return err; } /* Convert C from hexadecimal character to integer. */ -- 1.6.6 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 00/34] Add device addressing and disk controller support
On Fri, Jan 08, 2010 at 05:22:56PM +, Daniel P. Berrange wrote: This series is a merge of two previous series I posted http://www.redhat.com/archives/libvir-list/2009-December/msg00232.html http://www.redhat.com/archives/libvir-list/2009-December/msg00392.html It accomplishes quite a lot of things, having major impact on the QEMU driver, hopefully all in a postive way :-) In particular it does * Add standard XML syntax for addressing of PCI devices, and disk drives * Add support for disk controllers as a managed device in XML * Add support for disk controller hotplug/unplug * Convert everything over to use QEMU's -device flag where available * Add PCI addressing when using -device * Introduce a way to give every device a unique 'alias' name in the XML format I can't promise it works perfectly, but i've done quite alot of positive testing with it now believe all the back comptability stuff is working right. Since this is a long series, it might be helpful to see the results in the XML and command line Starting with this initial XML config which the application defines domain type='kvm' id='2' nameeverything/name uuidc7a1edbd-edaf-9455-926a-d65c36db1809/uuid memory219200/memory currentMemory219136/currentMemory vcpu1/vcpu os type arch='i686' machine='pc-0.11'hvm/type kernel/home/berrange/vmlinuz-PAE/kernel initrd/home/berrange/initrd-PAE.img/initrd boot dev='hd'/ /os features acpi/ /features clock offset='utc'/ on_poweroffdestroy/on_poweroff on_rebootrestart/on_reboot on_crashdestroy/on_crash devices emulator/home/berrange/usr/qemu-0.12/bin/qemu/emulator disk type='file' device='disk' driver name='qemu' type='qcow2'/ source file='/home/berrange/VirtualMachines/plain.qcow'/ target dev='vda' bus='virtio'/ /disk disk type='file' device='cdrom' source file='/home/berrange/gpxe.iso'/ target dev='hdc' bus='ide'/ readonly/ /disk disk type='file' device='disk' source file='/home/berrange/output.img'/ target dev='sdb' bus='usb'/ /disk disk type='file' device='disk' source file='/home/berrange/output.img'/ target dev='sda' bus='scsi'/ /disk disk type='file' device='disk' source file='/home/berrange/output.img'/ target dev='sdz' bus='scsi'/ /disk disk type='file' device='disk' source file='/home/berrange/output.img'/ target dev='sdaf' bus='scsi'/ /disk interface type='user' mac address='52:54:00:5b:ef:21'/ model type='ne2k_pci'/ /interface interface type='mcast' mac address='52:54:00:1c:dc:98'/ source address='230.0.0.1' port='5558'/ model type='virtio'/ /interface interface type='network' mac address='52:54:00:f7:c5:0e'/ source network='default'/ target dev='vnet0'/ model type='e1000'/ /interface interface type='user' mac address='52:54:00:56:6c:55'/ model type='pcnet'/ /interface interface type='user' mac address='52:54:00:ca:0d:58'/ model type='rtl8139'/ /interface serial type='pty' source path='/dev/pts/10'/ target port='0'/ /serial parallel type='pty' source path='/dev/pts/17'/ target port='0'/ /parallel console type='pty' tty='/dev/pts/10' source path='/dev/pts/10'/ target port='0'/ /console input type='tablet' bus='usb'/ input type='mouse' bus='ps2'/ graphics type='vnc' port='5900' autoport='yes'/ sound model='ac97'/ sound model='es1370'/ video model type='cirrus' vram='9216' heads='1'/ /video hostdev mode='subsystem' type='pci' managed='yes' source address domain='0x' bus='0x15' slot='0x00' function='0x0'/ /source /hostdev hostdev mode='subsystem' type='usb' managed='yes' source address bus='4' device='2'/ /source /hostdev watchdog model='i6300esb' action='reset'/ /devices /domain With the latest QEMU we now generate command line that looks like this LC_ALL=C PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin HOME=/root USER=root LOGNAME=root QEMU_AUDIO_DRV=none /home/berrange/usr/qemu-0.12/bin/qemu -S -M pc-0.11 -enable-kvm -m 214 -smp 1 -name everything -uuid c7a1edbd-edaf-9455-926a-d65c36db1809 -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/everything.monitor,server,nowait -mon chardev=monitor,mode=readline -boot c -kernel /home/berrange/vmlinuz-PAE -initrd /home/berrange/initrd-PAE.img -device lsi,id=scsi0,addr=13 -device lsi,id=scsi1,addr=14 -device lsi,id=scsi2,addr=15 -device lsi,id=scsi3,addr=16 -device lsi,id=scsi4,addr=17 -drive file=/home/berrange/VirtualMachines/plain.qcow,if=none,id=drive-virtio-disk0,format=qcow2 -device
Re: [libvirt] RFC: Create a separate libvirt users mailing list ?
Daniel Huhardeaux t...@tootai.net : Excellent idea. I was thinking to unsubscribe from the actual list because of the hudge dev traffic You were not abble to filter and split the destination folder? Are you serious? -- Architecte Informatique chez Blueline/Gulfsat: Administration Systeme, Recherche Developpement +261 34 29 155 34 / +261 33 11 207 36 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] esx: Warn if the ESX server is in maintenance mode
2010/1/8 Daniel Veillard veill...@redhat.com: On Tue, Jan 05, 2010 at 03:00:06AM +0100, Matthias Bolte wrote: --- src/esx/esx_driver.c | 38 +++--- 1 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index f86654a..ddda66e 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -401,6 +401,32 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) } } + /* Query the host for maintenance mode and vCenter IP address */ + if (esxVI_String_AppendValueListToList(conn, propertyNameList, + runtime.inMaintenanceMode\0 + summary.managementServerIp\0) 0 || + esxVI_LookupHostSystemByIp(conn, priv-host, hostIpAddress, + propertyNameList, hostSystem) 0) { + goto failure; + } + + /* Warn if host is in maintenance mode */ + for (dynamicProperty = hostSystem-propSet; dynamicProperty != NULL; + dynamicProperty = dynamicProperty-_next) { + if (STREQ(dynamicProperty-name, runtime.inMaintenanceMode)) { + if (esxVI_AnyType_ExpectType(conn, dynamicProperty-val, + esxVI_Type_Boolean) 0) { + goto failure; + } + + if (dynamicProperty-val-boolean == esxVI_Boolean_True) { + VIR_WARN0(The server is in maintenance mode); + } + + break; + } + } + /* Login to vCenter */ if (vCenter != NULL) { VIR_FREE(url); @@ -415,17 +441,9 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) } /* Lookup the vCenter from the ESX host */ - if (esxVI_String_AppendValueToList - (conn, propertyNameList, summary.managementServerIp) 0 || - esxVI_LookupHostSystemByIp(conn, priv-host, hostIpAddress, - propertyNameList, hostSystem) 0) { - goto failure; - } - for (dynamicProperty = hostSystem-propSet; dynamicProperty != NULL; dynamicProperty = dynamicProperty-_next) { - if (STREQ(dynamicProperty-name, - summary.managementServerIp)) { + if (STREQ(dynamicProperty-name, summary.managementServerIp)) { if (esxVI_AnyType_ExpectType(conn, dynamicProperty-val, esxVI_Type_String) 0) { goto failure; @@ -461,8 +479,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) } break; - } else { - VIR_WARN(Unexpected '%s' property, dynamicProperty-name); } } Looks like the fix for the problem Rich reported, ACK, Daniel Well, the fix for Richard's problem was to leave maintenance mode :) Now it should simpler to spot that maintenance mode may be the cause of such problems. Thanks, pushed together with the raw-response-dump commit. Matthias -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] QEMU/KVM snapshots, and rudimentary API extension
On 12/31/2009 07:42 PM, Philip Jameson wrote: I was starting to use libvirt on a project, and realized that there was nothing in the API for snapshots. As I need to be able to take snapshots without taking down the machine (that and KVM's restore function didn't seem to be working terribly well), I added a few functions so that I could take snapshots, and I also added a screenshot function so I could give users a view of their snapshots in my application. At this point, as I only really use KVM/QEMU, that is the only hypervisor I implemented it for, and I'm sure there will be some problems with my structure in the other drivers. However, I figured I should at least submit the patch, even if it turns out to be of no use to anyone :) At this point for the QEMU driver, it only does snapshots for qcow2 drives, and will report an error if qemu says that no valid drives were found, or if for restoring/deleting the specified snapshot wasn't found. Hi Philip, Thanks for the patch, snapshot handling is definitely one of the big missing pieces in libvirt. For this patch to get better attention, I'd recommend making a top level post (for some reason this mail appeared as a reply to an unrelated thread), and split the patch into discreet parts. You can see an example of such a split at http://libvirt.org/api_extension.html. Using git send-email will make this process very easy. It's probably also a good idea to split the screenshot API from the snapshot pieces and submit them separately. FYI, Dan (the primary libvirt architect) did a write up a while ago describing what he thought a snapshotting API should look like: http://www.redhat.com/archives/libvir-list/2009-March/msg00205.html It's pretty similar to yours: it might help to adjust your API entry points to take into account Dan's ideas. Thanks for the contribution! - Cole -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list