Re: [libvirt] [PATCH] qemu: Allow domain reboot after core dump
by Sheldon
yes, the patch can work, when I execute virsh dump --reboot <domain> <file>
and the type of file is: QEMU's suspend to disk image
but the guest does not reboot. The guest does nothing.
but I try virsh shutdown <domain>, the guest Ubuntu OS pop up a dialog
box with four options: Shut Down, Restart, Suspend and HIbernate.
-------- ???? --------
> ??: [libvirt] [PATCH] qemu: Allow domain reboot after core dump
> ??: Tue, 20 Sep 2011 13:34:27 +0200
> ???: Michal Privoznik <mprivozn(a)redhat.com>
> ???: libvir-list(a)redhat.com
>
>
>
> This patch introduces possibility to reboot domain after core dump
> finishes. The new flag VIR_DUMP_REBOOT was added to
> virDomainCoreDumpFlags. The new functionality is accessible via virsh
> too: virsh dump --reboot<domain>
> ---
> include/libvirt/libvirt.h.in | 1 +
> src/qemu/qemu_driver.c | 8 +++++++-
> tools/virsh.c | 3 +++
> 3 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 39155a6..8c41f5a 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -748,6 +748,7 @@ typedef enum {
> VIR_DUMP_CRASH = (1<< 0), /* crash after dump */
> VIR_DUMP_LIVE = (1<< 1), /* live dump */
> VIR_DUMP_BYPASS_CACHE = (1<< 2), /* avoid file system cache pollution */
> + VIR_DUMP_REBOOT = (1<< 3), /* reboot domain after dump finishes */
> } virDomainCoreDumpFlags;
>
> /* Domain migration flags. */
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index e2f428f..22576a8 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3104,7 +3104,8 @@ static int qemudDomainCoreDump(virDomainPtr dom,
> int ret = -1;
> virDomainEventPtr event = NULL;
>
> - virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH | VIR_DUMP_BYPASS_CACHE, -1);
> + virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH |
> + VIR_DUMP_BYPASS_CACHE | VIR_DUMP_REBOOT, -1);
>
> qemuDriverLock(driver);
> vm = virDomainFindByUUID(&driver->domains, dom->uuid);
> @@ -3189,6 +3190,11 @@ cleanup:
> if (event)
> qemuDomainEventQueue(driver, event);
> qemuDriverUnlock(driver);
> +
> + if ((ret == 0)&& (flags& VIR_DUMP_REBOOT)) {
> + qemuDomainReboot(dom, 0);
> + }
> +
> return ret;
> }
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index d575425..74f6a79 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -2840,6 +2840,7 @@ static const vshCmdOptDef opts_dump[] = {
> {"crash", VSH_OT_BOOL, 0, N_("crash the domain after core dump")},
> {"bypass-cache", VSH_OT_BOOL, 0,
> N_("avoid file system cache when saving")},
> + {"reboot", VSH_OT_BOOL, 0, N_("reboot the domain after core dump")},
> {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
> {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to dump the core")},
> {NULL, 0, 0, NULL}
> @@ -2869,6 +2870,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
> flags |= VIR_DUMP_CRASH;
> if (vshCommandOptBool(cmd, "bypass-cache"))
> flags |= VIR_DUMP_BYPASS_CACHE;
> + if (vshCommandOptBool(cmd, "reboot"))
> + flags |= VIR_DUMP_REBOOT;
>
> if (virDomainCoreDump(dom, to, flags)< 0) {
> vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
> --
> 1.7.3.4
>
> --
> libvir-list mailing list
> libvir-list(a)redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
13 years, 2 months
Re: [libvirt] [PATCH] qemu: Allow domain reboot after core dump
by Sheldon
yes, the patch can work, when I execute virsh dump --reboot <domian> <file>
and the type of file is: QEMU's suspend to disk image
> -------- ???? --------
> ??: [libvirt] [PATCH] qemu: Allow domain reboot after core dump
> ??: Tue, 20 Sep 2011 13:34:27 +0200
> ???: Michal Privoznik <mprivozn(a)redhat.com>
> ???: libvir-list(a)redhat.com
>
>
>
> This patch introduces possibility to reboot domain after core dump
> finishes. The new flag VIR_DUMP_REBOOT was added to
> virDomainCoreDumpFlags. The new functionality is accessible via virsh
> too: virsh dump --reboot<domain>
> ---
> include/libvirt/libvirt.h.in | 1 +
> src/qemu/qemu_driver.c | 8 +++++++-
> tools/virsh.c | 3 +++
> 3 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 39155a6..8c41f5a 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -748,6 +748,7 @@ typedef enum {
> VIR_DUMP_CRASH = (1<< 0), /* crash after dump */
> VIR_DUMP_LIVE = (1<< 1), /* live dump */
> VIR_DUMP_BYPASS_CACHE = (1<< 2), /* avoid file system cache pollution */
> + VIR_DUMP_REBOOT = (1<< 3), /* reboot domain after dump finishes */
> } virDomainCoreDumpFlags;
>
> /* Domain migration flags. */
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index e2f428f..22576a8 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3104,7 +3104,8 @@ static int qemudDomainCoreDump(virDomainPtr dom,
> int ret = -1;
> virDomainEventPtr event = NULL;
>
> - virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH | VIR_DUMP_BYPASS_CACHE, -1);
> + virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH |
> + VIR_DUMP_BYPASS_CACHE | VIR_DUMP_REBOOT, -1);
>
> qemuDriverLock(driver);
> vm = virDomainFindByUUID(&driver->domains, dom->uuid);
> @@ -3189,6 +3190,11 @@ cleanup:
> if (event)
> qemuDomainEventQueue(driver, event);
> qemuDriverUnlock(driver);
> +
> + if ((ret == 0)&& (flags& VIR_DUMP_REBOOT)) {
> + qemuDomainReboot(dom, 0);
> + }
> +
> return ret;
> }
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index d575425..74f6a79 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -2840,6 +2840,7 @@ static const vshCmdOptDef opts_dump[] = {
> {"crash", VSH_OT_BOOL, 0, N_("crash the domain after core dump")},
> {"bypass-cache", VSH_OT_BOOL, 0,
> N_("avoid file system cache when saving")},
> + {"reboot", VSH_OT_BOOL, 0, N_("reboot the domain after core dump")},
> {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
> {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to dump the core")},
> {NULL, 0, 0, NULL}
> @@ -2869,6 +2870,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
> flags |= VIR_DUMP_CRASH;
> if (vshCommandOptBool(cmd, "bypass-cache"))
> flags |= VIR_DUMP_BYPASS_CACHE;
> + if (vshCommandOptBool(cmd, "reboot"))
> + flags |= VIR_DUMP_REBOOT;
>
> if (virDomainCoreDump(dom, to, flags)< 0) {
> vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
> --
> 1.7.3.4
>
> --
> libvir-list mailing list
> libvir-list(a)redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
13 years, 2 months
[libvirt] [PATCH] virsh: Improve virsh manual for virsh memtune command
by Peter Krempa
Commit 0a22f54 added --min-guarantee option for the memtune command.
This option is supported only by the ESX hypervisor. This patch adds a
statement about this fact, to prevent user confusion.
This patch also adds explanation how to clear/set to unlimited the
memory tunables. (documments the -1 value).
---
tools/virsh.pod | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 88dee26..7f46ee4 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -959,6 +959,7 @@ Allows you to display or set the domain memory parameters. Without
flags, the current settings are displayed; with a flag, the
appropriate limit is adjusted if supported by the hypervisor. LXC and
QEMU/KVM support I<--hard-limit>, I<--soft-limit>, and I<--swap-hard-limit>.
+I<--min-guarantee> is supported only by ESX hypervisor yet.
If I<--live> is specified, affect a running guest.
If I<--config> is specified, affect the next boot of a persistent guest.
@@ -997,6 +998,8 @@ value are kilobytes (i.e. blocks of 1024 bytes).
=back
+Specifying -1 as a value for these limits is interpreted as unlimited.
+
=item B<blkiotune> I<domain-id> [I<--weight> B<weight>] [[I<--config>]
[I<--live>] | [I<--current>]]
--
1.7.3.4
13 years, 2 months
[libvirt] Release of libvirt-0.9.6
by Daniel Veillard
That's what is now usually called a brown paper bag release (dixit Linus) [*]
since 0.9.5 had broken shudown with the two last released versions of QEmu
0.9.6 should be available at the usual place:
ftp://libvirt.org/libvirt/
and obviously only contains a few bug fixes and local improvements.
People should not ship 0.9.5, and use 0.9.6 instead, thanks in advance !
Bug Fixes:
- snapshot: fix logic bug in qemu undefine (Eric Blake)
- sanlock: fix memory leak (Eric Blake)
- virsh: fix regression in argv parsing (Eric Blake)
- storage: Wait udev events are handled before removing lvm vol (Osier Yang)
- qemu: avoid dereferencing a NULL pointer (Alex Jia)
- qemu: Avoid loop of fake reboots (Jiri Denemark)
- qemu: Fix shutdown regression with buggy qemu (Jiri Denemark)
- remote: fix crash on OOM (Eric Blake)
Improvements:
- snapshot: also delete empty directory (Eric Blake)
- snapshot: remove snapshot metadata on transient exit (Eric Blake)
- snapshot: prepare to remove transient snapshot metadata (Eric Blake)
- virsh: More friendly err if no pool is specified for looking up a vol (Osier Yang)
- tests: improve test failure diagnosis (Oskari Saarenmaa)
- API: prefer to use NULLSTR macro (Osier Yang)
- xen: use typical allocations (Eric Blake)
- virsh: Remove useless codes of cmdVolPath (Osier Yang)
Portability:
- build: silence warning on 32-bit build (Eric Blake)
Thanks to all who reported and helped fix those issues quickly !!!
Daniel
[*] and no I won't carry one, they are non-existent where I live
for context http://lwn.net/1999/0204/kernel.php3
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
13 years, 2 months
[libvirt] [PATCH 0/9] Implement keepalive protocol for libvirt RPC
by Jiri Denemark
This allows us to detect broken connections between server and client without
waiting for TCP timeout and dead deamon/client. By default a connection is
considered broken after about 30 seconds of no messages received from remote
party. After that period, the connection is automatically closed.
The main reason for implementing this is that peer-to-peer migration can now be
canceled when a connection between source and target breaks. Although this will
really work only after qemu fixes migrate_cancel command so that it doesn't
block when outgoing TCP buffers are full.
Jiri Denemark (9):
Define keepalive protocol
Implement common keepalive handling
Introduce two public APIs for keepalive protocol
Implement keepalive protocol in libvirt daemon
Add support for non-blocking calls in client RPC
Add support for async close of client RPC socket
Implement keepalive protocol in remote driver
Add keepalive support into domain-events examples
qemu: Add support for keepalive messages during p2p migration
.gitignore | 1 +
daemon/libvirtd.aug | 4 +
daemon/libvirtd.c | 11 +
daemon/libvirtd.conf | 15 +
daemon/remote.c | 38 ++
examples/domain-events/events-c/event-test.c | 11 +
examples/domain-events/events-python/event-test.py | 3 +
include/libvirt/libvirt.h.in | 5 +
po/POTFILES.in | 1 +
src/Makefile.am | 13 +-
src/driver.h | 9 +
src/libvirt.c | 107 +++++
src/libvirt_internal.h | 10 +-
src/libvirt_public.syms | 6 +
src/qemu/libvirtd_qemu.aug | 2 +
src/qemu/qemu.conf | 16 +
src/qemu/qemu_conf.c | 11 +
src/qemu/qemu_conf.h | 3 +
src/qemu/qemu_migration.c | 10 +
src/qemu/test_libvirtd_qemu.aug | 6 +
src/remote/remote_driver.c | 30 ++
src/remote/remote_protocol.x | 2 +-
src/rpc/virkeepalive.c | 464 ++++++++++++++++++++
src/rpc/virkeepalive.h | 58 +++
src/rpc/virkeepaliveprotocol.x | 8 +
src/rpc/virnetclient.c | 321 ++++++++++++--
src/rpc/virnetclient.h | 5 +
src/rpc/virnetserver.c | 10 +
src/rpc/virnetserver.h | 2 +
src/rpc/virnetserverclient.c | 126 +++++-
src/rpc/virnetserverclient.h | 6 +
31 files changed, 1254 insertions(+), 60 deletions(-)
create mode 100644 src/rpc/virkeepalive.c
create mode 100644 src/rpc/virkeepalive.h
create mode 100644 src/rpc/virkeepaliveprotocol.x
--
1.7.6.1
13 years, 2 months
[libvirt] [PATCH] virsh: Do not ignore the specified flags for cmdSaveImageDefine
by Osier Yang
---
tools/virsh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4b9e662..02db278 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2346,7 +2346,7 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd)
if (virFileReadAll(xmlfile, 8192, &xml) < 0)
goto cleanup;
- if (virDomainSaveImageDefineXML(ctl->conn, file, xml, 0) < 0) {
+ if (virDomainSaveImageDefineXML(ctl->conn, file, xml, flags) < 0) {
vshError(ctl, _("Failed to update %s"), file);
goto cleanup;
}
--
1.7.6
13 years, 2 months
[libvirt] [PATCH] qemu: Transfer inactive XML among cookie
by Michal Privoznik
If a domain has inactive XML we want to transfer it to destination
when migrating with VIR_MIGRATE_PERSIST_DEST. In order to harm
the migration protocol as least as possible, a optional cookie was
chosen.
---
src/qemu/qemu_migration.c | 91 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 82 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d9f8d93..bc98708 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -64,6 +64,7 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase, QEMU_MIGRATION_PHASE_LAST,
enum qemuMigrationCookieFlags {
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
+ QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
QEMU_MIGRATION_COOKIE_FLAG_LAST
};
@@ -71,11 +72,12 @@ enum qemuMigrationCookieFlags {
VIR_ENUM_DECL(qemuMigrationCookieFlag);
VIR_ENUM_IMPL(qemuMigrationCookieFlag,
QEMU_MIGRATION_COOKIE_FLAG_LAST,
- "graphics", "lockstate");
+ "graphics", "lockstate", "persistent");
enum qemuMigrationCookieFeatures {
QEMU_MIGRATION_COOKIE_GRAPHICS = (1 << QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
QEMU_MIGRATION_COOKIE_LOCKSTATE = (1 << QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE),
+ QEMU_MIGRATION_COOKIE_PERSISTENT = (1 << QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT),
};
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -110,6 +112,9 @@ struct _qemuMigrationCookie {
/* If (flags & QEMU_MIGRATION_COOKIE_GRAPHICS) */
qemuMigrationCookieGraphicsPtr graphics;
+
+ /* If (flags & QEMU_MIGRATION_COOKIE_PERSISTENT) */
+ virDomainDefPtr persistent;
};
static void qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphicsPtr grap)
@@ -334,6 +339,26 @@ qemuMigrationCookieAddLockstate(qemuMigrationCookiePtr mig,
}
+static int
+qemuMigrationCookieAddPersistent(qemuMigrationCookiePtr mig,
+ virDomainObjPtr dom)
+{
+ if (mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Migration persistent data already present"));
+ return -1;
+ }
+
+ if (!dom->newDef)
+ return 0;
+
+ mig->persistent = dom->newDef;
+ mig->flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;
+ mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_PERSISTENT;
+ return 0;
+}
+
+
static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
qemuMigrationCookieGraphicsPtr grap)
@@ -354,10 +379,12 @@ static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
static void qemuMigrationCookieXMLFormat(virBufferPtr buf,
- qemuMigrationCookiePtr mig)
+ qemuMigrationCookiePtr mig,
+ struct qemud_driver *driver)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char hostuuidstr[VIR_UUID_STRING_BUFLEN];
+ char *domXML;
int i;
virUUIDFormat(mig->uuid, uuidstr);
@@ -388,15 +415,25 @@ static void qemuMigrationCookieXMLFormat(virBufferPtr buf,
virBufferAddLit(buf, " </lockstate>\n");
}
+ if ((mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
+ mig->persistent) {
+ domXML = qemuDomainDefFormatXML(driver, mig->persistent,
+ VIR_DOMAIN_XML_INACTIVE |
+ VIR_DOMAIN_XML_SECURE);
+ virBufferAdd(buf, domXML, -1);
+ VIR_FREE(domXML);
+ }
+
virBufferAddLit(buf, "</qemu-migration>\n");
}
-static char *qemuMigrationCookieXMLFormatStr(qemuMigrationCookiePtr mig)
+static char *qemuMigrationCookieXMLFormatStr(qemuMigrationCookiePtr mig,
+ struct qemud_driver *driver)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- qemuMigrationCookieXMLFormat(&buf, mig);
+ qemuMigrationCookieXMLFormat(&buf, mig, driver);
if (virBufferError(&buf)) {
virReportOOMError();
@@ -460,6 +497,8 @@ error:
static int
qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
+ struct qemud_driver *driver,
+ xmlDocPtr doc,
xmlXPathContextPtr ctxt,
unsigned int flags)
{
@@ -583,6 +622,25 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
VIR_FREE(mig->lockState);
}
+ if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
+ virXPathBoolean("count(./domain) > 0", ctxt)) {
+ if ((n = virXPathNodeSet("./domain", ctxt, &nodes)) > 1) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Too many domain elements in "
+ "migration cookie: %d"),
+ n);
+ goto error;
+ }
+ mig->persistent = virDomainDefParseNode(driver->caps, doc, nodes[0],
+ -1, VIR_DOMAIN_XML_INACTIVE);
+ if (!mig->persistent) {
+ /* virDomainDefParseNode already reported
+ * an error for us */
+ goto error;
+ }
+ VIR_FREE(nodes);
+ }
+
return 0;
error:
@@ -594,6 +652,7 @@ error:
static int
qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
+ struct qemud_driver *driver,
const char *xml,
unsigned int flags)
{
@@ -606,7 +665,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
if (!(doc = virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"), &ctxt)))
goto cleanup;
- ret = qemuMigrationCookieXMLParse(mig, ctxt, flags);
+ ret = qemuMigrationCookieXMLParse(mig, driver, doc, ctxt, flags);
cleanup:
xmlXPathFreeContext(ctxt);
@@ -637,7 +696,11 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookieAddLockstate(mig, driver, dom) < 0)
return -1;
- if (!(*cookieout = qemuMigrationCookieXMLFormatStr(mig)))
+ if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT &&
+ qemuMigrationCookieAddPersistent(mig, dom) < 0)
+ return -1;
+
+ if (!(*cookieout = qemuMigrationCookieXMLFormatStr(mig, driver)))
return -1;
*cookieoutlen = strlen(*cookieout) + 1;
@@ -672,6 +735,7 @@ qemuMigrationEatCookie(struct qemud_driver *driver,
if (cookiein && cookieinlen &&
qemuMigrationCookieXMLParseStr(mig,
+ driver,
cookiein,
flags) < 0)
goto error;
@@ -1575,7 +1639,8 @@ cleanup:
}
if (ret == 0 &&
- qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen, 0) < 0)
+ qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
+ QEMU_MIGRATION_COOKIE_PERSISTENT ) < 0)
VIR_WARN("Unable to encode migration cookie");
qemuMigrationCookieFree(mig);
@@ -2477,6 +2542,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
int newVM = 1;
qemuMigrationCookiePtr mig = NULL;
virErrorPtr orig_err = NULL;
+ int cookie_flags = 0;
VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
@@ -2490,7 +2556,11 @@ qemuMigrationFinish(struct qemud_driver *driver,
v3proto ? QEMU_MIGRATION_PHASE_FINISH3
: QEMU_MIGRATION_PHASE_FINISH2);
- if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, 0)))
+ if (flags & VIR_MIGRATE_PERSIST_DEST)
+ cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;
+
+ if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein,
+ cookieinlen, cookie_flags)))
goto endjob;
/* Did the migration go as planned? If yes, return the domain
@@ -2510,7 +2580,10 @@ qemuMigrationFinish(struct qemud_driver *driver,
if (vm->persistent)
newVM = 0;
vm->persistent = 1;
- vmdef = virDomainObjGetPersistentDef(driver->caps, vm);
+ if (mig->persistent)
+ vm->newDef = vmdef = mig->persistent;
+ else
+ vmdef = virDomainObjGetPersistentDef(driver->caps, vm);
if (virDomainSaveConfig(driver->configDir, vmdef) < 0) {
/* Hmpf. Migration was successful, but making it persistent
* was not. If we report successful, then when this domain
--
1.7.3.4
13 years, 2 months
[libvirt] [PATCH 0/3] snapshot: auto-cleanup metadata of transient domains
by Eric Blake
I intended to do this ever since I changed the API of virDomainUndefine
to reject undefine of persistent guests with snapshots, but am only
now getting around to it. This missed 0.9.5, but I think it is worth
including in 0.9.6 even if we have a short release cycle to work
around the qemu shutdown issue.
Eric Blake (3):
snapshot: fix logic bug in qemu undefine
snapshot: prepare to remove transient snapshot metadata
snapshot: remove snapshot metadata on transient exit
src/conf/domain_conf.c | 4 +-
src/qemu/qemu_domain.c | 260 ++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 36 ++++++
src/qemu/qemu_driver.c | 291 +++-----------------------------------------
src/qemu/qemu_migration.c | 8 +-
src/qemu/qemu_process.c | 10 +-
6 files changed, 327 insertions(+), 282 deletions(-)
--
1.7.4.4
13 years, 2 months
[libvirt] [PATCH] locking: avoid dereferencing a NULL pointer
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
* src/locking/lock_driver_sanlock.c: in fact, virStrcpy calls
virStrncpy(dest, src, strlen(src), destbytes) then return result,
if 'path' is NULL, it means 'src' is also NULL, strlen(NULL) will
dereference a NULL pointer, which probably causes a segmentation fault.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/locking/lock_driver_sanlock.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 2d72510..8c6d873 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -158,7 +158,7 @@ static int virLockManagerSanlockSetupLockspace(void)
memcpy(ls.name, VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE, SANLK_NAME_LEN);
ls.host_id = 0; /* Doesn't matter for initialization */
ls.flags = 0;
- if (!virStrcpy(ls.host_id_disk.path, path, SANLK_PATH_LEN)) {
+ if (!path || !virStrcpy(ls.host_id_disk.path, path, SANLK_PATH_LEN)) {
virLockError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace path '%s' exceeded %d characters"),
path, SANLK_PATH_LEN);
--
1.7.1
13 years, 2 months
[libvirt] [PATCH] virsh: fix regression in argv parsing
by Eric Blake
Commit 85d2810 broke commands with mandatory argv (send-key,
qemu-monitor-command). This fixes things, and enhances the
test to cover it.
* tools/virsh.c (vshCmddefGetOption, vshCmddefGetData)
(vshCommandParse): Fix option parsing for required argv option.
(vshCmddefOptParse): Check that argv option is last.
* tests/virsh-optparse: Enhance test.
---
tests/virsh-optparse | 9 +++++++++
tools/virsh.c | 24 +++++++++++++++---------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/tests/virsh-optparse b/tests/virsh-optparse
index 18252d2..d0d4329 100755
--- a/tests/virsh-optparse
+++ b/tests/virsh-optparse
@@ -118,6 +118,7 @@ for args in \
'test name desc vda vdb' \
'test --diskspec vda name --diskspec vdb desc' \
'--description desc --name name --domain test vda vdb' \
+ '--description desc --diskspec vda --name name --domain test vdb' \
; do
virsh -q -c $test_url snapshot-create-as --print-xml $args \
>out 2>>err || fail=1
@@ -126,4 +127,12 @@ done
test -s err && fail=1
+# Test a required argv
+cat <<\EOF > exp-err || framework_failure
+error: this function is not supported by the connection driver: virDomainQemuMonitorCommand
+EOF
+virsh -q -c $test_url qemu-monitor-command test a >out 2>err && fail=1
+test -s out && fail=1
+compare err exp-err || fail=1
+
(exit $fail); exit $fail
diff --git a/tools/virsh.c b/tools/virsh.c
index 371346a..0b187bc 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -13834,6 +13834,7 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
return NULL;
}
+/* Validate that the options associated with cmd can be parsed. */
static int
vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
uint32_t *opts_required)
@@ -13871,13 +13872,16 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
} else {
optional = true;
}
+
+ if (opt->type == VSH_OT_ARGV && cmd->opts[i + 1].name)
+ return -1; /* argv option must be listed last */
}
return 0;
}
static const vshCmdOptDef *
vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
- uint32_t *opts_seen)
+ uint32_t *opts_seen, int *opt_index)
{
int i;
@@ -13885,12 +13889,12 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
const vshCmdOptDef *opt = &cmd->opts[i];
if (STREQ(opt->name, name)) {
- if (*opts_seen & (1 << i)) {
+ if ((*opts_seen & (1 << i)) && opt->type != VSH_OT_ARGV) {
vshError(ctl, _("option --%s already seen"), name);
return NULL;
}
- if (opt->type != VSH_OT_ARGV)
- *opts_seen |= 1 << i;
+ *opts_seen |= 1 << i;
+ *opt_index = i;
return opt;
}
}
@@ -13913,10 +13917,9 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
/* Grab least-significant set bit */
i = ffs(*opts_need_arg) - 1;
opt = &cmd->opts[i];
- if (opt->type != VSH_OT_ARGV) {
+ if (opt->type != VSH_OT_ARGV)
*opts_need_arg &= ~(1 << i);
- *opts_seen |= 1 << i;
- }
+ *opts_seen |= 1 << i;
return opt;
}
@@ -14878,12 +14881,14 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
} else if (tkdata[0] == '-' && tkdata[1] == '-' &&
c_isalnum(tkdata[2])) {
char *optstr = strchr(tkdata + 2, '=');
+ int opt_index;
+
if (optstr) {
*optstr = '\0'; /* convert the '=' to '\0' */
optstr = vshStrdup(ctl, optstr + 1);
}
if (!(opt = vshCmddefGetOption(ctl, cmd, tkdata + 2,
- &opts_seen))) {
+ &opts_seen, &opt_index))) {
VIR_FREE(optstr);
goto syntaxError;
}
@@ -14905,7 +14910,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
VSH_OT_INT ? _("number") : _("string"));
goto syntaxError;
}
- opts_need_arg &= ~opts_seen;
+ if (opt->type != VSH_OT_ARGV)
+ opts_need_arg &= ~(1 << opt_index);
} else {
tkdata = NULL;
if (optstr) {
--
1.7.4.4
13 years, 2 months