[libvirt] [PATCH v2] qemu: Implement CPUs check against machine type's cpu-max
by Michal Novotny
Implement check whether (maximum) vCPUs doesn't exceed machine
type's cpu-max settings.
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
---
src/conf/capabilities.h | 1 +
src/qemu/qemu_capabilities.c | 40 +++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_capabilities.h | 3 ++-
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 7 +++++++
src/qemu/qemu_process.c | 27 +++++++++++++++++++++++++++
6 files changed, 77 insertions(+), 2 deletions(-)
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index abcf6de..16bf3de 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -46,6 +46,7 @@ typedef virCapsGuestMachine *virCapsGuestMachinePtr;
struct _virCapsGuestMachine {
char *name;
char *canonical;
+ int cpu_max;
};
typedef struct _virCapsGuestDomainInfo virCapsGuestDomainInfo;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index d10c8aa..a03a643 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -243,6 +243,7 @@ struct _virQEMUCaps {
size_t nmachineTypes;
char **machineTypes;
char **machineAliases;
+ int *machineMaxCpus;
};
struct _virQEMUCapsCache {
@@ -322,6 +323,7 @@ virQEMUCapsSetDefaultMachine(virQEMUCapsPtr qemuCaps,
{
char *name = qemuCaps->machineTypes[defIdx];
char *alias = qemuCaps->machineAliases[defIdx];
+ int cpu_max = qemuCaps->machineMaxCpus[defIdx];
memmove(qemuCaps->machineTypes + 1,
qemuCaps->machineTypes,
@@ -329,8 +331,12 @@ virQEMUCapsSetDefaultMachine(virQEMUCapsPtr qemuCaps,
memmove(qemuCaps->machineAliases + 1,
qemuCaps->machineAliases,
sizeof(qemuCaps->machineAliases[0]) * defIdx);
+ memmove(qemuCaps->machineMaxCpus + 1,
+ qemuCaps->machineMaxCpus,
+ sizeof(qemuCaps->machineMaxCpus[0]) * defIdx);
qemuCaps->machineTypes[0] = name;
qemuCaps->machineAliases[0] = alias;
+ qemuCaps->machineMaxCpus[0] = cpu_max;
}
/* Format is:
@@ -377,7 +383,8 @@ virQEMUCapsParseMachineTypesStr(const char *output,
}
if (VIR_REALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes + 1) < 0 ||
- VIR_REALLOC_N(qemuCaps->machineAliases, qemuCaps->nmachineTypes + 1) < 0) {
+ VIR_REALLOC_N(qemuCaps->machineAliases, qemuCaps->nmachineTypes + 1) < 0 ||
+ VIR_REALLOC_N(qemuCaps->machineMaxCpus, qemuCaps->nmachineTypes + 1) < 0) {
VIR_FREE(name);
VIR_FREE(canonical);
goto no_memory;
@@ -390,6 +397,8 @@ virQEMUCapsParseMachineTypesStr(const char *output,
qemuCaps->machineTypes[qemuCaps->nmachineTypes-1] = name;
qemuCaps->machineAliases[qemuCaps->nmachineTypes-1] = NULL;
}
+ /* Value 0 means "unknown" as it's not exposed by QEMU binary */
+ qemuCaps->machineMaxCpus[qemuCaps->nmachineTypes-1] = 0;
} while ((p = next));
@@ -1718,6 +1727,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
goto no_memory;
if (VIR_ALLOC_N(ret->machineAliases, qemuCaps->nmachineTypes) < 0)
goto no_memory;
+ if (VIR_ALLOC_N(ret->machineMaxCpus, qemuCaps->nmachineTypes) < 0)
+ goto no_memory;
ret->nmachineTypes = qemuCaps->nmachineTypes;
for (i = 0 ; i < qemuCaps->nmachineTypes ; i++) {
if (!(ret->machineTypes[i] = strdup(qemuCaps->machineTypes[i])))
@@ -1725,6 +1736,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
if (qemuCaps->machineAliases[i] &&
!(ret->machineAliases[i] = strdup(qemuCaps->machineAliases[i])))
goto no_memory;
+ ret->machineMaxCpus[i] = qemuCaps->machineMaxCpus[i];
}
return ret;
@@ -1885,9 +1897,11 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
goto no_memory;
if (!(mach->canonical = strdup(qemuCaps->machineTypes[i])))
goto no_memory;
+ mach->cpu_max = qemuCaps->machineMaxCpus[i];
} else {
if (!(mach->name = strdup(qemuCaps->machineTypes[i])))
goto no_memory;
+ mach->cpu_max = qemuCaps->machineMaxCpus[i];
}
(*machines)[i] = mach;
}
@@ -1923,6 +1937,25 @@ const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
}
+int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
+ const char *name)
+{
+ size_t i;
+
+ if (!name)
+ return 0;
+
+ for (i = 0 ; i < qemuCaps->nmachineTypes ; i++) {
+ if (!qemuCaps->machineMaxCpus[i])
+ continue;
+ if (STREQ(qemuCaps->machineTypes[i], name))
+ return qemuCaps->machineMaxCpus[i];
+ }
+
+ return 0;
+}
+
+
static int
virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon)
@@ -2073,6 +2106,10 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
virReportOOMError();
goto cleanup;
}
+ if (VIR_ALLOC_N(qemuCaps->machineMaxCpus, nmachines) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
for (i = 0 ; i < nmachines ; i++) {
if (machines[i]->alias) {
@@ -2087,6 +2124,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
}
if (machines[i]->isDefault)
defIdx = i;
+ qemuCaps->machineMaxCpus[i] = machines[i]->cpu_max;
}
qemuCaps->nmachineTypes = nmachines;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 728add5..8205ff7 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -224,7 +224,8 @@ size_t virQEMUCapsGetMachineTypes(virQEMUCapsPtr qemuCaps,
char ***names);
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
const char *name);
-
+int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
+ const char *name);
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
size_t *nmachines,
virCapsGuestMachinePtr **machines);
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index f39f009..c097953 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -650,6 +650,7 @@ struct _qemuMonitorMachineInfo {
char *name;
bool isDefault;
char *alias;
+ int cpu_max;
};
int qemuMonitorGetMachines(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6fdd650..adbd865 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4024,6 +4024,13 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
goto cleanup;
}
}
+
+ if (virJSONValueObjectHasKey(child, "cpu-max") &&
+ virJSONValueObjectGetNumberInt(child, "cpu-max", &info->cpu_max) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("query-machines reply has malformed 'cpu-max' data"));
+ goto cleanup;
+ }
}
ret = n;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ce9f501..9eae8f6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3266,6 +3266,30 @@ qemuSetUnprivSGIO(virDomainDiskDefPtr disk)
return ret;
}
+static bool
+qemuValidateCpuMax(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
+{
+ int cpu_max;
+
+ cpu_max = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
+ if (!cpu_max)
+ return true;
+
+ if (def->vcpus > cpu_max) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("CPUs greater than specified machine type limit"));
+ return false;
+ }
+
+ if (def->maxvcpus > cpu_max) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("Maximum CPUs greater than specified machine type limit"));
+ return false;
+ }
+
+ return true;
+}
+
int qemuProcessStart(virConnectPtr conn,
virQEMUDriverPtr driver,
virDomainObjPtr vm,
@@ -3481,6 +3505,9 @@ int qemuProcessStart(virConnectPtr conn,
vm->def->emulator)))
goto cleanup;
+ if (!qemuValidateCpuMax(vm->def, priv->qemuCaps))
+ goto cleanup;
+
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
goto cleanup;
--
1.7.11.7
11 years, 7 months
[libvirt] (no subject)
by David Scott
Hi,
I've made an improved set of ocaml bindings for the libvirt event
mechanism which I'm now reasonably happy with. Improvements since
my first submission:
1. it's possible to deregister callbacks with 'deregister_any'
2. the callback to ocaml now re-acquires the heap lock *before*
creating and registering OCaml values with the GC: the previous
patches got this wrong and bad things happened
3. it's possible to add and remove timer callbacks: this is used
in the example to run Gc.compact() often, to check for problems
4. I removed the symbol detection for bindings present in libvirt
0.9.1
Let me know what you think!
Thanks,
Dave
11 years, 7 months
[libvirt] [PATCH 0/2] Add cpu-max to capabilities and implement checks
by Michal Novotny
Add cpu-max to capabilities XML output for newer QEMU and implement checks
whether the number of vCPUs/maximum vCPUS doesn't exceed machine limit.
For older versions of QEMU cpu-max field is not present so the cpu-max is
set to 0 to disable checking and act the same as without this patch.
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Michal Novotny (2):
cpu-max: Implement cpu-max attribute into capabilities XML output
qemu: Implement validation for max-cpu in XML
docs/schemas/capability.rng | 5 +++++
src/conf/capabilities.c | 4 ++++
src/conf/capabilities.h | 1 +
src/qemu/qemu_capabilities.c | 40 +++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_capabilities.h | 3 ++-
src/qemu/qemu_driver.c | 30 ++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 7 +++++++
8 files changed, 89 insertions(+), 2 deletions(-)
--
1.7.11.7
11 years, 7 months
[libvirt] Google Summer of Code 2013 ideas wiki open
by Stefan Hajnoczi
I have created the Google Summer of Code 2013 wiki page where you can
add project ideas:
http://wiki.qemu.org/Google_Summer_of_Code_2013
Please add project ideas you are willing to mentor. If you have an
idea but cannot mentor this year, feel free to add it but please try
to find a mentor for it.
If you want to be a mentor, please see
http://wiki.qemu.org/Google_Summer_of_Code_2013#Information_for_mentors.
Background on Google Summer of Code:
Google Summer of Code is a scheme where Google funds university
students to work on open source projects for 12 weeks during the
summer. It has been held annually since 2005.
GSoC is an opportunity for students to experience open source
development. Organizations sometimes find long-term contributors, and
either way it's a fun experience.
Open source organizations can apply to take part. Those chosen will
be able to take on one or more students for the summer. Each student
is paired with a mentor who helps them and evaluates their progress.
Last year QEMU was not accepted but we were successful in years before
that. I believe Google will announce GSoC again this year (there is
no guarantee though) and I have created the wiki page so we can begin
organizing project ideas that students can choose from.
This way we'll be ready to put together a good organization application.
Stefan
11 years, 7 months
[libvirt] [PATCH 0/6] cleanup: About including header
by Osier Yang
*** BLURB HERE ***
Osier Yang (6):
cleanup: Remove the duplicate header
cleanup: Only include testutils.h once
cleanup: Don't include libvirt/libvirt.h
cleanup: Don't include libvirt/virterror.h
syntax-check: Don't include duplicate header
syntax-check: Don't include libvirt.h and virterror.h
cfg.mk | 34 ++++++++++++++++++++++++++++++++++
daemon/libvirtd.c | 1 -
src/conf/node_device_conf.c | 1 -
src/network/bridge_driver.c | 1 -
src/nodeinfo.h | 1 -
src/openvz/openvz_conf.c | 1 -
src/openvz/openvz_driver.c | 1 -
src/parallels/parallels_driver.c | 1 -
src/phyp/phyp_driver.c | 2 --
src/qemu/qemu_capabilities.h | 1 -
src/qemu/qemu_driver.c | 1 -
src/remote/remote_driver.h | 2 --
src/remote/remote_protocol.x | 1 -
src/security/security_selinux.c | 1 -
src/uml/uml_driver.c | 1 -
src/util/virkeycode.h | 1 -
src/util/virnetdevtap.c | 1 -
src/xen/xen_hypervisor.c | 1 -
tests/domainsnapshotxml2xmltest.c | 4 ++--
tests/esxutilstest.c | 4 ++--
tests/lxcxml2xmltest.c | 4 ++--
tests/openvzutilstest.c | 4 ++--
tests/qemuargv2xmltest.c | 4 ++--
tests/qemuhelptest.c | 4 ++--
tests/qemumonitortest.c | 4 ++--
tests/qemuxml2argvtest.c | 4 ++--
tests/qemuxml2xmltest.c | 4 ++--
tests/qemuxmlnstest.c | 4 ++--
tests/shunloadtest.c | 4 ++--
tests/vmx2xmltest.c | 4 ++--
tests/xml2vmxtest.c | 4 ++--
31 files changed, 60 insertions(+), 45 deletions(-)
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 0/5] VirtualBox version 4.2 support for libvirt vbox driver
by ryan woodsmall
This patch set adds VirtualBox 4.2 initial support for the libvirt vbox driver.
I've tested enough to check capabilities, create a VM, destroy it, etc. Five
patches total:
- Patch 1 is the C API header file from Oracle, cleaned up for libvirt.
- Patch 2 is the version specific source file for version dependency.
- Patch 3 is the src/Makefile.am change to pick up the two new files.
- Patch 4 is the vbox driver support for the new VirtualBox API/version.
- Patch 5 is the vbox_tmpl.c template support for the new version.
A few things have changed in the VirtualBox API - some small (capitalizations
of things in function names like Ip to IP and Dhcp to DHCP) and some much larger
(FindMedium is superceded by OpenMedium). The biggest change for the sake of this
patch set is the signature of CreateMachine is quite a bit different. Using the
Oracle source as a guide, to spin up a VM with a given UUID, it looks like a text
flag has to be passed in a new argument to CreateMachine. This flag is built in the
VirtualBox 4.2 specific ifdefs and is kind of ugly but works. Additionally, there
is now (unused) VM groups support in CreateMachine and the previous 'osTypeId' arg
is currently set to nsnull as in the Oracle code.
The FindMedium to OpenMedium changes were more straightforward and are pretty clear.
The rest of the vbox template changes are basically spelling/capitalization changes
from the looks of things.
This probably isn't perfect, but it works on git and patched against 0.10.2 for a
few quick tests. Not currently on the list, so ping me directly if you need any
other info on these, or if anything could use additional work. Thanks! -r
ryan woodsmall (5):
vbox C API header for VirtualBox v4.2
vbox version-specific C file for VirtualBox v4.2
Makefile.am additions for VirtualBox v4.2
vbox driver support for VirtualBox v4.2
vbox template support for VirtualBox v4.2
src/Makefile.am | 3 +-
src/vbox/vbox_CAPI_v4_2.h | 8855 +++++++++++++++++++++++++++++++++++++++++++++
src/vbox/vbox_V4_2.c | 13 +
src/vbox/vbox_driver.c | 8 +
src/vbox/vbox_tmpl.c | 90 +-
5 files changed, 8958 insertions(+), 11 deletions(-)
create mode 100644 src/vbox/vbox_CAPI_v4_2.h
create mode 100644 src/vbox/vbox_V4_2.c
11 years, 7 months
[libvirt] [PATCH] Check for QMP query-tpm-models
by Stefan Berger
Check for QMP query-tpm-models and set a capability flag. Do not use
this QMP command if it is not supported.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/qemu/qemu_capabilities.c | 8 ++++++++
src/qemu/qemu_capabilities.h | 1 +
2 files changed, 9 insertions(+)
Index: libvirt/src/qemu/qemu_capabilities.h
===================================================================
--- libvirt.orig/src/qemu/qemu_capabilities.h
+++ libvirt/src/qemu/qemu_capabilities.h
@@ -179,6 +179,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_MACHINE_USB_OPT = 137, /* -machine xxx,usb=on/off */
QEMU_CAPS_DEVICE_TPM_PASSTHROUGH = 138, /* -tpmdev passthrough */
QEMU_CAPS_DEVICE_TPM_TIS = 139, /* -device tpm_tis */
+ QEMU_CAPS_TPM_MODELS = 140, /* query-tpm-models QMP command */
QEMU_CAPS_LAST, /* this must always be the last
item */
};
Index: libvirt/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt.orig/src/qemu/qemu_capabilities.c
+++ libvirt/src/qemu/qemu_capabilities.c
@@ -220,6 +220,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAS
"machine-usb-opt",
"tpm-passthrough",
"tpm-tis",
+
+ "query-tpm-models", /* 140 */
);
struct _virQEMUCaps {
@@ -1962,6 +1964,8 @@ virQEMUCapsProbeQMPCommands(virQEMUCapsP
virQEMUCapsSet(qemuCaps, QEMU_CAPS_ADD_FD);
else if (STREQ(name, "nbd-server-start"))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NBD_SERVER);
+ else if (STREQ(name, "query-tpm-models"))
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_TPM_MODELS);
VIR_FREE(name);
}
VIR_FREE(commands);
@@ -2144,6 +2148,10 @@ virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qe
{
int nentries, i;
char **entries = NULL;
+
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_TPM_MODELS))
+ return 0;
+
if ((nentries = qemuMonitorGetTPMModels(mon, &entries)) < 0)
return -1;
11 years, 7 months
[libvirt] [PATCH v2] Fix compilation error in util/vircgroup.c
by Stefan Berger
Fix the error
util/vircgroup.c: In function 'virCgroupNewDomainPartition':
util/vircgroup.c:1299:11: error: declaration of 'dirname' shadows a
global declaration [-Werror=shadow]
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/util/vircgroup.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: libvirt-acl/src/util/vircgroup.c
===================================================================
--- libvirt-acl.orig/src/util/vircgroup.c
+++ libvirt-acl/src/util/vircgroup.c
@@ -1296,13 +1296,13 @@ int virCgroupNewDomainPartition(virCgrou
virCgroupPtr *group)
{
int rc;
- char *dirname = NULL;
+ char *grpname = NULL;
- if (virAsprintf(&dirname, "%s.%s.libvirt",
+ if (virAsprintf(&grpname, "%s.%s.libvirt",
name, driver) < 0)
return -ENOMEM;
- rc = virCgroupNew(dirname, partition, -1, group);
+ rc = virCgroupNew(grpname, partition, -1, group);
if (rc == 0) {
/*
@@ -1322,7 +1322,7 @@ int virCgroupNewDomainPartition(virCgrou
}
}
- VIR_FREE(dirname);
+ VIR_FREE(grpname);
return rc;
}
#else
11 years, 7 months
[libvirt] [PATCH] Fix build breaker with ATTRIBUTE_NONNULL defs
by John Ferlan
Using "./autogen.sh --system lv_cv_static_analysis=yes" for my daily
Coverity builds resulted in the following error when building:
In file included from util/vircgrouppriv.h:32:0,
from util/vircgroup.c:44:
util/vircgroup.h:59:5: error: nonnull argument with out-of-range operand number (argument 1, operand 5)
util/vircgroup.h:74:5: error: nonnull argument references non-pointer operand (argument 1, operand 4)
make[3]: *** [libvirt_util_la-vircgroup.lo] Error 1
make[3]: Leaving directory `/home/jferlan/libvirt.cov.curr/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/jferlan/libvirt.cov.curr/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/jferlan/libvirt.cov.curr'
make: *** [all] Error 2
---
src/util/vircgroup.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index f324fa3..b030e4a 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -54,11 +54,11 @@ int virCgroupNewPartition(const char *path,
int virCgroupNewDriver(const char *name,
bool create,
int controllers,
virCgroupPtr *group)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(5);
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
int virCgroupNewSelf(virCgroupPtr *group)
ATTRIBUTE_NONNULL(1);
int virCgroupNewDomainDriver(virCgroupPtr driver,
@@ -69,11 +69,11 @@ int virCgroupNewDomainDriver(virCgroupPtr driver,
int virCgroupNewDomainPartition(virCgroupPtr partition,
const char *driver,
const char *name,
bool create,
virCgroupPtr *group)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
int virCgroupNewVcpu(virCgroupPtr domain,
int vcpuid,
bool create,
virCgroupPtr *group)
--
1.8.1.4
11 years, 7 months