[libvirt] Heads up 0.10.1 release on Friday
by Daniel Veillard
I was a bit afraid of the .0 effect on release name, but we really
have a number of problem with 0.10.0 that ought to be fixed in a
"brown paper bag" release. I would urge people to report and try to
fix the problem being raised in 0.10.0, let's try to get them fixed
today or tomorrow and I will cut a new release on Friday,
Sorry about that, but somehow we didn't managed to catch even serious
problem during the freeze, at some point we need to fix the problem of
testing the code that we push on git on a daily basis, we have many
tools but we lack at doing the continuous testing :-\
Daniel
--
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/
12 years, 2 months
[libvirt] [PATCH v4 0/3] Per-guest S3/S4 configuration
by Martin Kletzander
There is a way to tell qemu how (not) to advertise S3/S4 ACPI sleep
state capability to the guest OS. This series includes the capability
to set this in the XML and also covers all the handling from qemu
point of view including checking for the support, parameter parsing,
command building, checking before sending the signals through guest
agent and also tests and documentation.
--
Even though the patches were half-acked, I rather send them again with
the changes made after Michal's suggestions.
v4:
- Changed the XML config to subelements
- Minor fixes and optimalizations
v3:
- Option names are change according to Eric and Doug
- Added docs (formatdomain)
v2:
- Modified the patch to reflect danpb's notes (according to qemu
people the setting the disable_s[34] parameter to 0/1 ensures that
the states will be enabled/disabled respectively)
Martin Kletzander (3):
Add per-guest S3/S4 state configuration
qemu: Add support for S3/S4 state configuration
tests: Add tests for qemu S3/S4 state configuration
docs/formatdomain.html.in | 24 +++++++++
docs/schemas/domaincommon.rng | 39 ++++++++++++++
src/conf/domain_conf.c | 50 +++++++++++++++++
src/conf/domain_conf.h | 15 ++++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 7 +++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 62 ++++++++++++++++++++++
src/qemu/qemu_driver.c | 17 ++++++
tests/qemuargv2xmltest.c | 3 ++
.../qemuxml2argv-misc-disable-s3.args | 4 ++
.../qemuxml2argv-misc-disable-s3.xml | 29 ++++++++++
.../qemuxml2argv-misc-disable-suspends.args | 4 ++
.../qemuxml2argv-misc-disable-suspends.xml | 30 +++++++++++
.../qemuxml2argv-misc-enable-s4.args | 4 ++
.../qemuxml2argv-misc-enable-s4.xml | 29 ++++++++++
tests/qemuxml2argvtest.c | 4 ++
tests/qemuxml2xmltest.c | 3 ++
18 files changed, 328 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.xml
--
1.7.12
12 years, 2 months
[libvirt] [PATCH V4] implement offline migration
by liguang
allow migration even domain isn't active by
inserting some stubs to tunnel migration path.
Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_migration.c | 181 +++++++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_migration.h | 3 +-
3 files changed, 178 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d74bf52..00ca211 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9779,7 +9779,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
- if (!dom_xml) {
+ if (!dom_xml && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("no domain XML passed"));
goto cleanup;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1b21ef6..991bcc5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -70,6 +70,7 @@ enum qemuMigrationCookieFlags {
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
+ QEMU_MIGRATION_COOKIE_FLAG_OFFLINE,
QEMU_MIGRATION_COOKIE_FLAG_LAST
};
@@ -77,12 +78,13 @@ enum qemuMigrationCookieFlags {
VIR_ENUM_DECL(qemuMigrationCookieFlag);
VIR_ENUM_IMPL(qemuMigrationCookieFlag,
QEMU_MIGRATION_COOKIE_FLAG_LAST,
- "graphics", "lockstate", "persistent");
+ "graphics", "lockstate", "persistent", "offline");
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),
+ QEMU_MIGRATION_COOKIE_OFFLINE = (1 << QEMU_MIGRATION_COOKIE_FLAG_OFFLINE),
};
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -101,6 +103,10 @@ struct _qemuMigrationCookie {
unsigned int flags;
unsigned int flagsMandatory;
+ /*offline migration flag*/
+ int offline;
+ char *mig_file;
+
/* Host properties */
unsigned char localHostuuid[VIR_UUID_BUFLEN];
unsigned char remoteHostuuid[VIR_UUID_BUFLEN];
@@ -139,6 +145,8 @@ static void qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
if (mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS)
qemuMigrationCookieGraphicsFree(mig->graphics);
+ if (mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS)
+ VIR_FREE(mig->mig_file);
VIR_FREE(mig->localHostname);
VIR_FREE(mig->remoteHostname);
@@ -439,6 +447,12 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
virBufferAdjustIndent(buf, -2);
}
+ if (mig->flags & QEMU_MIGRATION_COOKIE_OFFLINE) {
+ virBufferAsprintf(buf, " <offline mig_ol='%d' mig_file='%s'>\n",
+ mig->offline, mig->mig_file);
+ virBufferAddLit(buf, " </offline>\n");
+ }
+
virBufferAddLit(buf, "</qemu-migration>\n");
return 0;
}
@@ -662,6 +676,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
VIR_FREE(nodes);
}
+ if ((flags & QEMU_MIGRATION_COOKIE_OFFLINE) &&
+ virXPathBoolean("count(./offline) > 0", ctxt)) {
+ if (virXPathInt("string(./offline/@mig_ol)", ctxt, &mig->offline) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing mig_ol attribute in migration data"));
+ goto error;
+ }
+ mig->mig_file = virXPathString("string(./offline/@mig_file)", ctxt);
+ if (mig->mig_file && STREQ(mig->mig_file, ""))
+ VIR_FREE(mig->mig_file);
+ }
+
return 0;
error:
@@ -721,6 +747,12 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookieAddPersistent(mig, dom) < 0)
return -1;
+ if (flags & QEMU_MIGRATION_COOKIE_OFFLINE) {
+ mig->flags |= QEMU_MIGRATION_COOKIE_OFFLINE;
+ mig->offline = 1;
+ }
+
+
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1;
@@ -1307,6 +1339,27 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
/* Domain starts inactive, even if the domain XML had an id field. */
vm->def->id = -1;
+ if (tunnel) {
+ if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+ QEMU_MIGRATION_COOKIE_OFFLINE)))
+ return ret;
+ else if (mig->offline) {
+ char *file, *str, *tmp = NULL;
+ ret = 0;
+ for (str = mig->mig_file; ; str = NULL) {
+ file = strtok_r(str, " ", &tmp);
+ if (file == NULL)
+ break;
+ if (virFDStreamCreateFile(st, file, 0, 0, O_WRONLY, 0) < 0) {
+ virReportSystemError(errno, "%s",
+ _("cannot setup stream for tunnelled migration\n"));
+ ret = -1;
+ }
+ }
+ goto endjob;
+ }
+ }
+
if (tunnel &&
(pipe(dataFD) < 0 || virSetCloseExec(dataFD[1]) < 0)) {
virReportSystemError(errno, "%s",
@@ -2303,6 +2356,117 @@ cleanup:
return ret;
}
+static int
+doReadFile(virStreamPtr st ATTRIBUTE_UNUSED,
+ char *buf, size_t nbytes, void *opaque)
+{
+ int *fd = opaque;
+
+ return saferead(*fd, buf, nbytes);
+}
+
+
+/*
+ * do offline migration
+ */
+static int doMigrateOffline(struct qemud_driver *driver,
+ virConnectPtr dconn,
+ virDomainObjPtr vm,
+ const char *cookiein,
+ int cookieinlen,
+ char **cookieout,
+ int *cookieoutlen,
+ unsigned long flags,
+ const char *dom_xml,
+ const char *dname,
+ virStreamPtr st,
+ unsigned long resource)
+{
+ xmlDocPtr xml = NULL;
+ xmlXPathContextPtr ctxt = NULL;
+ xmlNodePtr *disks = NULL;
+ qemuMigrationCookiePtr mig = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ int i = 0, cn = 0, fd = -1, ret = -1;
+ char *src[] = {NULL}, *files = NULL;
+
+ VIR_DEBUG("driver=%p, vm=%p, st=%p, cookiein=%s, cookieinlen=%d, "
+ "cookieout=%p, cookieoutlen=%p, dom_xml=%s,"
+ "dname=%s, flags=%lx, resource=%lu",
+ driver, vm, st, NULLSTR(cookiein), cookieinlen,
+ cookieout, cookieoutlen, dom_xml, dname, flags, resource);
+
+ xml = virXMLParseStringCtxt(dom_xml, _("(domain_definition)"), &ctxt);
+ if (!xml) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("can't parse dom_xml for offline migration\n"));
+ goto cleanup;
+ }
+ cn = virXPathNodeSet("./devices/disk", ctxt, &disks);
+ if (cn < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Fail to get disk node\n"));
+ goto cleanup;
+ }
+ cn = 1;
+
+ for (i = 0 ; i < cn ; i++) {
+ ctxt->node = disks[i];
+ src[i] = virXPathString("string(./source/@file"
+ "|./source/@dir"
+ "|./source/@name)", ctxt);
+ virBufferAsprintf(&buf, "%s ", src[i]);
+ }
+
+ files = virBufferContentAndReset(&buf);
+
+ if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
+ goto cleanup;
+
+ mig->mig_file = files;
+
+ if (qemuMigrationBakeCookie(mig, driver, vm,
+ cookieout, cookieoutlen,
+ QEMU_MIGRATION_COOKIE_OFFLINE) < 0)
+ goto cleanup;
+
+ cookiein = *cookieout;
+ cookieinlen = *cookieoutlen;
+ cookieout = NULL;
+ cookieoutlen = 0;
+
+ qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ ret = dconn->driver->domainMigratePrepareTunnel3
+ (dconn, st, cookiein, cookieinlen,
+ cookieout, cookieoutlen,
+ flags, dname, resource, dom_xml);
+ qemuDomainObjExitRemoteWithDriver(driver, vm);
+ if (ret == -1)
+ goto cleanup;
+
+ for (i = 0; i < cn; i++) {
+ if ((fd = open(src[i], O_RDONLY)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s %s",
+ _("Fail to open file for offline migration\n"), src[i]);
+ goto cleanup;
+ }
+ if (virStreamSendAll(st, doReadFile, &fd) < 0)
+ goto cleanup;
+ if (VIR_CLOSE(fd) < 0)
+ goto cleanup;
+ }
+
+ if (virStreamFinish(st) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(files);
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xml);
+ return ret;
+}
/* This is essentially a re-impl of virDomainMigrateVersion3
* from libvirt.c, but running in source libvirtd context,
@@ -2357,7 +2521,13 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
if (flags & VIR_MIGRATE_TUNNELLED) {
if (!(st = virStreamNew(dconn, 0)))
goto cleanup;
-
+ if (flags & VIR_MIGRATE_OFFLINE) {
+ if (doMigrateOffline(driver, dconn, vm, cookiein, cookieinlen,
+ &cookieout, &cookieoutlen, flags, dom_xml,
+ dname, st, resource) != -1)
+ ret = 0;
+ goto cleanup;
+ }
qemuDomainObjEnterRemoteWithDriver(driver, vm);
ret = dconn->driver->domainMigratePrepareTunnel3
(dconn, st, cookiein, cookieinlen,
@@ -2477,7 +2647,7 @@ finish:
vm->def->name);
cleanup:
- if (ddomain) {
+ if (ddomain || (flags & VIR_MIGRATE_OFFLINE)) {
virObjectUnref(ddomain);
ret = 0;
} else {
@@ -2557,7 +2727,7 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest unexpectedly quit"));
- goto cleanup;
+ flags |= VIR_MIGRATE_OFFLINE;
}
/* Change protection is only required on the source side (us), and
@@ -2573,7 +2743,6 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
else
ret = doPeer2PeerMigrate2(driver, sconn, dconn, vm,
dconnuri, flags, dname, resource);
-
cleanup:
orig_err = virSaveLastError();
qemuDomainObjEnterRemoteWithDriver(driver, vm);
@@ -2620,7 +2789,7 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
- goto endjob;
+ flags |= VIR_MIGRATE_OFFLINE;
}
if (!qemuMigrationIsAllowed(driver, vm, NULL))
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 1740204..2bcaea0 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -36,7 +36,8 @@
VIR_MIGRATE_NON_SHARED_DISK | \
VIR_MIGRATE_NON_SHARED_INC | \
VIR_MIGRATE_CHANGE_PROTECTION | \
- VIR_MIGRATE_UNSAFE)
+ VIR_MIGRATE_UNSAFE | \
+ VIR_MIGRATE_OFFLINE)
enum qemuMigrationJobPhase {
QEMU_MIGRATION_PHASE_NONE = 0,
--
1.7.2.5
12 years, 2 months
[libvirt] [PATCH V4] implement offline migration
by liguang
allow migration even domain isn't active by
inserting some stubs to tunnel migration path.
Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_migration.c | 181 +++++++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_migration.h | 3 +-
3 files changed, 178 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d74bf52..00ca211 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9779,7 +9779,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
- if (!dom_xml) {
+ if (!dom_xml && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("no domain XML passed"));
goto cleanup;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1b21ef6..991bcc5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -70,6 +70,7 @@ enum qemuMigrationCookieFlags {
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
+ QEMU_MIGRATION_COOKIE_FLAG_OFFLINE,
QEMU_MIGRATION_COOKIE_FLAG_LAST
};
@@ -77,12 +78,13 @@ enum qemuMigrationCookieFlags {
VIR_ENUM_DECL(qemuMigrationCookieFlag);
VIR_ENUM_IMPL(qemuMigrationCookieFlag,
QEMU_MIGRATION_COOKIE_FLAG_LAST,
- "graphics", "lockstate", "persistent");
+ "graphics", "lockstate", "persistent", "offline");
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),
+ QEMU_MIGRATION_COOKIE_OFFLINE = (1 << QEMU_MIGRATION_COOKIE_FLAG_OFFLINE),
};
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -101,6 +103,10 @@ struct _qemuMigrationCookie {
unsigned int flags;
unsigned int flagsMandatory;
+ /*offline migration flag*/
+ int offline;
+ char *mig_file;
+
/* Host properties */
unsigned char localHostuuid[VIR_UUID_BUFLEN];
unsigned char remoteHostuuid[VIR_UUID_BUFLEN];
@@ -139,6 +145,8 @@ static void qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
if (mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS)
qemuMigrationCookieGraphicsFree(mig->graphics);
+ if (mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS)
+ VIR_FREE(mig->mig_file);
VIR_FREE(mig->localHostname);
VIR_FREE(mig->remoteHostname);
@@ -439,6 +447,12 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
virBufferAdjustIndent(buf, -2);
}
+ if (mig->flags & QEMU_MIGRATION_COOKIE_OFFLINE) {
+ virBufferAsprintf(buf, " <offline mig_ol='%d' mig_file='%s'>\n",
+ mig->offline, mig->mig_file);
+ virBufferAddLit(buf, " </offline>\n");
+ }
+
virBufferAddLit(buf, "</qemu-migration>\n");
return 0;
}
@@ -662,6 +676,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
VIR_FREE(nodes);
}
+ if ((flags & QEMU_MIGRATION_COOKIE_OFFLINE) &&
+ virXPathBoolean("count(./offline) > 0", ctxt)) {
+ if (virXPathInt("string(./offline/@mig_ol)", ctxt, &mig->offline) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing mig_ol attribute in migration data"));
+ goto error;
+ }
+ mig->mig_file = virXPathString("string(./offline/@mig_file)", ctxt);
+ if (mig->mig_file && STREQ(mig->mig_file, ""))
+ VIR_FREE(mig->mig_file);
+ }
+
return 0;
error:
@@ -721,6 +747,12 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookieAddPersistent(mig, dom) < 0)
return -1;
+ if (flags & QEMU_MIGRATION_COOKIE_OFFLINE) {
+ mig->flags |= QEMU_MIGRATION_COOKIE_OFFLINE;
+ mig->offline = 1;
+ }
+
+
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1;
@@ -1307,6 +1339,27 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
/* Domain starts inactive, even if the domain XML had an id field. */
vm->def->id = -1;
+ if (tunnel) {
+ if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+ QEMU_MIGRATION_COOKIE_OFFLINE)))
+ return ret;
+ else if (mig->offline) {
+ char *file, *str, *tmp = NULL;
+ ret = 0;
+ for (str = mig->mig_file; ; str = NULL) {
+ file = strtok_r(str, " ", &tmp);
+ if (file == NULL)
+ break;
+ if (virFDStreamCreateFile(st, file, 0, 0, O_WRONLY, 0) < 0) {
+ virReportSystemError(errno, "%s",
+ _("cannot setup stream for tunnelled migration\n"));
+ ret = -1;
+ }
+ }
+ goto endjob;
+ }
+ }
+
if (tunnel &&
(pipe(dataFD) < 0 || virSetCloseExec(dataFD[1]) < 0)) {
virReportSystemError(errno, "%s",
@@ -2303,6 +2356,117 @@ cleanup:
return ret;
}
+static int
+doReadFile(virStreamPtr st ATTRIBUTE_UNUSED,
+ char *buf, size_t nbytes, void *opaque)
+{
+ int *fd = opaque;
+
+ return saferead(*fd, buf, nbytes);
+}
+
+
+/*
+ * do offline migration
+ */
+static int doMigrateOffline(struct qemud_driver *driver,
+ virConnectPtr dconn,
+ virDomainObjPtr vm,
+ const char *cookiein,
+ int cookieinlen,
+ char **cookieout,
+ int *cookieoutlen,
+ unsigned long flags,
+ const char *dom_xml,
+ const char *dname,
+ virStreamPtr st,
+ unsigned long resource)
+{
+ xmlDocPtr xml = NULL;
+ xmlXPathContextPtr ctxt = NULL;
+ xmlNodePtr *disks = NULL;
+ qemuMigrationCookiePtr mig = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ int i = 0, cn = 0, fd = -1, ret = -1;
+ char *src[] = {NULL}, *files = NULL;
+
+ VIR_DEBUG("driver=%p, vm=%p, st=%p, cookiein=%s, cookieinlen=%d, "
+ "cookieout=%p, cookieoutlen=%p, dom_xml=%s,"
+ "dname=%s, flags=%lx, resource=%lu",
+ driver, vm, st, NULLSTR(cookiein), cookieinlen,
+ cookieout, cookieoutlen, dom_xml, dname, flags, resource);
+
+ xml = virXMLParseStringCtxt(dom_xml, _("(domain_definition)"), &ctxt);
+ if (!xml) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("can't parse dom_xml for offline migration\n"));
+ goto cleanup;
+ }
+ cn = virXPathNodeSet("./devices/disk", ctxt, &disks);
+ if (cn < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Fail to get disk node\n"));
+ goto cleanup;
+ }
+ cn = 1;
+
+ for (i = 0 ; i < cn ; i++) {
+ ctxt->node = disks[i];
+ src[i] = virXPathString("string(./source/@file"
+ "|./source/@dir"
+ "|./source/@name)", ctxt);
+ virBufferAsprintf(&buf, "%s ", src[i]);
+ }
+
+ files = virBufferContentAndReset(&buf);
+
+ if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
+ goto cleanup;
+
+ mig->mig_file = files;
+
+ if (qemuMigrationBakeCookie(mig, driver, vm,
+ cookieout, cookieoutlen,
+ QEMU_MIGRATION_COOKIE_OFFLINE) < 0)
+ goto cleanup;
+
+ cookiein = *cookieout;
+ cookieinlen = *cookieoutlen;
+ cookieout = NULL;
+ cookieoutlen = 0;
+
+ qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ ret = dconn->driver->domainMigratePrepareTunnel3
+ (dconn, st, cookiein, cookieinlen,
+ cookieout, cookieoutlen,
+ flags, dname, resource, dom_xml);
+ qemuDomainObjExitRemoteWithDriver(driver, vm);
+ if (ret == -1)
+ goto cleanup;
+
+ for (i = 0; i < cn; i++) {
+ if ((fd = open(src[i], O_RDONLY)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s %s",
+ _("Fail to open file for offline migration\n"), src[i]);
+ goto cleanup;
+ }
+ if (virStreamSendAll(st, doReadFile, &fd) < 0)
+ goto cleanup;
+ if (VIR_CLOSE(fd) < 0)
+ goto cleanup;
+ }
+
+ if (virStreamFinish(st) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(files);
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xml);
+ return ret;
+}
/* This is essentially a re-impl of virDomainMigrateVersion3
* from libvirt.c, but running in source libvirtd context,
@@ -2357,7 +2521,13 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
if (flags & VIR_MIGRATE_TUNNELLED) {
if (!(st = virStreamNew(dconn, 0)))
goto cleanup;
-
+ if (flags & VIR_MIGRATE_OFFLINE) {
+ if (doMigrateOffline(driver, dconn, vm, cookiein, cookieinlen,
+ &cookieout, &cookieoutlen, flags, dom_xml,
+ dname, st, resource) != -1)
+ ret = 0;
+ goto cleanup;
+ }
qemuDomainObjEnterRemoteWithDriver(driver, vm);
ret = dconn->driver->domainMigratePrepareTunnel3
(dconn, st, cookiein, cookieinlen,
@@ -2477,7 +2647,7 @@ finish:
vm->def->name);
cleanup:
- if (ddomain) {
+ if (ddomain || (flags & VIR_MIGRATE_OFFLINE)) {
virObjectUnref(ddomain);
ret = 0;
} else {
@@ -2557,7 +2727,7 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest unexpectedly quit"));
- goto cleanup;
+ flags |= VIR_MIGRATE_OFFLINE;
}
/* Change protection is only required on the source side (us), and
@@ -2573,7 +2743,6 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
else
ret = doPeer2PeerMigrate2(driver, sconn, dconn, vm,
dconnuri, flags, dname, resource);
-
cleanup:
orig_err = virSaveLastError();
qemuDomainObjEnterRemoteWithDriver(driver, vm);
@@ -2620,7 +2789,7 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
- goto endjob;
+ flags |= VIR_MIGRATE_OFFLINE;
}
if (!qemuMigrationIsAllowed(driver, vm, NULL))
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 1740204..2bcaea0 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -36,7 +36,8 @@
VIR_MIGRATE_NON_SHARED_DISK | \
VIR_MIGRATE_NON_SHARED_INC | \
VIR_MIGRATE_CHANGE_PROTECTION | \
- VIR_MIGRATE_UNSAFE)
+ VIR_MIGRATE_UNSAFE | \
+ VIR_MIGRATE_OFFLINE)
enum qemuMigrationJobPhase {
QEMU_MIGRATION_PHASE_NONE = 0,
--
1.7.2.5
12 years, 2 months
[libvirt] Compiling a simple code which include libvirt
by Rahul Bansal
I am trying to compile this code by two methods but it shows error
1) Without -lvirt option
*/tmp/ccHGRn8q.o: In function `main':
ex1.c:(.text+0x15): undefined reference to `virConnectOpen'
ex1.c:(.text+0x57): undefined reference to `virConnectClose'*
2) with -lvirt option
*/usr/bin/ld: cannot find -lvirt
collect2: ld returned 1 exit status*
Someone help me!
12 years, 2 months
[libvirt] [libvirt-perl PATCH v2] Virt.xs: fix flag issue on set_scheduler_parameters
by Alex Jia
From: Alex Jia <Alex Jia ajia(a)redhat.com>
The default flags are inconsistent on both qemuSetSchedulerParameters()
and qemuGetSchedulerParameters() in libvirt, the qemuGetSchedulerParameters()
always passes 'VIR_DOMAIN_AFFECT_CURRENT' flag to the qemuGetSchedulerParametersFlags(),
it should be a expected behavior, but the qemuSetSchedulerParameters() always passes
'VIR_DOMAIN_AFFECT_LIVE' flag to the qemuSetSchedulerParametersFlags(), if users use
default flag=0 or explicitly give a 'VIR_DOMAIN_AFFECT_CURRENT' flag to the
set_scheduler_parameters() in perl-Sys-Virt, because the flag value is 0, the result is
the virDomainSetSchedulerParameters() is called incorrectly.
In fact, it's enough to call the qemuSetSchedulerParametersFlags() regardless of what flag is
like 'virsh schedinfo' command.
How to reproduce?
# cat test.pl
#!/usr/bin/env perl
use warnings;
use strict;
use Sys::Virt;
my $uri = "qemu:///system";
my $domname = "foo"; # change your guest name
my $con = Sys::Virt->new(address => $uri, readonly => 0);
my $dom = $con->get_domain_by_name($domname);
my %sched_param = (Sys::Virt::Domain::SCHEDULER_CPU_SHARES=>1);
$dom->set_scheduler_parameters(\%sched_param, Sys::Virt::Domain::AFFECT_CURRENT);
# perl test.pl
libvirt error code: 55, message: Requested operation is not valid: domain is not running
Signed-off-by: Alex Jia <Alex Jia ajia(a)redhat.com>
---
Virt.xs | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/Virt.xs b/Virt.xs
index 2b8d74c..fa58cc6 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -2833,13 +2833,9 @@ set_scheduler_parameters(dom, newparams, flags=0)
}
}
vir_typed_param_from_hv(newparams, params, nparams);
- if (flags) {
- if (virDomainSetSchedulerParametersFlags(dom, params, nparams, flags) < 0)
- _croak_error();
- } else {
- if (virDomainSetSchedulerParameters(dom, params, nparams) < 0)
- _croak_error();
- }
+
+ if (virDomainSetSchedulerParametersFlags(dom, params, nparams, flags) < 0)
+ _croak_error();
Safefree(params);
--
1.7.1
12 years, 2 months
[libvirt] Release of libvirt-0.10.1
by Daniel Veillard
As promised there is a fixup release since 0.10.0 is catastrophic,
and I should probably wear a brown paper bag ...
The tarball is being pushed as I write this and should be available
soon at the usual place:
ftp://libvirt.org/libvirt/
There are still known issues, count 2 weeks of developments and
a new week of freeze before 0.10.2, hopefully we will get those fixed
by then !
Without surprize it's a nearly only bug fixes release:
Bug Fixes:
- conf: Avoid formatting auto-generated DAC labels (Marcelo Cerri)
- conf: Fix parsing of seclabels without model (Marcelo Cerri)
- virsh: fixed incorrect timing report (Viktor Mihajlovski)
- qemu: Don't ignore CPU tuning config if required cgroups are missing (Jiri Denemark)
- cgroup: fix libvirtd crash caused by messed memory (Guannan Ren)
- cgroup: fix a typo on extracting data from vcpu cgroup (Guannan Ren)
- cgroup: read more data from cgroup cpuacct.usage_percpu (Guannan Ren)
- nwfilter: adapt IP learning for broadcasted DHCP replies (Stefan Berger)
- nwfilter: accept broadcasted DHCP replies in DHCP snooping code (Stefan Berger)
- Fix adding ports to OVS bridges without VLAN tags (Kyle Mestery)
- Fix xen driver following changes to make it stateful (Jim Fehlig)
- Fix issue of PF brought down if VF is 8021.Qbh and pci passthrough (Nishank Trivedi)
- nwfilter: loop generated too many rules (Stefan Berger)
- security: Re-apply commit ce53382ba28179d3a504b29b4f888b6e130d53f0 (Peter Krempa)
- vcpupin: Fix returning of arrays from virDomainVcpuPinAdd (Peter Krempa)
- qemu: Fix possible infinite loop and segfault on error path. (Peter Krempa)
- qemu: Clean up security driver initialisation and config file (Peter Krempa)
- qemu: Revert to blocking behavior of qemuAgentCommand (Jiri Denemark)
- qemu: Remove redundant parameter from qemuAgentSend (Jiri Denemark)
- network: get vlan info for Open vSwitch interfaces from proper source (Laine Stump)
- Small cleanup on previous patch (Daniel Veillard)
- Fix a crash when using Open vSwitch virtual ports (Kyle Mestery)
- qemu: Sort the numa params only when it affects the live config (Osier Yang)
- Fix configuration of QEMU security drivers (Daniel P. Berrange)
- qemu: Refactor initialisation of security drivers. (Peter Krempa)
- Revert "security: Add DAC to security_drivers" (Peter Krempa)
- qemu: Fix starting domains with no cpu cgroup (Jiri Denemark)
Documentation:
- virsh: Document subdriver option of attach-disk (Jiri Denemark)
- update option force to subcommand change-media (Guannan Ren)
- Fix typo in CPU tuning (Jiri Denemark)
- Fix emulator pinning example in formatdomain.html (Peter Krempa)
Improvement:
- Implement virMacAddrIsBroadcastRaw (Stefan Berger)
Cleanup:
- security: remove dead code from virSecurityDACGenLabel (Alex Jia)
Thanks to everybody for those 2 days frenetically chasing bugs and
trying to fix them !
Daniel
--
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/
12 years, 2 months