Re: [libvirt] [Qemu-devel] [Qemu PATCH v2] add a boot option to do strict boot
by Eric Blake
On 01/09/2013 01:39 AM, Amos Kong wrote:
> Current seabios will try to boot from selected devices first,
> if they are all failed, seabios will also try to boot from
> un-selected devices.
>
> We need to make it configurable. I already posted a seabios
> patch to add a new device type to halt booting. Qemu can add
> "HALT" at the end of bootindex string, then seabios will halt
> booting after trying to boot from selected devices.
>
> This option only effects when boot priority is changed by
> bootindex options, the old style(-boot order=..) will still
> try to boot from un-selected devices.
>
> v2: add HALT entry in get_boot_devices_list()
> define boot_strict to bool
>
> Signed-off-by: Amos Kong <akong(a)redhat.com>
> ---
Libvirt will need to expose an attribute that lets the user control
whether to use this new option; how do we probe via QMP whether the new
-boot strict=on command-line option is available?
> +++ b/qemu-options.hx
> @@ -376,14 +376,14 @@ ETEXI
>
> DEF("boot", HAS_ARG, QEMU_OPTION_boot,
> "-boot [order=drives][,once=drives][,menu=on|off]\n"
> - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
> + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n"
> " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
> " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
> " 'sp_time': the period that splash picture last if menu=on, unit is ms\n"
> " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
So if I understand correctly, -boot order=... is incompatible with -boot
strict=on; even though you have listed both options under a single -boot
entry in the -help. We've already declared that -help output is no
longer guaranteed stable, so this doesn't really impact libvirt, but
would it make any more sense to list this as two orthogonal entries, to
make it clear that they don't mix?
-boot order=drivers[,once=drives]...
-boot strict=on|off[,menu=on|off]...
But this is all bikeshedding, so it's not worth a v3 if you disagree.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
11 years, 8 months
[libvirt] Entering freeze for libvirt-1.0.3
by Daniel Veillard
I have just tagged git and pushed the tarball. The rpms for F17
are following too at the usual place:
ftp://libvirt.org/libvirt/
I gave a try to the set of rpms and this seems to work fine for
relatively simple tests, but of course more testing and checking on
other architectures is needed !
If everything goes fine, I will make an rc2 in a couple of days
and then we can decide if a final release on Friday is fine or if
we need to postpone to next week,
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
11 years, 8 months
[libvirt] libvirt accidentally destroys guests after being restarted
by Igor Lukyanov
Hello.
We notice a very upsetting behavior of how libvirtd deals with running domains after being restarted.
Namely, in 10-20s after start libvirtd may accidentally kill a random number of running (qemu) domains with SIGTERM.
Here is what we get in libvirt log:
2013-02-27 12:35:10.415+0000: 45777: info : libvirt version: 1.0.2
2013-02-27 12:35:10.415+0000: 45777: error : virNWFilterSnoopLeaseFileRefresh:1903 : open("/var/run/libvirt/network/nwfilter.ltmp"): No such file or directory
2013-02-27 12:35:21.772+0000: 45766: error : qemuMonitorIO:602 : internal error End of file from monitor
2013-02-27 12:35:21.772+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet34" not in key map
2013-02-27 12:35:21.905+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet34: No such device
2013-02-27 12:35:22.029+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet35" not in key map
2013-02-27 12:35:22.032+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet35: No such device
2013-02-27 12:35:22.430+0000: 45766: error : qemuMonitorIO:602 : internal error End of file from monitor
2013-02-27 12:35:22.430+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet4" not in key map
2013-02-27 12:35:22.433+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet4: No such device
2013-02-27 12:35:22.554+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet5" not in key map
2013-02-27 12:35:22.557+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet5: No such device
2013-02-27 12:35:22.794+0000: 45766: error : qemuMonitorIO:602 : internal error End of file from monitor
2013-02-27 12:35:22.794+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet10" not in key map
2013-02-27 12:35:22.797+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet10: No such device
2013-02-27 12:35:22.944+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet11" not in key map
2013-02-27 12:35:22.947+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet11: No such device
2013-02-27 12:35:23.194+0000: 45766: error : qemuMonitorIO:602 : internal error End of file from monitor
2013-02-27 12:35:23.194+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet14" not in key map
2013-02-27 12:35:23.197+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet14: No such device
2013-02-27 12:35:23.361+0000: 45766: error : virNWFilterDHCPSnoopEnd:2131 : internal error ifname "vnet15" not in key map
2013-02-27 12:35:23.364+0000: 45766: error : virNetDevGetIndex:653 : Unable to get index for interface vnet15: No such device
And this is what we get by grepping 45766 in separate logs of vms:
drafter@10-5-0-11:/var/log/libvirt/qemu$ sudo grep -A 1 45766 *
vm010-001-206-002.log:qemu: terminating on signal 15 from pid 45766
vm010-001-206-002.log-2013-02-27 12:35:22.430+0000: shutting down
--
vm010-001-207-002.log:qemu: terminating on signal 15 from pid 45766
vm010-001-207-002.log-2013-02-27 12:35:22.794+0000: shutting down
--
vm010-001-228-006.log:qemu: terminating on signal 15 from pid 45766
vm010-001-228-006.log-2013-02-27 12:35:23.194+0000: shutting down
--
vm010-002-011-002.log:qemu: terminating on signal 15 from pid 45766
vm010-002-011-002.log-2013-02-27 12:35:21.772+0000: shutting down
Specifically here libvirt killed 4 vms just after start.
Before that occasion we just shut libvirtd off and started again (stop/start).
Will be very grateful for any ideas on this matter.
--
wbr, Igor Lukyanov
11 years, 8 months
[libvirt] VG backed storage pool start behavior.
by Luke Varnadore
Libvirt 1.0.2-3
I am unable to use vg storage pools that are shared with the host. I was
able to do this without issue an update before this one. Wondering if
anyone else is seeing this behavior.
I am on an Arch Linux system but I can't see why that would matter yet.
Here is the error I get when trying to start a pool defined from the shared
VG that my host, and guests share:
Error starting pool 'vg_nimbus': internal error Child process
(/sbin/vgchange -aln vg_nimbus) unexpected exit status 5: Can't
deactivate volume group "vg_nimbus" with 7 open logical volume(s)
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 96, in
cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 117, in tmpcb
callback(*args, **kwargs)
File "/usr/share/virt-manager/virtManager/storagepool.py", line 64, in
start
self.pool.create(0)
File "/usr/lib/python2.7/site-packages/libvirt.py", line 2360, in create
if ret == -1: raise libvirtError ('virStoragePoolCreate() failed',
pool=self)
libvirtError: internal error Child process (/sbin/vgchange -aln vg_nimbus)
unexpected exit status 5: Can't deactivate volume group "vg_nimbus" with
7 open logical volume(s)
I can still carry on using lvs manually (without storage pools) to run my
guests and host lvs.
--
Luke W Varnadore
11 years, 8 months
[libvirt] [PATCH] Hook log the exit status of the hook not 256
by Guido Günther
Adjust the docs accordingly. See http://bugs.debian.org/701570.
---
docs/hooks.html.in | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/docs/hooks.html.in b/docs/hooks.html.in
index 5f9963d..b75fbeb 100644
--- a/docs/hooks.html.in
+++ b/docs/hooks.html.in
@@ -239,13 +239,14 @@
<p>If a hook script returns with an exit code of 0, the libvirt daemon
regards this as successful and performs no logging of it.</p>
<p>However, if a hook script returns with a non zero exit code, the libvirt
- daemon regards this as a failure, logs it with return code 256, and
+ daemon regards this as a failure, logs it's return code, and
additionally logs anything on stderr the hook script returns.</p>
<p>For example, a hook script might use this code to indicate failure,
and send a text string to stderr:</p>
<pre>echo "Could not find required XYZZY" >&2
exit 1</pre>
<p>The resulting entry in the libvirt log will appear as:</p>
- <pre>20:02:40.297: error : virHookCall:416 : Hook script execution failed: Hook script /etc/libvirt/hooks/qemu qemu failed with error code 256:Could not find required XYZZY</pre>
+ <pre>20:02:40.297: error : virHookCall:285 : Hook script execution failed: internal error Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ HOME=/root USER=root LOGNAME=root /etc/libvirt/hooks/qemu qemu prepare begin -) unexpected exit status 1: Could not find required XYZZY</pre>
</body>
</html>
--
1.7.10.4
11 years, 9 months
[libvirt] [PATCH] qemu: enable direct migration over IPv6
by Ján Tomko
Use virURIParse in qemuMigrationPrepareDirect to allow parsing
IPv6 addresses, which would cause an 'incorrect :port' error message
before.
To be able to migrate over IPv6, QEMU needs to listen on [::] instead
of 0.0.0.0. This patch adds a call to getaddrinfo and sets the listen
address based on the result.
This will break migration if a hostname that can only be resolved on the
source machine is passed in the migration URI, or if it does not resolve
to the same address family on both sides.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=846013
---
src/qemu/qemu_migration.c | 65 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 52 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 36e55d2..c813c4a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -22,7 +22,10 @@
#include <config.h>
+#include <netdb.h>
+#include <sys/socket.h>
#include <sys/time.h>
+#include <sys/types.h>
#ifdef WITH_GNUTLS
# include <gnutls/gnutls.h>
# include <gnutls/x509.h>
@@ -1835,8 +1838,11 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
int this_port;
char *hostname = NULL;
char migrateFrom [64];
- const char *p;
+ char *uri_str;
int ret = -1;
+ bool ipv6 = false;
+ struct addrinfo *info;
+ virURIPtr uri;
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
@@ -1892,9 +1898,33 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
goto cleanup;
}
- /* Get the port number. */
- p = strrchr(uri_in, ':');
- if (p == strchr(uri_in, ':')) {
+ /* Convert uri_in to well-formed URI with // after tcp: */
+ if (!(STRPREFIX(uri_in, "tcp://"))) {
+ if (virAsprintf(&uri_str, "tcp://%s",
+ uri_in + strlen("tcp:")) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
+ uri = virURIParse(uri_str ? uri_str : uri_in);
+ VIR_FREE(uri_str);
+
+ if (uri == NULL) {
+ virReportError(VIR_ERR_INVALID_ARG, _("unable to parse URI: %s"),
+ uri_in);
+ goto cleanup;
+ }
+
+ if (uri->server == NULL) {
+ virReportError(VIR_ERR_INVALID_ARG, _("missing host in migration"
+ " URI: %s"), uri_in);
+ goto cleanup;
+ } else {
+ hostname = uri->server;
+ }
+
+ if (uri->port == 0) {
/* Generate a port */
this_port = QEMUD_MIGRATION_FIRST_PORT + port++;
if (port == QEMUD_MIGRATION_NUM_PORTS)
@@ -1907,21 +1937,30 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
}
} else {
- p++; /* definitely has a ':' in it, see above */
- this_port = virParseNumber(&p);
- if (this_port == -1 || p-uri_in != strlen(uri_in)) {
- virReportError(VIR_ERR_INVALID_ARG,
- "%s", _("URI ended with incorrect ':port'"));
- goto cleanup;
- }
+ this_port = uri->port;
}
}
+ if (getaddrinfo(hostname, NULL, NULL, &info)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to get address info for %s"), hostname);
+ goto cleanup;
+ } else {
+ ipv6 = info->ai_family == AF_INET6;
+ }
+
if (*uri_out)
VIR_DEBUG("Generated uri_out=%s", *uri_out);
- /* QEMU will be started with -incoming tcp:0.0.0.0:port */
- snprintf(migrateFrom, sizeof(migrateFrom), "tcp:0.0.0.0:%d", this_port);
+ /* QEMU will be started with -incoming tcp:0.0.0.0:port
+ * or -incoming tcp:[::]:port for IPv6 */
+ if (ipv6) {
+ snprintf(migrateFrom, sizeof(migrateFrom),
+ "tcp:[::]:%d", this_port);
+ } else {
+ snprintf(migrateFrom, sizeof(migrateFrom),
+ "tcp:0.0.0.0:%d", this_port);
+ }
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, dname, dom_xml,
--
1.7.12.4
11 years, 9 months
[libvirt] [PATCH v2] virnetdevmacvlan.c: Introduce mutex for macvlan creation
by Michal Privoznik
Currently, after we removed the qemu driver lock, it may happen
that two or more threads will start up a machine with macvlan and
race over virNetDevMacVLanCreateWithVPortProfile(). However,
there's a racy section in which we are generating a sequence of
possible device names and detecting if they exits. If we found
one which doesn't we try to create a device with that name.
However, the other thread is doing just the same. Assume it will
succeed and we must therefore fail. If this happens more than 5
times (which in massive parallel startup surely will) we return
-1 without any error reported. This patch is a simple hack to
both of these problems. It introduces a mutex, so only one thread
will enter the section, and if it runs out of possibilities,
error is reported. Moreover, the number of retries is raised to 20.
---
diff to v1:
-don't increase @retries
-move error reporting to virNetDevMacVLanCreateMutexOnceInit
src/util/virnetdevmacvlan.c | 37 ++++++++++++++++++++++++++++++++-----
1 file changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index a74db1e..ddea11f 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -31,6 +31,7 @@
#include "virmacaddr.h"
#include "virutil.h"
#include "virerror.h"
+#include "virthread.h"
#define VIR_FROM_THIS VIR_FROM_NET
@@ -71,6 +72,19 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
# define MACVLAN_NAME_PREFIX "macvlan"
# define MACVLAN_NAME_PATTERN "macvlan%d"
+virMutex virNetDevMacVLanCreateMutex;
+
+static int virNetDevMacVLanCreateMutexOnceInit(void)
+{
+ if (virMutexInit(&virNetDevMacVLanCreateMutex) < 0) {
+ virReportSystemError(errno, "%s", _("unable to init mutex"));
+ return -1;
+ }
+ return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(virNetDevMacVLanCreateMutex);
+
/**
* virNetDevMacVLanCreate:
*
@@ -829,7 +843,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
char ifname[IFNAMSIZ];
int retries, do_retry = 0;
uint32_t macvtapMode;
- const char *cr_ifname;
+ const char *cr_ifname = NULL;
int ret;
int vf = -1;
@@ -871,22 +885,35 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
} else {
create_name:
retries = 5;
+ if (virNetDevMacVLanCreateMutexInitialize() < 0)
+ return -1;
+ virMutexLock(&virNetDevMacVLanCreateMutex);
for (c = 0; c < 8192; c++) {
snprintf(ifname, sizeof(ifname), pattern, c);
- if ((ret = virNetDevExists(ifname)) < 0)
+ if ((ret = virNetDevExists(ifname)) < 0) {
+ virMutexUnlock(&virNetDevMacVLanCreateMutex);
return -1;
+ }
if (!ret) {
rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
macvtapMode, &do_retry);
- if (rc == 0)
+ if (rc == 0) {
+ cr_ifname = ifname;
break;
+ }
if (do_retry && --retries)
continue;
- return -1;
+ break;
}
}
- cr_ifname = ifname;
+
+ virMutexUnlock(&virNetDevMacVLanCreateMutex);
+ if (!cr_ifname) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Unable to create macvlan device"));
+ return -1;
+ }
}
if (virNetDevVPortProfileAssociate(cr_ifname,
--
1.8.1.4
11 years, 9 months
[libvirt] [PATCH] virnetdevmacvlan.c: Introduce mutex for macvlan creation
by Michal Privoznik
Currently, after we removed the qemu driver lock, it may happen
that two or more threads will start up a machine with macvlan and
race over virNetDevMacVLanCreateWithVPortProfile(). However,
there's a racy section in which we are generating a sequence of
possible device names and detecting if they exits. If we found
one which doesn't we try to create a device with that name.
However, the other thread is doing just the same. Assume it will
succeed and we must therefore fail. If this happens more than 5
times (which in massive parallel startup surely will) we return
-1 without any error reported. This patch is a simple hack to
both of these problems. It introduces a mutex, so only one thread
will enter the section, and if it runs out of possibilities,
error is reported. Moreover, the number of retries is raised to 20.
---
This is just a quick hack which aim is to be as small as possible in order to
be well understood and hence included in the release. After the release, this
should be totally dropped in flavour of virNetDevNameAllocator.
src/util/virnetdevmacvlan.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index a74db1e..bf5e7e0 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -31,6 +31,7 @@
#include "virmacaddr.h"
#include "virutil.h"
#include "virerror.h"
+#include "virthread.h"
#define VIR_FROM_THIS VIR_FROM_NET
@@ -71,6 +72,15 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
# define MACVLAN_NAME_PREFIX "macvlan"
# define MACVLAN_NAME_PATTERN "macvlan%d"
+virMutex virNetDevMacVLanCreateMutex;
+
+static int virNetDevMacVLanCreateMutexOnceInit(void)
+{
+ return virMutexInit(&virNetDevMacVLanCreateMutex);
+}
+
+VIR_ONCE_GLOBAL_INIT(virNetDevMacVLanCreateMutex);
+
/**
* virNetDevMacVLanCreate:
*
@@ -829,7 +839,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
char ifname[IFNAMSIZ];
int retries, do_retry = 0;
uint32_t macvtapMode;
- const char *cr_ifname;
+ const char *cr_ifname = NULL;
int ret;
int vf = -1;
@@ -870,23 +880,39 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
return -1;
} else {
create_name:
- retries = 5;
+ if (virNetDevMacVLanCreateMutexInitialize() < 0) {
+ virReportSystemError(errno, "%s", _("unable to init mutext"));
+ return -1;
+ }
+
+ retries = 20;
+ virMutexLock(&virNetDevMacVLanCreateMutex);
for (c = 0; c < 8192; c++) {
snprintf(ifname, sizeof(ifname), pattern, c);
- if ((ret = virNetDevExists(ifname)) < 0)
+ if ((ret = virNetDevExists(ifname)) < 0) {
+ virMutexUnlock(&virNetDevMacVLanCreateMutex);
return -1;
+ }
if (!ret) {
rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
macvtapMode, &do_retry);
- if (rc == 0)
+ if (rc == 0) {
+ cr_ifname = ifname;
break;
+ }
if (do_retry && --retries)
continue;
- return -1;
+ break;
}
}
- cr_ifname = ifname;
+
+ virMutexUnlock(&virNetDevMacVLanCreateMutex);
+ if (!cr_ifname) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Unable to create macvlan device"));
+ return -1;
+ }
}
if (virNetDevVPortProfileAssociate(cr_ifname,
--
1.8.1.4
11 years, 9 months