[libvirt] [PATCH v4 0/4] Add startupPolicy attribute support for hard disks
by Guannan Ren
v3: https://www.redhat.com/archives/libvir-list/2013-June/thread.html
v3 to v4: Rebase
v2 to v3: Not only check disk source, startupPolicy should work if any
backing file is missing. The commit 039a3283 break the limition
of contiguous device boot orders, so I remove my previous patch
about it.
v1 to v2: Added relax schema for disk of block and dir type
Removed original patch 3/5.
The set of patches is trying to add 'startupPolicy' attribute support
to the source element of hard disks. Policy levels are using the
mandatory, requisite, optional levels as originally documented.
For the 'optional' policy, there is a little difference from CDROM and
Floppy which only drop its source path, for disks, if missing, the
checking function will drop their definitions, because qemu doesn't
allow missing source path for hard disk.
Guannan Ren
[PATCH v3 1/4] conf: add startupPolicy attribute for harddisk
[PATCH v3 2/4] storage: report error rather than warning if backing files doesn't exist
[PATCH v3 3/4] qemu: drop disk with 'optional' startupPolicy if it is not present
[PATCH v3 4/4] security: restore DAC for every disk file in disk chain
docs/schemas/domaincommon.rng | 6 ++++++
include/libvirt/libvirt.h.in | 1 +
src/conf/domain_conf.c | 20 +++++++++++++-------
src/qemu/qemu_domain.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------
src/qemu/qemu_process.c | 7 -------
src/security/security_dac.c | 15 ++++++++++++++-
src/util/virstoragefile.c | 23 +++++++++++++++--------
tests/virstoragetest.c | 16 ++++++++--------
8 files changed, 130 insertions(+), 77 deletions(-)
11 years, 2 months
[libvirt] Adding network interfaces to VMs created on ESX hypervisor
by varun bhatnagar
Hi,
I want to create/attach two "internal" and one "host-only" interface to my
node created by libvirt on ESX hypervisor. Is it possible to do so?
If yes can anyone send a template of xml file?
If it is not possible then is there any alternative for this?
Regards,
Varun
11 years, 2 months
[libvirt] [PATCH] Ensure that /dev exists in the container root filesystem
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If booting a container with a root FS that isn't the host's
root, we must ensure that the /dev mount point exists.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_container.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 0ab4026..678a9d5 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -868,7 +868,7 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
static int lxcContainerMountFSDev(virDomainDefPtr def,
const char *stateDir)
{
- int ret;
+ int ret = -1;
char *path = NULL;
VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir);
@@ -877,14 +877,24 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
stateDir, def->name)) < 0)
return ret;
+ if (virFileMakePath("/dev") < 0) {
+ virReportSystemError(errno, "%s",
+ _("Cannot create /dev"));
+ goto cleanup;
+ }
+
VIR_DEBUG("Tring to move %s to /dev", path);
- if ((ret = mount(path, "/dev", NULL, MS_MOVE, NULL)) < 0) {
+ if (mount(path, "/dev", NULL, MS_MOVE, NULL) < 0) {
virReportSystemError(errno,
_("Failed to mount %s on /dev"),
path);
+ goto cleanup;
}
+ ret = 0;
+
+cleanup:
VIR_FREE(path);
return ret;
}
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] util: Fix crash of libvirtd when running numatune with invalid nodeset
by Alex Jia
This issue is introduced by commit 0fc8909, the virBitmapIsSet() needs caller
to ensure 'b < bitmap->max_bit', but it's lost in the virBitmapParse() caller,
this will cause crash of libvirtd, with the patch, libvirtd no crash and can
get a expected error "Failed to parse nodeset".
How to reproduce?
# virsh numatune foo --nodeset 1000000000
Actual result:
error: Unable to change numa parameters
error: End of file while reading data: Input/output error
error: One or more references were leaked after disconnect from the hypervisor
error: Failed to reconnect to the hypervisor
GDB backtrace:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f80ee533700 (LWP 4156)]
0x00007f80fb1b8906 in virBitmapIsSet (str=<value optimized out>, terminator=0 '\000', bitmap=0x7f80ee532978, bitmapSize=<value optimized out>)
at util/virbitmap.c:158
158 return !!(bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] & VIR_BITMAP_BIT(b));
(gdb) bt
#0 0x00007f80fb1b8906 in virBitmapIsSet (str=<value optimized out>, terminator=0 '\000', bitmap=0x7f80ee532978, bitmapSize=<value optimized out>)
at util/virbitmap.c:158
#1 virBitmapParse (str=<value optimized out>, terminator=0 '\000', bitmap=0x7f80ee532978, bitmapSize=<value optimized out>) at util/virbitmap.c:351
#2 0x00007f80e5e7ef6b in qemuDomainSetNumaParameters (dom=<value optimized out>, params=<value optimized out>, nparams=1, flags=2) at qemu/qemu_driver.c:8357
#3 0x00007f80fb2ad7c6 in virDomainSetNumaParameters (domain=0x7f80d4000930, params=0x7f80d4000b00, nparams=1, flags=0) at libvirt.c:4163
#4 0x00007f80fbcd17ec in remoteDispatchDomainSetNumaParameters (server=<value optimized out>, client=<value optimized out>, msg=<value optimized out>,
rerr=0x7f80ee532ba0, args=<value optimized out>, ret=<value optimized out>) at remote_dispatch.h:7771
#5 remoteDispatchDomainSetNumaParametersHelper (server=<value optimized out>, client=<value optimized out>, msg=<value optimized out>, rerr=0x7f80ee532ba0,
args=<value optimized out>, ret=<value optimized out>) at remote_dispatch.h:7741
#6 0x00007f80fb2f6518 in virNetServerProgramDispatchCall (prog=0x7f80fd33a990, server=0x7f80fd32f3e0, client=0x7f80fd33fe30, msg=0x7f80fd33e550)
at rpc/virnetserverprogram.c:435
#7 virNetServerProgramDispatch (prog=0x7f80fd33a990, server=0x7f80fd32f3e0, client=0x7f80fd33fe30, msg=0x7f80fd33e550) at rpc/virnetserverprogram.c:305
#8 0x00007f80fb2f9dd6 in virNetServerProcessMsg (srv=<value optimized out>, client=0x7f80fd33fe30, prog=<value optimized out>, msg=0x7f80fd33e550)
at rpc/virnetserver.c:165
#9 0x00007f80fb2fa9f3 in virNetServerHandleJob (jobOpaque=<value optimized out>, opaque=<value optimized out>) at rpc/virnetserver.c:186
#10 0x00007f80fb20210e in virThreadPoolWorker (opaque=<value optimized out>) at util/virthreadpool.c:144
#11 0x00007f80fb2016f6 in virThreadHelper (data=<value optimized out>) at util/virthreadpthread.c:161
#12 0x00007f80f8d857f1 in start_thread (arg=0x7f80ee533700) at pthread_create.c:301
#13 0x00007f80f86bb70d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=997367
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
The caller virBitmapGetBit() can make sure 'b < bitmap->max_bit', so don't
need to worry about higher caller for the virBitmapGetBit(), but the
virBitmapParse() is called by many XML parser function, not sure which one
can crash libvirtd with read-only client then probably require a CVE, I haven't
a good way to check them now and only manually check them one by one.
src/util/virbitmap.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 7e1cd02..edbfb30 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -337,6 +337,9 @@ virBitmapParse(const char *str,
if (start < 0)
goto parse_error;
+ if ((*bitmap)->max_bit <= start)
+ goto parse_error;
+
cur = tmp;
virSkipSpaces(&cur);
--
1.7.1
11 years, 2 months
[libvirt] RFC: Introduce API to return configuration/state paths of the network driver
by Nehal J. Wani
Currently, there is no API which returns configuration/state paths of the
network driver.
Although it is a private implementation of the network driver, I don't see
any harm in
making the locations public because although the locations might change,
there will always
be a location for these files. There is a need for this API to implement
method 2 of the
"API to query ip addresses of a given domain", refer:
http://www.mail-archive.com/libvir-list@redhat.com/msg79793.html . It is
required to parse
the leases file generated by dnsmasq. So, this API will be used by the qemu
driver, but it
can also be made public, so that, if a user wants to know get some
information from a
configuration file, he can get the location from libvirt and analyze it on
his own. Right now,
there is an alternate way to get the info: by using
networkDnsmasqLeaseFileNameDefault,
defined in /src/network/bridge_driver.c Since this function is static, it
is part of the private
implementation and not visible outside. To make it public, the following
hack is possible:
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a7ff602..7274861 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -124,7 +124,7 @@ static int networkUnplugBandwidth(virNetworkObjPtr net,
static struct network_driver *driverState = NULL;
-static char *
+char *
networkDnsmasqLeaseFileNameDefault(const char *netname)
{
char *leasefile;
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 50258b5..40e3990 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -49,6 +49,8 @@ int networkDnsmasqConfContents(virNetworkObjPtr network,
char **configstr,
dnsmasqContext *dctx,
dnsmasqCapsPtr caps);
+char * networkDnsmasqLeaseFileNameDefault(const char *netname)
+ ATTRIBUTE_NONNULL(1);
# else
/* Define no-op replacements that don't drag in any link dependencies. */
# define networkAllocateActualDevice(iface) 0
@@ -57,6 +59,7 @@ int networkDnsmasqConfContents(virNetworkObjPtr network,
# define networkGetNetworkAddress(netname, netaddr) (-2)
# define networkDnsmasqConfContents(network, pidfile, configstr, \
dctx, caps) 0
+# define networkDnsmasqLeaseFileNameDefault(netname) 0
# endif
typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname);
Similar hack has been used so that networkAllocateActualDevice() can be
called
from qemu_command.c. Although the above method works, we want to have a
formal API and not leave things like a hack.
/*
* @conn: connection object
* @params: array to populate on output
* @nparams: number of parameters that will be filled
* @flags: not supported, user should pass 0 for now
* return 0 on success -1 otherwise
* Valid parameter field names:
* VIR_NETWORK_CONFIG_DIR, VIR_NETWORK_AUTOSTART_DIR, VIR_STATE_DIR,
* VIR_PID_DIR, VIR_DNSMASQ_STATE_DIR, VIR_RADVD_STATE_DIR
* All the above will of the type VIR_TYPED_PARAM_STRING
*/
int virNetworkGetConfigFileName(virConnectPtr conn,
virTypedParameterPtr params,
int nparams,
unsigned int flags)
Nehal J. Wani
UG3, BTech CS+MS(CL)
IIIT-Hyderabad
http://commandlinewani.blogspot.com
11 years, 2 months
[libvirt] [PATCH] tools: Make sure to distribute conf_DATA, fix RPM build
by Cole Robinson
---
Pushed as build breaker.
tools/Makefile.am | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index d48883c..f85c35c 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -33,6 +33,7 @@ ICON_FILES = \
EXTRA_DIST = \
$(ICON_FILES) \
+ $(conf_DATA) \
virt-xml-validate.in \
virt-pki-validate.in \
virt-sanlock-cleanup.in \
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH 00/10] test: Mock snapshot APIs and misc improvements
by Cole Robinson
This series implements snapshot APIs for the test driver, and adds
some misc improvements, like specifying domain state in the passed
in driver XML.
Cole Robinson (10):
test: Split object parsing into their own functions
test: Simplify args passed to testDomainStartState
test: Unify object XML parsing
test: Allow specifying object runstate in driver XML
test: Allow specifying object transient state in driver XML
test: Wire up managed save APIs
snapshot_conf: Allow parsing an XML node
test: Allow specifying <domainsnapshot> XML
test: Implement readonly snapshot APIs
test: Implement snapshot create/delete/revert APIs
src/conf/domain_conf.c | 3 +-
src/conf/snapshot_conf.c | 85 +-
src/conf/snapshot_conf.h | 6 +
src/test/test_driver.c | 4871 +++++++++++++++++++++++++++++-----------------
tests/virshtest.c | 2 +-
5 files changed, 3151 insertions(+), 1816 deletions(-)
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] Add flag to BaselineCPU API to return detailed CPU features
by Don Dugger
Currently the virConnectBaselineCPU API does not expose the CPU features
that are part of the CPU's model. This patch adds a new flag,
VIR_CONNECT_BASELINE_SHOW_MODEL, that causes the API to explictly
list all features that are part of that model.
Signed-off-by: Don Dugger <donald.d.dugger(a)intel.com>
---
include/libvirt/libvirt.h.in | 9 +++++++
src/cpu/cpu.c | 12 +++++----
src/cpu/cpu.h | 12 ++++++---
src/cpu/cpu_arm.c | 3 ++-
src/cpu/cpu_generic.c | 3 ++-
src/cpu/cpu_powerpc.c | 6 +++--
src/cpu/cpu_s390.c | 3 ++-
src/cpu/cpu_x86.c | 39 ++++++++++++++++++++++++---
src/qemu/qemu_driver.c | 4 +--
tests/cputest.c | 30 +++++++++++----------
tests/cputestdata/x86-baseline-3-result.xml | 35 ++++++++++++++++++++++++
tests/cputestdata/x86-baseline-3.xml | 7 +++++
tools/virsh-domain.c | 11 +++++++-
13 files changed, 140 insertions(+), 34 deletions(-)
create mode 100644 tests/cputestdata/x86-baseline-3-result.xml
create mode 100644 tests/cputestdata/x86-baseline-3.xml
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 1804c93..d0afc65 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3890,6 +3890,15 @@ int virConnectCompareCPU(virConnectPtr conn,
/**
+ * virConnectBaselineCPUFlags
+ *
+ * Flags when getting XML description of a computed CPU
+ */
+typedef enum {
+ VIR_CONNECT_BASELINE_SHOW_MODEL = (1 << 0), /* show model features*/
+} virConnectBaselineCPUFlags;
+
+/**
* virConnectBaselineCPU:
*
* @conn: virConnect connection
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 68125a5..c96f669 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -167,7 +167,7 @@ cpuDecode(virCPUDefPtr cpu,
return -1;
}
- return driver->decode(cpu, data, models, nmodels, preferred);
+ return driver->decode(cpu, data, models, nmodels, preferred, 0);
}
@@ -277,7 +277,8 @@ char *
cpuBaselineXML(const char **xmlCPUs,
unsigned int ncpus,
const char **models,
- unsigned int nmodels)
+ unsigned int nmodels,
+ unsigned int flags)
{
xmlDocPtr doc = NULL;
xmlXPathContextPtr ctxt = NULL;
@@ -324,7 +325,7 @@ cpuBaselineXML(const char **xmlCPUs,
doc = NULL;
}
- if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels)))
+ if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels, flags)))
goto error;
cpustr = virCPUDefFormat(cpu, 0);
@@ -353,7 +354,8 @@ virCPUDefPtr
cpuBaseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
- unsigned int nmodels)
+ unsigned int nmodels,
+ unsigned int flags)
{
struct cpuArchDriver *driver;
unsigned int i;
@@ -395,7 +397,7 @@ cpuBaseline(virCPUDefPtr *cpus,
return NULL;
}
- return driver->baseline(cpus, ncpus, models, nmodels);
+ return driver->baseline(cpus, ncpus, models, nmodels, flags);
}
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index cba7149..9148871 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -49,7 +49,8 @@ typedef int
const union cpuData *data,
const char **models,
unsigned int nmodels,
- const char *preferred);
+ const char *preferred,
+ unsigned int flags);
typedef int
(*cpuArchEncode) (const virCPUDefPtr cpu,
@@ -76,7 +77,8 @@ typedef virCPUDefPtr
(*cpuArchBaseline) (virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
- unsigned int nmodels);
+ unsigned int nmodels,
+ unsigned int /* flags */);
typedef int
(*cpuArchUpdate) (virCPUDefPtr guest,
@@ -145,13 +147,15 @@ extern char *
cpuBaselineXML(const char **xmlCPUs,
unsigned int ncpus,
const char **models,
- unsigned int nmodels);
+ unsigned int nmodels,
+ unsigned int /* flags */);
extern virCPUDefPtr
cpuBaseline (virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
- unsigned int nmodels);
+ unsigned int nmodels,
+ unsigned int /* flags */);
extern int
cpuUpdate (virCPUDefPtr guest,
diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index cfe1a23..af1309c 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -48,7 +48,8 @@ ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
const union cpuData *data ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED,
- const char *preferred ATTRIBUTE_UNUSED)
+ const char *preferred ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
return 0;
}
diff --git a/src/cpu/cpu_generic.c b/src/cpu/cpu_generic.c
index 7e3eda2..cad1782 100644
--- a/src/cpu/cpu_generic.c
+++ b/src/cpu/cpu_generic.c
@@ -115,7 +115,8 @@ static virCPUDefPtr
genericBaseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
- unsigned int nmodels)
+ unsigned int nmodels,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
virCPUDefPtr cpu = NULL;
virCPUFeatureDefPtr features = NULL;
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index d17f9ca..cd468dd 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -310,7 +310,8 @@ ppcDecode(virCPUDefPtr cpu,
const union cpuData *data,
const char **models,
unsigned int nmodels,
- const char *preferred ATTRIBUTE_UNUSED)
+ const char *preferred ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
int ret = -1;
struct ppc_map *map;
@@ -385,7 +386,8 @@ static virCPUDefPtr
ppcBaseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
- unsigned int nmodels)
+ unsigned int nmodels,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
struct ppc_map *map = NULL;
const struct ppc_model *model;
diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c
index 998197c..32ab2d9 100644
--- a/src/cpu/cpu_s390.c
+++ b/src/cpu/cpu_s390.c
@@ -50,7 +50,8 @@ s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
const union cpuData *data ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED,
- const char *preferred ATTRIBUTE_UNUSED)
+ const char *preferred ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
return 0;
}
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 5d479c2..6cb8263 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1296,13 +1296,43 @@ x86GuestData(virCPUDefPtr host,
return x86Compute(host, guest, data, message);
}
+static void
+x86AddFeatures(virCPUDefPtr cpu,
+ struct x86_map *map)
+{
+ const struct x86_model *candidate;
+ const struct x86_feature *feature = map->features;
+
+ candidate = map->models;
+ while (candidate != NULL) {
+ if (STREQ(cpu->model, candidate->name))
+ break;
+ candidate = candidate->next;
+ }
+ if (!candidate) {
+ VIR_WARN("Odd, %s not a known CPU model\n", cpu->model);
+ return;
+ }
+ while (feature != NULL) {
+ if (x86DataIsSubset(candidate->data, feature->data)) {
+ if (virCPUDefAddFeature(cpu, feature->name, VIR_CPU_FEATURE_REQUIRE) < 0) {
+ VIR_WARN("CPU model %s, no room for feature %s", cpu->model, feature->name);
+ return;
+ }
+ }
+ feature = feature->next;
+ }
+ return;
+}
+
static int
x86Decode(virCPUDefPtr cpu,
const union cpuData *data,
const char **models,
unsigned int nmodels,
- const char *preferred)
+ const char *preferred,
+ unsigned int flags)
{
int ret = -1;
struct x86_map *map;
@@ -1383,6 +1413,8 @@ x86Decode(virCPUDefPtr cpu,
goto out;
}
+ if (flags & VIR_CONNECT_BASELINE_SHOW_MODEL)
+ x86AddFeatures(cpuModel, map);
cpu->model = cpuModel->model;
cpu->vendor = cpuModel->vendor;
cpu->nfeatures = cpuModel->nfeatures;
@@ -1610,7 +1642,8 @@ static virCPUDefPtr
x86Baseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
- unsigned int nmodels)
+ unsigned int nmodels,
+ unsigned int flags)
{
struct x86_map *map = NULL;
struct x86_model *base_model = NULL;
@@ -1691,7 +1724,7 @@ x86Baseline(virCPUDefPtr *cpus,
if (vendor && x86DataAddCpuid(base_model->data, &vendor->cpuid) < 0)
goto no_memory;
- if (x86Decode(cpu, base_model->data, models, nmodels, NULL) < 0)
+ if (x86Decode(cpu, base_model->data, models, nmodels, NULL, flags) < 0)
goto error;
if (!outputVendor)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4a76f14..b87c73a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10260,9 +10260,9 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
{
char *cpu;
- virCheckFlags(0, NULL);
+ virCheckFlags(VIR_CONNECT_BASELINE_SHOW_MODEL, NULL);
- cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0);
+ cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
return cpu;
}
diff --git a/tests/cputest.c b/tests/cputest.c
index 0105440..227faa0 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -75,6 +75,7 @@ struct data {
const char *modelsName;
unsigned int nmodels;
const char *preferred;
+ int flags;
int result;
};
@@ -331,7 +332,7 @@ cpuTestBaseline(const void *arg)
if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
goto cleanup;
- baseline = cpuBaseline(cpus, ncpus, NULL, 0);
+ baseline = cpuBaseline(cpus, ncpus, NULL, 0, data->flags);
if (data->result < 0) {
virResetLastError();
if (!baseline)
@@ -512,12 +513,12 @@ mymain(void)
}
#define DO_TEST(arch, api, name, host, cpu, \
- models, nmodels, preferred, result) \
+ models, nmodels, preferred, flags, result) \
do { \
static struct data data = { \
arch, api, host, cpu, models, \
models == NULL ? NULL : #models, \
- nmodels, preferred, result \
+ nmodels, preferred, flags, result \
}; \
if (cpuTestRun(name, &data) < 0) \
ret = -1; \
@@ -526,31 +527,31 @@ mymain(void)
#define DO_TEST_COMPARE(arch, host, cpu, result) \
DO_TEST(arch, API_COMPARE, \
host "/" cpu " (" #result ")", \
- host, cpu, NULL, 0, NULL, result)
+ host, cpu, NULL, 0, NULL, 0, result)
#define DO_TEST_UPDATE(arch, host, cpu, result) \
do { \
DO_TEST(arch, API_UPDATE, \
cpu " on " host, \
- host, cpu, NULL, 0, NULL, 0); \
+ host, cpu, NULL, 0, NULL, 0, 0); \
DO_TEST_COMPARE(arch, host, host "+" cpu, result); \
} while (0)
-#define DO_TEST_BASELINE(arch, name, result) \
+#define DO_TEST_BASELINE(arch, name, flags, result) \
DO_TEST(arch, API_BASELINE, name, NULL, "baseline-" name, \
- NULL, 0, NULL, result)
+ NULL, 0, NULL, flags, result)
#define DO_TEST_HASFEATURE(arch, host, feature, result) \
DO_TEST(arch, API_HAS_FEATURE, \
host "/" feature " (" #result ")", \
- host, feature, NULL, 0, NULL, result)
+ host, feature, NULL, 0, NULL, 0, result)
#define DO_TEST_GUESTDATA(arch, host, cpu, models, preferred, result) \
DO_TEST(arch, API_GUEST_DATA, \
host "/" cpu " (" #models ", pref=" #preferred ")", \
host, cpu, models, \
models == NULL ? 0 : sizeof(models) / sizeof(char *), \
- preferred, result)
+ preferred, 0, result)
/* host to host comparison */
DO_TEST_COMPARE("x86", "host", "host", VIR_CPU_COMPARE_IDENTICAL);
@@ -594,11 +595,12 @@ mymain(void)
DO_TEST_UPDATE("x86", "host", "host-passthrough", VIR_CPU_COMPARE_IDENTICAL);
/* computing baseline CPUs */
- DO_TEST_BASELINE("x86", "incompatible-vendors", -1);
- DO_TEST_BASELINE("x86", "no-vendor", 0);
- DO_TEST_BASELINE("x86", "some-vendors", 0);
- DO_TEST_BASELINE("x86", "1", 0);
- DO_TEST_BASELINE("x86", "2", 0);
+ DO_TEST_BASELINE("x86", "incompatible-vendors", 0, -1);
+ DO_TEST_BASELINE("x86", "no-vendor", 0, 0);
+ DO_TEST_BASELINE("x86", "some-vendors", 0, 0);
+ DO_TEST_BASELINE("x86", "1", 0, 0);
+ DO_TEST_BASELINE("x86", "2", 0, 0);
+ DO_TEST_BASELINE("x86", "3", VIR_CONNECT_BASELINE_SHOW_MODEL, 0);
/* CPU features */
DO_TEST_HASFEATURE("x86", "host", "vmx", YES);
diff --git a/tests/cputestdata/x86-baseline-3-result.xml b/tests/cputestdata/x86-baseline-3-result.xml
new file mode 100644
index 0000000..d196112
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-3-result.xml
@@ -0,0 +1,35 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='allow'>Westmere</model>
+ <feature policy='require' name='lahf_lm'/>
+ <feature policy='require' name='lm'/>
+ <feature policy='require' name='nx'/>
+ <feature policy='require' name='syscall'/>
+ <feature policy='require' name='aes'/>
+ <feature policy='require' name='popcnt'/>
+ <feature policy='require' name='sse4.2'/>
+ <feature policy='require' name='sse4.1'/>
+ <feature policy='require' name='cx16'/>
+ <feature policy='require' name='ssse3'/>
+ <feature policy='require' name='pni'/>
+ <feature policy='require' name='sse2'/>
+ <feature policy='require' name='sse'/>
+ <feature policy='require' name='fxsr'/>
+ <feature policy='require' name='mmx'/>
+ <feature policy='require' name='clflush'/>
+ <feature policy='require' name='pse36'/>
+ <feature policy='require' name='pat'/>
+ <feature policy='require' name='cmov'/>
+ <feature policy='require' name='mca'/>
+ <feature policy='require' name='pge'/>
+ <feature policy='require' name='mtrr'/>
+ <feature policy='require' name='sep'/>
+ <feature policy='require' name='apic'/>
+ <feature policy='require' name='cx8'/>
+ <feature policy='require' name='mce'/>
+ <feature policy='require' name='pae'/>
+ <feature policy='require' name='msr'/>
+ <feature policy='require' name='tsc'/>
+ <feature policy='require' name='pse'/>
+ <feature policy='require' name='de'/>
+ <feature policy='require' name='fpu'/>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-3.xml b/tests/cputestdata/x86-baseline-3.xml
new file mode 100644
index 0000000..7654a1d
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-3.xml
@@ -0,0 +1,7 @@
+<cpuTest>
+<cpu>
+ <arch>x86_64</arch>
+ <model>Westmere</model>
+ <topology sockets='1' cores='2' threads='1'/>
+</cpu>
+</cpuTest>
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0402aef..0aa8b60 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5986,6 +5986,10 @@ static const vshCmdOptDef opts_cpu_baseline[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("file containing XML CPU descriptions")
},
+ {.name = "model_features",
+ .type = VSH_OT_BOOL,
+ .help = N_("Show features that are part of the CPU model type")
+ },
{.name = NULL}
};
@@ -5997,6 +6001,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
char *buffer;
char *result = NULL;
const char **list = NULL;
+ unsigned int flags = 0;
int count = 0;
xmlDocPtr xml = NULL;
@@ -6006,6 +6011,9 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER;
int i;
+ if (vshCommandOptBool(cmd, "model_features"))
+ flags |= VIR_CONNECT_BASELINE_SHOW_MODEL;
+
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
@@ -6049,7 +6057,8 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
list[i] = vshStrdup(ctl, (const char *)xmlBufferContent(xml_buf));
}
- result = virConnectBaselineCPU(ctl->conn, list, count, 0);
+ result = virConnectBaselineCPU(ctl->conn, list, count, flags);
+vshPrint(ctl, "result - %p\n", result);
if (result) {
vshPrint(ctl, "%s", result);
--
1.7.10.4
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
n0ano(a)n0ano.com
Ph: 303/443-3786
11 years, 2 months
[libvirt] [PATCH] maint: slightly reduce configure size
by Eric Blake
Rather than inlining gl_WARN_ADD loads of time, we can shave about
17k size off of the configure script by delaying it to a cleanup
shell loop.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Track a
list of things to check, rather than inlining multiple checks.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
m4/virt-compile-warnings.m4 | 72 ++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 6bf797f..938c8bb 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -133,47 +133,31 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
# Remove the ones we don't want, blacklisted earlier
gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
- # Check for $CC support of each warning
- for w in $wantwarn; do
- gl_WARN_ADD([$w])
- done
-
# GNULIB uses '-W' (aka -Wextra) which includes a bunch of stuff.
# Unfortunately, this means you can't simply use '-Wsign-compare'
# with gl_MANYWARN_COMPLEMENT
# So we have -W enabled, and then have to explicitly turn off...
- gl_WARN_ADD([-Wno-sign-compare])
+ wantwarn="$wantwarn -Wno-sign-compare"
# GNULIB expects this to be part of -Wc++-compat, but we turn
# that one off, so we need to manually enable this again
- gl_WARN_ADD([-Wjump-misses-init])
+ wantwarn="$wantwarn -Wjump-misses-init"
# GNULIB turns on -Wformat=2 which implies -Wformat-nonliteral,
# so we need to manually re-exclude it. Also, older gcc 4.2
# added an implied ATTRIBUTE_NONNULL on any parameter marked
# ATTRIBUTE_FMT_PRINT, which causes -Wformat failure on our
# intentional use of virReportError(code, NULL).
- gl_WARN_ADD([-Wno-format-nonliteral])
+ wantwarn="$wantwarn -Wno-format-nonliteral"
if test $lv_cv_gcc_wformat_null_works = no; then
- gl_WARN_ADD([-Wno-format])
+ wantwarn="$wantwarn -Wno-format"
fi
# This should be < 256 really. Currently we're down to 4096,
# but using 1024 bytes sized buffers (mostly for virStrerror)
# stops us from going down further
- gl_WARN_ADD([-Wframe-larger-than=4096])
- dnl gl_WARN_ADD([-Wframe-larger-than=256])
-
- # Silence certain warnings in gnulib, and use improved glibc headers
- AC_DEFINE([lint], [1],
- [Define to 1 if the compiler is checking for lint.])
- AH_VERBATIM([FORTIFY_SOURCE],
- [/* Enable compile-time and run-time bounds-checking, and some warnings,
- without upsetting newer glibc. */
- #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
- # define _FORTIFY_SOURCE 2
- #endif
- ])
+ wantwarn="$wantwarn -Wframe-larger-than=4096"
+ dnl wantwarn="$wantwarn -Wframe-larger-than=256"
# Extra special flags
dnl -fstack-protector stuff passes gl_WARN_ADD with gcc
@@ -182,43 +166,59 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
*-*-linux*)
dnl Fedora only uses -fstack-protector, but doesn't seem to
dnl be great overhead in adding -fstack-protector-all instead
- dnl gl_WARN_ADD([-fstack-protector])
- gl_WARN_ADD([-fstack-protector-all])
- gl_WARN_ADD([--param=ssp-buffer-size=4])
+ dnl wantwarn="$wantwarn -fstack-protector"
+ wantwarn="$wantwarn -fstack-protector-all"
+ wantwarn="$wantwarn --param=ssp-buffer-size=4"
dnl Even though it supports it, clang complains about
dnl use of --param=ssp-buffer-size=4 unless used with
dnl the -c arg. It doesn't like it when used with args
dnl that just link together .o files. Unfortunately
dnl we can't avoid that with automake, so we must turn
dnl off the following clang specific warning
- gl_WARN_ADD([-Wno-unused-command-line-argument])
+ wantwarn="$wantwarn -Wno-unused-command-line-argument"
;;
*-*-freebsd*)
dnl FreeBSD ships old gcc 4.2.1 which doesn't handle
dnl -fstack-protector-all well
- gl_WARN_ADD([-fstack-protector])
+ wantwarn="$wantwarn -fstack-protector"
- gl_WARN_ADD([-Wno-unused-command-line-argument])
+ wantwarn="$wantwarn -Wno-unused-command-line-argument"
;;
esac
- gl_WARN_ADD([-fexceptions])
- gl_WARN_ADD([-fasynchronous-unwind-tables])
- gl_WARN_ADD([-fdiagnostics-show-option])
- gl_WARN_ADD([-funit-at-a-time])
+ wantwarn="$wantwarn -fexceptions"
+ wantwarn="$wantwarn -fasynchronous-unwind-tables"
+ wantwarn="$wantwarn -fdiagnostics-show-option"
+ wantwarn="$wantwarn -funit-at-a-time"
# Need -fipa-pure-const in order to make -Wsuggest-attribute=pure
# fire even without -O.
- gl_WARN_ADD([-fipa-pure-const])
+ wantwarn="$wantwarn -fipa-pure-const"
# We should eventually enable this, but right now there are at
# least 75 functions triggering warnings.
- gl_WARN_ADD([-Wno-suggest-attribute=pure])
- gl_WARN_ADD([-Wno-suggest-attribute=const])
+ wantwarn="$wantwarn -Wno-suggest-attribute=pure"
+ wantwarn="$wantwarn -Wno-suggest-attribute=const"
if test "$set_werror" = "yes"
then
- gl_WARN_ADD([-Werror])
+ wantwarn="$wantwarn -Werror"
fi
+ # Check for $CC support of each warning
+ for w in $wantwarn; do
+ gl_WARN_ADD([$w])
+ done
+
+ # Silence certain warnings in gnulib, and use improved glibc headers
+ AC_DEFINE([lint], [1],
+ [Define to 1 if the compiler is checking for lint.])
+ AH_VERBATIM([FORTIFY_SOURCE],
+ [/* Enable compile-time and run-time bounds-checking, and some warnings,
+ without upsetting newer glibc. */
+ #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
+ # define _FORTIFY_SOURCE 2
+ #endif
+ ])
+
dnl Needed to keep compile quiet on python 2.4
save_WARN_CFLAGS=$WARN_CFLAGS
WARN_CFLAGS=
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] libxl: refactor capabilities code
by Jim Fehlig
Cleanup the libxl capabilities code to be a bit more extensible,
splitting out the creation of host and guest capabilities. This
should make it easier to implement additional capabilities in the
future, such as NUMA topology reporting.
---
Although I can't see how changes here would affect other drivers, I nonetheless
ensured libvirtd loaded when not booted to Xen :).
src/libxl/libxl_conf.c | 256 +++++++++++++++++++++++--------------------------
1 file changed, 121 insertions(+), 135 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 827dfdd..5ea4163 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -64,126 +64,62 @@ static const char *xen_cap_re = "(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x
static regex_t xen_cap_rec;
-static virCapsPtr
-libxlBuildCapabilities(virArch hostarch,
- int host_pae,
- struct guest_arch *guest_archs,
- int nr_guest_archs)
+static int
+libxlCapsInitHost(libxl_ctx *ctx, virCapsPtr caps)
{
- virCapsPtr caps;
- size_t i;
-
- if ((caps = virCapabilitiesNew(hostarch, 1, 1)) == NULL)
- goto no_memory;
-
- if (host_pae &&
- virCapabilitiesAddHostFeature(caps, "pae") < 0)
- goto no_memory;
-
- for (i = 0; i < nr_guest_archs; ++i) {
- virCapsGuestPtr guest;
- char const *const xen_machines[] = {guest_archs[i].hvm ? "xenfv" : "xenpv"};
- virCapsGuestMachinePtr *machines;
-
- if ((machines = virCapabilitiesAllocMachines(xen_machines, 1)) == NULL)
- goto no_memory;
-
- if ((guest = virCapabilitiesAddGuest(caps,
- guest_archs[i].hvm ? "hvm" : "xen",
- guest_archs[i].arch,
- ((hostarch == VIR_ARCH_X86_64) ?
- "/usr/lib64/xen/bin/qemu-dm" :
- "/usr/lib/xen/bin/qemu-dm"),
- (guest_archs[i].hvm ?
- "/usr/lib/xen/boot/hvmloader" :
- NULL),
- 1,
- machines)) == NULL) {
- virCapabilitiesFreeMachines(machines, 1);
- goto no_memory;
- }
- machines = NULL;
-
- if (virCapabilitiesAddGuestDomain(guest,
- "xen",
- NULL,
- NULL,
- 0,
- NULL) == NULL)
- goto no_memory;
-
- if (guest_archs[i].pae &&
- virCapabilitiesAddGuestFeature(guest,
- "pae",
- 1,
- 0) == NULL)
- goto no_memory;
-
- if (guest_archs[i].nonpae &&
- virCapabilitiesAddGuestFeature(guest,
- "nonpae",
- 1,
- 0) == NULL)
- goto no_memory;
-
- if (guest_archs[i].ia64_be &&
- virCapabilitiesAddGuestFeature(guest,
- "ia64_be",
- 1,
- 0) == NULL)
- goto no_memory;
-
- if (guest_archs[i].hvm) {
- if (virCapabilitiesAddGuestFeature(guest,
- "acpi",
- 1,
- 1) == NULL)
- goto no_memory;
+ int err;
+ libxl_physinfo phy_info;
+ int host_pae;
- if (virCapabilitiesAddGuestFeature(guest, "apic",
- 1,
- 0) == NULL)
- goto no_memory;
+ err = regcomp(&xen_cap_rec, xen_cap_re, REG_EXTENDED);
+ if (err != 0) {
+ char error[100];
+ regerror(err, &xen_cap_rec, error, sizeof(error));
+ regfree(&xen_cap_rec);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to compile regex %s"), error);
+ return -1;
+ }
- if (virCapabilitiesAddGuestFeature(guest,
- "hap",
- 0,
- 1) == NULL)
- goto no_memory;
- }
+ if (libxl_get_physinfo(ctx, &phy_info) != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to get node physical info from libxenlight"));
+ return -1;
}
- return caps;
+ /* hw_caps is an array of 32-bit words whose meaning is listed in
+ * xen-unstable.hg/xen/include/asm-x86/cpufeature.h. Each feature
+ * is defined in the form X*32+Y, corresponding to the Y'th bit in
+ * the X'th 32-bit word of hw_cap.
+ */
+ host_pae = phy_info.hw_cap[0] & LIBXL_X86_FEATURE_PAE_MASK;
+ if (host_pae &&
+ virCapabilitiesAddHostFeature(caps, "pae") < 0)
+ return -1;
- no_memory:
- virObjectUnref(caps);
- return NULL;
+ return 0;
}
-static virCapsPtr
-libxlMakeCapabilitiesInternal(virArch hostarch,
- libxl_physinfo *phy_info,
- char *capabilities)
+static int
+libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
{
+ const libxl_version_info *ver_info;
char *str, *token;
regmatch_t subs[4];
char *saveptr = NULL;
size_t i;
+ virArch hostarch = caps->host.arch;
- int host_pae = 0;
struct guest_arch guest_archs[32];
int nr_guest_archs = 0;
- virCapsPtr caps = NULL;
memset(guest_archs, 0, sizeof(guest_archs));
- /* hw_caps is an array of 32-bit words whose meaning is listed in
- * xen-unstable.hg/xen/include/asm-x86/cpufeature.h. Each feature
- * is defined in the form X*32+Y, corresponding to the Y'th bit in
- * the X'th 32-bit word of hw_cap.
- */
- host_pae = phy_info->hw_cap[0] & LIBXL_X86_FEATURE_PAE_MASK;
-
+ if ((ver_info = libxl_get_version_info(ctx)) == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to get version info from libxenlight"));
+ return -1;
+ }
/* Format of capabilities string is documented in the code in
* xen-unstable.hg/xen/arch/.../setup.c.
*
@@ -209,7 +145,7 @@ libxlMakeCapabilitiesInternal(virArch hostarch,
/* Split capabilities string into tokens. strtok_r is OK here because
* we "own" the buffer. Parse out the features from each token.
*/
- for (str = capabilities, nr_guest_archs = 0;
+ for (str = ver_info->capabilities, nr_guest_archs = 0;
nr_guest_archs < sizeof(guest_archs) / sizeof(guest_archs[0])
&& (token = strtok_r(str, " ", &saveptr)) != NULL;
str = NULL) {
@@ -274,17 +210,80 @@ libxlMakeCapabilitiesInternal(virArch hostarch,
}
}
- if ((caps = libxlBuildCapabilities(hostarch,
- host_pae,
- guest_archs,
- nr_guest_archs)) == NULL)
- goto error;
+ for (i = 0; i < nr_guest_archs; ++i) {
+ virCapsGuestPtr guest;
+ char const *const xen_machines[] = {guest_archs[i].hvm ? "xenfv" : "xenpv"};
+ virCapsGuestMachinePtr *machines;
- return caps;
+ if ((machines = virCapabilitiesAllocMachines(xen_machines, 1)) == NULL)
+ return -1;
- error:
- virObjectUnref(caps);
- return NULL;
+ if ((guest = virCapabilitiesAddGuest(caps,
+ guest_archs[i].hvm ? "hvm" : "xen",
+ guest_archs[i].arch,
+ ((hostarch == VIR_ARCH_X86_64) ?
+ "/usr/lib64/xen/bin/qemu-dm" :
+ "/usr/lib/xen/bin/qemu-dm"),
+ (guest_archs[i].hvm ?
+ "/usr/lib/xen/boot/hvmloader" :
+ NULL),
+ 1,
+ machines)) == NULL) {
+ virCapabilitiesFreeMachines(machines, 1);
+ return -1;
+ }
+ machines = NULL;
+
+ if (virCapabilitiesAddGuestDomain(guest,
+ "xen",
+ NULL,
+ NULL,
+ 0,
+ NULL) == NULL)
+ return -1;
+
+ if (guest_archs[i].pae &&
+ virCapabilitiesAddGuestFeature(guest,
+ "pae",
+ 1,
+ 0) == NULL)
+ return -1;
+
+ if (guest_archs[i].nonpae &&
+ virCapabilitiesAddGuestFeature(guest,
+ "nonpae",
+ 1,
+ 0) == NULL)
+ return -1;
+
+ if (guest_archs[i].ia64_be &&
+ virCapabilitiesAddGuestFeature(guest,
+ "ia64_be",
+ 1,
+ 0) == NULL)
+ return -1;
+
+ if (guest_archs[i].hvm) {
+ if (virCapabilitiesAddGuestFeature(guest,
+ "acpi",
+ 1,
+ 1) == NULL)
+ return -1;
+
+ if (virCapabilitiesAddGuestFeature(guest, "apic",
+ 1,
+ 0) == NULL)
+ return -1;
+
+ if (virCapabilitiesAddGuestFeature(guest,
+ "hap",
+ 0,
+ 1) == NULL)
+ return -1;
+ }
+ }
+
+ return 0;
}
static int
@@ -874,35 +873,22 @@ error:
virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx)
{
- int err;
- libxl_physinfo phy_info;
- const libxl_version_info *ver_info;
+ virCapsPtr caps;
- err = regcomp(&xen_cap_rec, xen_cap_re, REG_EXTENDED);
- if (err != 0) {
- char error[100];
- regerror(err, &xen_cap_rec, error, sizeof(error));
- regfree(&xen_cap_rec);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to compile regex %s"), error);
+ if ((caps = virCapabilitiesNew(virArchFromHost(), 1, 1)) == NULL)
return NULL;
- }
- if (libxl_get_physinfo(ctx, &phy_info) != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to get node physical info from libxenlight"));
- return NULL;
- }
+ if (libxlCapsInitHost(ctx, caps) < 0)
+ goto error;
- if ((ver_info = libxl_get_version_info(ctx)) == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to get version info from libxenlight"));
- return NULL;
- }
+ if (libxlCapsInitGuests(ctx, caps) < 0)
+ goto error;
+
+ return caps;
- return libxlMakeCapabilitiesInternal(virArchFromHost(),
- &phy_info,
- ver_info->capabilities);
+error:
+ virObjectUnref(caps);
+ return NULL;
}
int
--
1.8.1.4
11 years, 2 months