[libvirt] Entering freeze for libvirt-1.0.4
by Daniel Veillard
Based on the discussions from last week, we are entering freeze
now, I tagged v1.0.4-rc1 in git and pushed
libvirt-1.0.4-rc1.tar.gz
as well as rpms for F17 at the usual place:
ftp://libvirt.org/libvirt/
This looks functional for my limited testing, but give it a try.
Hopefully since 1.0.3 wasn't too long ago we should be mostly okay :)
And of course a release on April Fool sounds like a good target !
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, 6 months
[libvirt] [PATCHv2] conf: Enforce ranges on cputune variables
by Peter Krempa
The limits are documented at
http://libvirt.org/formatdomain.html#elementsCPUTuning . Enforce them
when going through XML parsing in addition to being enforced by the API.
---
Notes:
Version 2:
- split out from the conf callback series and applied separately to the parser code
src/conf/domain_conf.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f3fca7f..371d80c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9677,6 +9677,14 @@ virDomainDefParseXML(virCapsPtr caps,
goto error;
}
+ if (def->cputune.period > 0 &&
+ (def->cputune.period < 1000 || def->cputune.period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune period must be in range "
+ "[1000, 1000000]"));
+ goto error;
+ }
+
if (virXPathLongLong("string(./cputune/quota[1])", ctxt,
&def->cputune.quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -9684,6 +9692,15 @@ virDomainDefParseXML(virCapsPtr caps,
goto error;
}
+ if (def->cputune.quota > 0 &&
+ (def->cputune.quota < 1000 ||
+ def->cputune.quota > 18446744073709551)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune quota must be in range "
+ "[1000, 18446744073709551]"));
+ goto error;
+ }
+
if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt,
&def->cputune.emulator_period) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -9691,6 +9708,15 @@ virDomainDefParseXML(virCapsPtr caps,
goto error;
}
+ if (def->cputune.emulator_period > 0 &&
+ (def->cputune.emulator_period < 1000 ||
+ def->cputune.emulator_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_period must be in range "
+ "[1000, 1000000]"));
+ goto error;
+ }
+
if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt,
&def->cputune.emulator_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -9698,6 +9724,15 @@ virDomainDefParseXML(virCapsPtr caps,
goto error;
}
+ if (def->cputune.emulator_quota > 0 &&
+ (def->cputune.emulator_quota < 1000 ||
+ def->cputune.emulator_quota > 18446744073709551)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_quota must be in range "
+ "[1000, 18446744073709551]"));
+ goto error;
+ }
+
if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0)
goto error;
--
1.8.1.5
11 years, 6 months
[libvirt] [PATCH v5] qemu: Allow migration over IPv6
by Ján Tomko
Allow migration over IPv6 by listening on [::] instead of 0.0.0.0
when QEMU supports it (QEMU_CAPS_IPV6_MIGRATION) and there is
at least one v6 address configured on the system.
Use virURIParse in qemuMigrationPrepareDirect to allow parsing
IPv6 addresses, which would cause an 'incorrect :port' error
message before.
Move setting of migrateFrom from qemuMigrationPrepare{Direct,Tunnel}
after domain XML parsing, since we need the QEMU binary path from it
to get its capabilities.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=846013
---
diff to v4:
Always listen on IPv6 if it's available.
Don't add a migration flag.
v4:
https://www.redhat.com/archives/libvir-list/2013-March/msg01213.html
discussion:
https://www.redhat.com/archives/libvir-list/2013-March/msg00515.html
src/qemu/qemu_capabilities.c | 6 +++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_migration.c | 104 +++++++++++++++++++++++++++++++++----------
tests/qemuhelptest.c | 9 ++--
4 files changed, 93 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 3840b41..1e1da4d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -213,6 +213,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-ccw",
"dtb",
"megasas",
+
+ "ipv6-migration", /* 135 */
);
struct _virQEMUCaps {
@@ -1181,6 +1183,9 @@ virQEMUCapsComputeCmdFlags(const char *help,
if (version >= 11000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_HOST);
+ if (version >= 1001000)
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_IPV6_MIGRATION);
+
if (version >= 1002000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
return 0;
@@ -2317,6 +2322,7 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_SECCOMP_SANDBOX);
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_IPV6_MIGRATION);
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 7101f67..2ccc7c2 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -174,6 +174,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_VIRTIO_CCW = 132, /* -device virtio-*-ccw */
QEMU_CAPS_DTB = 133, /* -dtb file */
QEMU_CAPS_SCSI_MEGASAS = 134, /* -device megasas */
+ QEMU_CAPS_IPV6_MIGRATION = 135, /* -incoming [::] */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 537b834..867c7f1 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -22,6 +22,8 @@
#include <config.h>
+#include <netdb.h>
+#include <sys/socket.h>
#include <sys/time.h>
#ifdef WITH_GNUTLS
# include <gnutls/gnutls.h>
@@ -1104,12 +1106,12 @@ error:
*/
static int
qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
- virDomainObjPtr vm)
+ virDomainObjPtr vm,
+ const char *listenAddr)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
unsigned short port = 0;
- const char *listenAddr = "0.0.0.0";
char *diskAlias = NULL;
size_t i;
@@ -1980,8 +1982,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
int *cookieoutlen,
const char *dname,
const char *dom_xml,
- const char *migrateFrom,
virStreamPtr st,
+ unsigned int port,
unsigned long flags)
{
virDomainDefPtr def = NULL;
@@ -1997,6 +1999,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
char *xmlout = NULL;
unsigned int cookieFlags;
virCapsPtr caps = NULL;
+ const char *listenAddr = NULL;
+ char *migrateFrom = NULL;
if (virTimeMillisNow(&now) < 0)
return -1;
@@ -2084,6 +2088,45 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
}
}
+ if (tunnel) {
+ /* QEMU will be started with -incoming stdio
+ * (which qemu_command might convert to exec:cat or fd:n)
+ */
+ if (!(migrateFrom = strdup("stdio"))) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ virQEMUCapsPtr qemuCaps = NULL;
+ struct addrinfo *info = NULL;
+ struct addrinfo hints = { .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM };
+
+ if (!(qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
+ def->emulator)))
+ goto cleanup;
+
+ /* Listen on :: instead of 0.0.0.0 if QEMU understands it
+ * and there is at least one IPv6 address configured
+ */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_IPV6_MIGRATION) &&
+ getaddrinfo("::", NULL, &hints, &info) == 0) {
+ freeaddrinfo(info);
+ listenAddr = "[::]";
+ } else {
+ listenAddr = "0.0.0.0";
+ }
+ virObjectUnref(qemuCaps);
+
+ /* QEMU will be started with -incoming [::]:port
+ * or -incoming 0.0.0.0:port
+ */
+ if (virAsprintf(&migrateFrom, "tcp:%s:%d", listenAddr, port) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
if (!(vm = virDomainObjListAdd(driver->domains,
driver->xmlconf,
def,
@@ -2172,7 +2215,7 @@ done:
if (flags & VIR_MIGRATE_TUNNELLED)
VIR_DEBUG("NBD in tunnelled migration is currently not supported");
else {
- if (qemuMigrationStartNBDServer(driver, vm) < 0) {
+ if (qemuMigrationStartNBDServer(driver, vm, listenAddr) < 0) {
/* error already reported */
goto endjob;
}
@@ -2213,6 +2256,7 @@ done:
ret = 0;
cleanup:
+ VIR_FREE(migrateFrom);
VIR_FREE(origname);
VIR_FREE(xmlout);
virDomainDefFree(def);
@@ -2270,12 +2314,9 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
driver, dconn, NULLSTR(cookiein), cookieinlen,
cookieout, cookieoutlen, st, NULLSTR(dname), dom_xml, flags);
- /* QEMU will be started with -incoming stdio (which qemu_command might
- * convert to exec:cat or fd:n)
- */
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, dname, dom_xml,
- "stdio", st, flags);
+ st, 0, flags);
return ret;
}
@@ -2296,9 +2337,10 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
static int port = 0;
int this_port;
char *hostname = NULL;
- char migrateFrom [64];
const char *p;
+ char *uri_str = NULL;
int ret = -1;
+ virURIPtr uri;
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
@@ -2347,16 +2389,39 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
* URI when passing it to the qemu monitor, so bad
* characters in hostname part don't matter.
*/
- if (!STRPREFIX(uri_in, "tcp:")) {
+ if (!(p = STRSKIP(uri_in, "tcp:"))) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("only tcp URIs are supported for KVM/QEMU"
" migrations"));
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", p) < 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)
@@ -2369,25 +2434,16 @@ 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 (*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);
-
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, dname, dom_xml,
- migrateFrom, NULL, flags);
+ NULL, this_port, flags);
cleanup:
VIR_FREE(hostname);
if (ret != 0)
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index a28109a..05bb8a6 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -812,7 +812,8 @@ mymain(void)
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
QEMU_CAPS_DEVICE_USB_NET,
- QEMU_CAPS_DTB);
+ QEMU_CAPS_DTB,
+ QEMU_CAPS_IPV6_MIGRATION);
DO_TEST("qemu-1.2.0", 1002000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -913,7 +914,8 @@ mymain(void)
QEMU_CAPS_DEVICE_USB_SERIAL,
QEMU_CAPS_DEVICE_USB_NET,
QEMU_CAPS_DTB,
- QEMU_CAPS_SCSI_MEGASAS);
+ QEMU_CAPS_SCSI_MEGASAS,
+ QEMU_CAPS_IPV6_MIGRATION);
DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -1019,7 +1021,8 @@ mymain(void)
QEMU_CAPS_DEVICE_USB_SERIAL,
QEMU_CAPS_DEVICE_USB_NET,
QEMU_CAPS_DTB,
- QEMU_CAPS_SCSI_MEGASAS);
+ QEMU_CAPS_SCSI_MEGASAS,
+ QEMU_CAPS_IPV6_MIGRATION);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
1.8.1.5
11 years, 6 months
[libvirt] [PATCH] virsh: Add a helper to parse cpulist
by Osier Yang
vcpupin and emulatorpin use same code to parse the cpulist, this
abstracts the same code as a helper. Along with various code style
fixes, and error improvement (only error "Physical CPU %d doesn't
exist" if the specified CPU exceed the range, no "cpulist: Invalid
format", see the following for an example of the error prior to
this patch).
% virsh vcpupin 4 0 0-8
error: Physical CPU 4 doesn't exist.
error: cpulist: Invalid format.
---
tools/virsh-domain.c | 278 ++++++++++++++++++++-------------------------------
1 file changed, 106 insertions(+), 172 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d1e6f9d..0fe2a51 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5460,6 +5460,97 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
return true;
}
+static unsigned char *
+virParseCPUList(vshControl *ctl, const char *cpulist,
+ int maxcpu, size_t cpumaplen)
+{
+ unsigned char *cpumap = NULL;
+ const char *cur;
+ bool unuse = false;
+ int i, cpu, lastcpu;
+
+ cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
+
+ /* Parse cpulist */
+ cur = cpulist;
+ if (*cur == 'r') {
+ for (cpu = 0; cpu < maxcpu; cpu++)
+ VIR_USE_CPU(cpumap, cpu);
+ return cpumap;
+ } else if (*cur == 0) {
+ goto error;
+ }
+
+ while (*cur != 0) {
+ /* The char '^' denotes exclusive */
+ if (*cur == '^') {
+ cur++;
+ unuse = true;
+ }
+
+ /* Parse physical CPU number */
+ if (!c_isdigit(*cur))
+ goto error;
+
+ if ((cpu = virParseNumber(&cur)) < 0)
+ goto error;
+
+ if (cpu >= maxcpu) {
+ vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
+ goto cleanup;
+ }
+
+ virSkipSpaces(&cur);
+
+ if (*cur == ',' || *cur == 0) {
+ if (unuse)
+ VIR_UNUSE_CPU(cpumap, cpu);
+ else
+ VIR_USE_CPU(cpumap, cpu);
+ } else if (*cur == '-') {
+ /* The char '-' denotes range */
+ if (unuse)
+ goto error;
+ cur++;
+ virSkipSpaces(&cur);
+
+ /* Parse the end of range */
+ lastcpu = virParseNumber(&cur);
+
+ if (lastcpu < cpu)
+ goto error;
+
+ if (lastcpu >= maxcpu) {
+ vshError(ctl, _("Physical CPU %d doesn't exist."), maxcpu);
+ goto cleanup;
+ }
+
+ for (i = cpu; i <= lastcpu; i++)
+ VIR_USE_CPU(cpumap, i);
+
+ virSkipSpaces(&cur);
+ }
+
+ if (*cur == ',') {
+ cur++;
+ virSkipSpaces(&cur);
+ unuse = false;
+ } else if (*cur == 0) {
+ break;
+ } else {
+ goto error;
+ }
+ }
+
+ return cpumap;
+
+error:
+ vshError(ctl, "%s", _("cpulist: Invalid format."));
+cleanup:
+ VIR_FREE(cpumap);
+ return NULL;
+}
+
static bool
cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
{
@@ -5467,13 +5558,11 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
int vcpu = -1;
const char *cpulist = NULL;
- bool ret = true;
+ bool ret = false;
unsigned char *cpumap = NULL;
unsigned char *cpumaps = NULL;
size_t cpumaplen;
- int i, cpu, lastcpu, maxcpu, ncpus;
- bool unuse = false;
- const char *cur;
+ int i, maxcpu, ncpus;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
@@ -5545,7 +5634,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%s %s\n", _("VCPU:"), _("CPU Affinity"));
vshPrint(ctl, "----------------------------------\n");
for (i = 0; i < ncpus; i++) {
-
if (vcpu != -1 && i != vcpu)
continue;
@@ -5556,105 +5644,28 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
break;
}
- } else {
- ret = false;
}
VIR_FREE(cpumaps);
goto cleanup;
}
/* Pin mode: pinning specified vcpu to specified physical cpus*/
-
- cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
- /* Parse cpulist */
- cur = cpulist;
- if (*cur == 0) {
- goto parse_error;
- } else if (*cur == 'r') {
- for (cpu = 0; cpu < maxcpu; cpu++)
- VIR_USE_CPU(cpumap, cpu);
- cur = "";
- }
-
- while (*cur != 0) {
-
- /* the char '^' denotes exclusive */
- if (*cur == '^') {
- cur++;
- unuse = true;
- }
-
- /* parse physical CPU number */
- if (!c_isdigit(*cur))
- goto parse_error;
- cpu = virParseNumber(&cur);
- if (cpu < 0) {
- goto parse_error;
- }
- if (cpu >= maxcpu) {
- vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
- goto parse_error;
- }
- virSkipSpaces(&cur);
-
- if (*cur == ',' || *cur == 0) {
- if (unuse) {
- VIR_UNUSE_CPU(cpumap, cpu);
- } else {
- VIR_USE_CPU(cpumap, cpu);
- }
- } else if (*cur == '-') {
- /* the char '-' denotes range */
- if (unuse) {
- goto parse_error;
- }
- cur++;
- virSkipSpaces(&cur);
- /* parse the end of range */
- lastcpu = virParseNumber(&cur);
- if (lastcpu < cpu) {
- goto parse_error;
- }
- if (lastcpu >= maxcpu) {
- vshError(ctl, _("Physical CPU %d doesn't exist."), maxcpu);
- goto parse_error;
- }
- for (i = cpu; i <= lastcpu; i++) {
- VIR_USE_CPU(cpumap, i);
- }
- virSkipSpaces(&cur);
- }
-
- if (*cur == ',') {
- cur++;
- virSkipSpaces(&cur);
- unuse = false;
- } else if (*cur == 0) {
- break;
- } else {
- goto parse_error;
- }
- }
+ if (!(cpumap = virParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
+ goto cleanup;
if (flags == -1) {
- if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
- ret = false;
- }
+ if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0)
+ goto cleanup;
} else {
- if (virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) != 0) {
- ret = false;
- }
+ if (virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) != 0)
+ goto cleanup;
}
+ ret = true;
cleanup:
VIR_FREE(cpumap);
virDomainFree(dom);
return ret;
-
-parse_error:
- vshError(ctl, "%s", _("cpulist: Invalid format."));
- ret = false;
- goto cleanup;
}
/*
@@ -5701,13 +5712,11 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *cpulist = NULL;
- bool ret = true;
+ bool ret = false;
unsigned char *cpumap = NULL;
unsigned char *cpumaps = NULL;
size_t cpumaplen;
- int i, cpu, lastcpu, maxcpu;
- bool unuse = false;
- const char *cur;
+ int maxcpu;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
@@ -5761,101 +5770,26 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, " *: ");
ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, 0);
vshPrint(ctl, "\n");
- } else {
- ret = false;
}
VIR_FREE(cpumaps);
goto cleanup;
}
/* Pin mode: pinning emulator threads to specified physical cpus*/
-
- cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
- /* Parse cpulist */
- cur = cpulist;
- if (*cur == 0) {
- goto parse_error;
- } else if (*cur == 'r') {
- for (cpu = 0; cpu < maxcpu; cpu++)
- VIR_USE_CPU(cpumap, cpu);
- cur = "";
- }
-
- while (*cur != 0) {
-
- /* the char '^' denotes exclusive */
- if (*cur == '^') {
- cur++;
- unuse = true;
- }
-
- /* parse physical CPU number */
- if (!c_isdigit(*cur))
- goto parse_error;
- cpu = virParseNumber(&cur);
- if (cpu < 0) {
- goto parse_error;
- }
- if (cpu >= maxcpu) {
- vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
- goto parse_error;
- }
- virSkipSpaces(&cur);
-
- if (*cur == ',' || *cur == 0) {
- if (unuse) {
- VIR_UNUSE_CPU(cpumap, cpu);
- } else {
- VIR_USE_CPU(cpumap, cpu);
- }
- } else if (*cur == '-') {
- /* the char '-' denotes range */
- if (unuse) {
- goto parse_error;
- }
- cur++;
- virSkipSpaces(&cur);
- /* parse the end of range */
- lastcpu = virParseNumber(&cur);
- if (lastcpu < cpu) {
- goto parse_error;
- }
- if (lastcpu >= maxcpu) {
- vshError(ctl, _("Physical CPU %d doesn't exist."), maxcpu);
- goto parse_error;
- }
- for (i = cpu; i <= lastcpu; i++) {
- VIR_USE_CPU(cpumap, i);
- }
- virSkipSpaces(&cur);
- }
-
- if (*cur == ',') {
- cur++;
- virSkipSpaces(&cur);
- unuse = false;
- } else if (*cur == 0) {
- break;
- } else {
- goto parse_error;
- }
- }
+ if (!(cpumap = virParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
+ goto cleanup;
if (flags == -1)
flags = VIR_DOMAIN_AFFECT_LIVE;
if (virDomainPinEmulator(dom, cpumap, cpumaplen, flags) != 0)
- ret = false;
+ goto cleanup;
+ ret = true;
cleanup:
VIR_FREE(cpumap);
virDomainFree(dom);
return ret;
-
-parse_error:
- vshError(ctl, "%s", _("cpulist: Invalid format."));
- ret = false;
- goto cleanup;
}
/*
--
1.8.1.4
11 years, 6 months
[libvirt] [PATCHv5 00/11] Introduce driver specific XML parsing callbacks
by Peter Krempa
This series now splits out everything unrelated from the virCaps object.
See notes in individual patches for change summary.
This series now contains 2 renaming patches that were suggested by Eric and
Laine.
Peter Krempa (11):
conf: Add post XML parse callbacks and prepare for cleaning of virCaps
conf callback: Rearrange function parameters
qemu: Record the default NIC model in the domain XML
virCaps: get rid of "defaultInitPath" value in the virCaps struct
virCaps: get rid of defaultDiskDriverName
virCaps: get rid of emulatorRequired
virCaps: get rid of defaultDiskDriverType
virCaps: get rid of hasWideScsiBus
virCaps: get rid of macPrefix field
virCaps: get rid of defaultConsoleTargetType callback
maint: Rename xmlconf to xmlopt and virDomainXMLConfing to
virDomainXMLOption
src/conf/capabilities.c | 24 -
src/conf/capabilities.h | 23 -
src/conf/domain_conf.c | 658 ++++++++++++---------
src/conf/domain_conf.h | 103 ++--
src/conf/snapshot_conf.c | 4 +-
src/conf/snapshot_conf.h | 2 +-
src/esx/esx_driver.c | 32 +-
src/esx/esx_private.h | 2 +-
src/libvirt_private.syms | 10 +-
src/libvirt_vmx.syms | 1 +
src/libxl/libxl_conf.c | 13 -
src/libxl/libxl_conf.h | 2 +-
src/libxl/libxl_driver.c | 101 ++--
src/lxc/lxc_conf.c | 21 +-
src/lxc/lxc_conf.h | 4 +-
src/lxc/lxc_controller.c | 10 +-
src/lxc/lxc_domain.c | 34 ++
src/lxc/lxc_domain.h | 1 +
src/lxc/lxc_driver.c | 71 ++-
src/lxc/lxc_process.c | 8 +-
src/openvz/openvz_conf.c | 16 +-
src/openvz/openvz_conf.h | 2 +-
src/openvz/openvz_driver.c | 64 +-
src/parallels/parallels_driver.c | 37 +-
src/parallels/parallels_utils.h | 2 +-
src/phyp/phyp_driver.c | 24 +-
src/phyp/phyp_driver.h | 2 +-
src/qemu/qemu_capabilities.c | 19 -
src/qemu/qemu_command.c | 27 +-
src/qemu/qemu_command.h | 6 +-
src/qemu/qemu_conf.c | 16 +-
src/qemu/qemu_conf.h | 5 +-
src/qemu/qemu_domain.c | 98 ++-
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 147 +++--
src/qemu/qemu_migration.c | 21 +-
src/qemu/qemu_process.c | 34 +-
src/security/virt-aa-helper.c | 19 +-
src/test/test_driver.c | 69 +--
src/uml/uml_conf.c | 9 -
src/uml/uml_conf.h | 2 +-
src/uml/uml_driver.c | 69 ++-
src/vbox/vbox_tmpl.c | 33 +-
src/vmware/vmware_conf.c | 21 +-
src/vmware/vmware_conf.h | 2 +-
src/vmware/vmware_driver.c | 24 +-
src/vmx/vmx.c | 39 +-
src/vmx/vmx.h | 12 +-
src/xen/xen_driver.c | 37 +-
src/xen/xen_driver.h | 4 +-
src/xen/xen_hypervisor.c | 13 -
src/xen/xend_internal.c | 20 +-
src/xen/xm_internal.c | 16 +-
src/xenapi/xenapi_driver.c | 40 +-
src/xenapi/xenapi_driver_private.h | 2 +-
tests/domainsnapshotxml2xmltest.c | 6 +-
tests/lxcxml2xmldata/lxc-hostdev.xml | 1 +
tests/lxcxml2xmldata/lxc-systemd.xml | 1 +
tests/lxcxml2xmltest.c | 8 +-
tests/qemuargv2xmltest.c | 6 +-
tests/qemumonitorjsontest.c | 28 +-
tests/qemumonitortestutils.c | 4 +-
tests/qemumonitortestutils.h | 2 +-
...qemuxml2argv-disk-drive-network-nbd-export.args | 3 +-
.../qemuxml2argv-disk-drive-network-nbd-export.xml | 1 +
...ml2argv-disk-drive-network-nbd-ipv6-export.args | 3 +-
...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 3 +-
.../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd-unix.args | 3 +-
.../qemuxml2argv-disk-drive-network-nbd-unix.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd.args | 5 +-
.../qemuxml2argv-disk-drive-network-nbd.xml | 1 +
.../qemuxml2argv-disk-drive-network-rbd-auth.args | 2 +-
.../qemuxml2argv-disk-drive-network-rbd-ipv6.args | 2 +-
.../qemuxml2argv-disk-drive-network-rbd-ipv6.xml | 1 +
.../qemuxml2argv-disk-drive-network-rbd.args | 2 +-
.../qemuxml2argv-disk-drive-network-rbd.xml | 1 +
.../qemuxml2argv-disk-drive-network-sheepdog.args | 3 +-
.../qemuxml2argv-disk-drive-network-sheepdog.xml | 1 +
.../qemuxml2argv-net-bandwidth.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-client.args | 4 +-
.../qemuxml2argv-net-eth-ifname.args | 4 +-
.../qemuxml2argv-net-eth-ifname.xml | 1 +
.../qemuxml2argv-net-eth-names.args | 8 +-
tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 4 +-
tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args | 4 +-
.../qemuxml2argv-net-openvswitch.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-server.args | 4 +-
tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 3 +-
tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 +
.../qemuxml2argv-net-virtio-network-portgroup.xml | 2 +
tests/qemuxml2argvtest.c | 6 +-
.../qemuxml2xmlout-graphics-spice-timeout.xml | 1 +
tests/qemuxml2xmltest.c | 6 +-
tests/qemuxmlnstest.c | 6 +-
tests/securityselinuxlabeltest.c | 6 +-
tests/testutilslxc.c | 9 -
tests/testutilsqemu.c | 11 -
tests/testutilsqemu.h | 2 +-
tests/testutilsxen.c | 16 -
tests/testutilsxen.h | 2 -
tests/vmx2xmltest.c | 17 +-
tests/xmconfigtest.c | 8 +-
tests/xml2sexprtest.c | 9 +-
tests/xml2vmxtest.c | 19 +-
108 files changed, 1273 insertions(+), 1050 deletions(-)
--
1.8.1.5
11 years, 6 months
[libvirt] [PATCH v2] test: Return Libvirt logo as domain screenshot
by Michal Privoznik
This is just a bare Easter Egg. Whenever user run virDomainScreenshot
over a domain in test driver, he'll get the Libvirt PNG logo in return.
---
docs/Makefile.am | 1 +
src/test/test_driver.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 7583772..b5d7575 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -287,6 +287,7 @@ install-data-local:
for file in $(devhelphtml) $(devhelppng) $(devhelpcss); do \
$(INSTALL) -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \
done
+ $(INSTALL_DATA) $(srcdir)/../docs/libvirtLogo.png $(DESTDIR)$(pkgdatadir)
uninstall-local:
for h in $(apihtml); do rm $(DESTDIR)$(HTML_DIR)/$$h; done
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index c5fffb9..4dbd775 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -39,11 +39,13 @@
#include "virutil.h"
#include "viruuid.h"
#include "capabilities.h"
+#include "configmake.h"
#include "viralloc.h"
#include "network_conf.h"
#include "interface_conf.h"
#include "domain_conf.h"
#include "domain_event.h"
+#include "fdstream.h"
#include "storage_conf.h"
#include "node_device_conf.h"
#include "virxml.h"
@@ -5773,6 +5775,27 @@ cleanup:
return ret;
}
+static char *
+testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
+ virStreamPtr st,
+ unsigned int screen ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ char *ret = NULL;
+
+ virCheckFlags(0, NULL);
+
+ if (!(ret = strdup("image/png"))) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ if (virFDStreamOpenFile(st, PKGDATADIR "/libvirtLogo.png", 0, 0, O_RDONLY < 0))
+ VIR_FREE(ret);
+
+ return ret;
+}
+
static virDriver testDriver = {
.no = VIR_DRV_TEST,
@@ -5843,6 +5866,7 @@ static virDriver testDriver = {
.domainEventDeregisterAny = testDomainEventDeregisterAny, /* 0.8.0 */
.isAlive = testIsAlive, /* 0.9.8 */
.nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
+ .domainScreenshot = testDomainScreenshot, /* 1.0.5 */
};
static virNetworkDriver testNetworkDriver = {
--
1.8.1.5
11 years, 6 months
[libvirt] The problems of default settings
by Li Zhang
Hi all,
I am recently considering about the default setting for different platforms.
Currently, there is no good way to fix the default setting for PPC64
platform.
For example, we prefer pseries on PPC64 as the default machine type
users don't need to specify it.
I am thinking about the solutions.
1. One solution I am thinking about is to create template xml files for
different platforms.
But if users give their own configuration XML files, how to keep the
preferred configurations in domain definition.
I think this solution should be better in management tools, for example,
ovirt or openstack.
After management tools can generate its own configuration files with
different default settings,
libvirt can help create according to XML files.
2. Another solution is to use hook in libvirt.
But it seems that we need to use hook daemon. Is it complex to use?
I am not familiar with hook.
Any suggestion is appreciated.
Thanks. :)
--Li
11 years, 6 months
[libvirt] migrate qemu domains
by Yin Olivia-R63875
Hi,
I tried to migrate qemu domains between same two Freescale PPC platforms.
1) Migrate test domain from Host1(10.193.20.109) to Host2(10.193.20.181).
root@ppc-host1:~# virsh migrate test qemu+tls://10.193.20.181/system
or
root@ppc-host2:~# virsh -c qemu+tls://10.193.20.109/system migrate test qemu:///system
I waited for a while and finally got error message as below:
error: Unable to read from monitor: Connection reset by peer
Exactly, when waiting (I guess during migration), the migrated domain is pasued on
both source and destination nodes.
root@ppc-host1:~# virsh -c qemu:///system list --all
Id Name State
----------------------------------------------------
5 test paused
And meanwhile, the destination domain is also paused when waiting
root@ppc-host2:~# virsh -c qemu:///system list --all
Id Name State
----------------------------------------------------
2 test paused
Finally, the migrated domain on source node is shut off.
root@ppc-host1:~# virsh -c qemu:///system list --all
Id Name State
----------------------------------------------------
- test shut off
But can't find any domain on destination node any longer.
root@ppc-host2:~# virsh -c qemu:///system list --all
Id Name State
----------------------------------------------------
As I know qemu-system-ppc doesn't support live migration on Freescale PPC platform yet.
My question is whether it depends on qemu implementation to migrate qemu hypervisor with libvirt?
>From the above experiment, it seemed that migration happened but not succeeded finally.
Best Regards,
Olivia
11 years, 6 months
[libvirt] [PATCHv4 0/9] Introduce driver specific callbacks and get rid of irrelevant data in virCaps
by Peter Krempa
This series now splits out almost everything
from the virCaps object (except for the defaultConsoleTargetType
callback that I will post later as It requires more tweaking).
See notes in individual patches for change summary.
Peter Krempa (9):
conf: Add post XML parse callbacks and prepare for cleaning of virCaps
qemu: Record the default NIC model in the domain XML
virCaps: get rid of "defaultInitPath" value in the virCaps struct
virCaps: get rid of defaultDiskDriverName
virCaps: get rid of emulatorRequired
conf: Enforce ranges on cputune variables
virCaps: remove defaultDiskDriverType from the struct
virCaps: Get rid of hasWideScsiBus
virCaps: get rid of macPrefix field
src/conf/capabilities.c | 24 ---
src/conf/capabilities.h | 20 --
src/conf/domain_conf.c | 239 ++++++++++++++++-----
src/conf/domain_conf.h | 40 +++-
src/esx/esx_driver.c | 13 +-
src/libvirt_private.syms | 6 +-
src/libvirt_vmx.syms | 2 +
src/libxl/libxl_conf.c | 2 -
src/libxl/libxl_driver.c | 13 +-
src/lxc/lxc_conf.c | 11 +-
src/lxc/lxc_domain.c | 17 ++
src/lxc/lxc_domain.h | 1 +
src/lxc/lxc_driver.c | 6 +-
src/openvz/openvz_conf.c | 4 +-
src/openvz/openvz_driver.c | 32 ++-
src/parallels/parallels_driver.c | 12 +-
src/phyp/phyp_driver.c | 10 +-
src/qemu/qemu_capabilities.c | 6 -
src/qemu/qemu_command.c | 15 +-
src/qemu/qemu_conf.c | 14 +-
src/qemu/qemu_conf.h | 3 +-
src/qemu/qemu_domain.c | 89 ++++++++
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 13 +-
src/security/virt-aa-helper.c | 2 +-
src/test/test_driver.c | 2 +-
src/uml/uml_driver.c | 7 +-
src/vbox/vbox_tmpl.c | 18 +-
src/vmware/vmware_conf.c | 4 +-
src/vmware/vmware_driver.c | 8 +-
src/vmx/vmx.c | 39 ++--
src/vmx/vmx.h | 12 +-
src/xen/xen_driver.c | 7 +-
src/xen/xen_hypervisor.c | 2 -
src/xen/xend_internal.c | 6 +-
src/xen/xm_internal.c | 2 +
src/xenapi/xenapi_driver.c | 2 +-
tests/domainsnapshotxml2xmltest.c | 2 +-
tests/lxcxml2xmldata/lxc-hostdev.xml | 1 +
tests/lxcxml2xmldata/lxc-systemd.xml | 1 +
tests/qemuargv2xmltest.c | 2 +-
tests/qemumonitorjsontest.c | 2 +-
.../qemuxml2argv-disk-drive-network-nbd.args | 5 +-
.../qemuxml2argv-disk-drive-network-nbd.xml | 1 +
.../qemuxml2argv-disk-drive-network-rbd-auth.args | 2 +-
.../qemuxml2argv-disk-drive-network-rbd-ipv6.args | 2 +-
.../qemuxml2argv-disk-drive-network-rbd-ipv6.xml | 1 +
.../qemuxml2argv-disk-drive-network-rbd.args | 2 +-
.../qemuxml2argv-disk-drive-network-rbd.xml | 1 +
.../qemuxml2argv-disk-drive-network-sheepdog.args | 3 +-
.../qemuxml2argv-disk-drive-network-sheepdog.xml | 1 +
.../qemuxml2argv-net-bandwidth.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-client.args | 4 +-
.../qemuxml2argv-net-eth-ifname.args | 4 +-
.../qemuxml2argv-net-eth-ifname.xml | 1 +
.../qemuxml2argv-net-eth-names.args | 8 +-
tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 4 +-
tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args | 4 +-
.../qemuxml2argv-net-openvswitch.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-server.args | 4 +-
tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 3 +-
tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 +
.../qemuxml2argv-net-virtio-network-portgroup.xml | 2 +
tests/qemuxml2argvtest.c | 2 +-
.../qemuxml2xmlout-graphics-spice-timeout.xml | 1 +
tests/qemuxml2xmltest.c | 2 +-
tests/qemuxmlnstest.c | 2 +-
tests/securityselinuxlabeltest.c | 2 +-
tests/testutilsxen.c | 2 +-
tests/vmx2xmltest.c | 11 +-
tests/xml2vmxtest.c | 8 +-
73 files changed, 548 insertions(+), 251 deletions(-)
--
1.8.1.5
11 years, 6 months
[libvirt] [PATCHv2 0/4] Fix race and crash in connection close callback.
by Peter Krempa
Originaly reported by Viktor, this changes a few bits I didn't like
on the original series.
Peter Krempa (2):
virsh: Move cmdConnect from virsh-host.c to virsh.c
virsh: Register and unregister the close callback also in cmdConnect
Viktor Mihajlovski (2):
libvirt: Increase connection reference count for callbacks
virsh: Unregister the connection close notifier upon termination
src/libvirt.c | 5 +++
tools/virsh-host.c | 67 ----------------------------------
tools/virsh.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 103 insertions(+), 72 deletions(-)
--
1.8.1.5
11 years, 6 months