[libvirt] [PATCH] python: return dictionay without value in case of no blockjob
by Guannan Ren
Currently, when there is no blockjob, dom.blockJobInfo('vda')
still reports error because it didn't distinguish return value 0 from -1.
libvirt.libvirtError: virDomainGetBlockJobInfo() failed
virDomainGetBlockJobInfo() API return value:
-1 in case of failure, 0 when nothing found, 1 found.
And use PyDict_SetItemString instead of PyDict_SetItem when key is
string type. PyDict_SetItemString increments key/value reference
count, so calling Py_DECREF() for value. For key, we don't need to
do this, because PyDict_SetItemString will handle it internally.
---
python/libvirt-override.c | 54 ++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 15 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index fd9ebb8..c1e8661 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -4354,33 +4354,57 @@ libvirt_virDomainGetBlockJobInfo(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
virDomainBlockJobInfo info;
int c_ret;
- PyObject *ret;
+ PyObject *type = NULL, *bandwidth = NULL, *cur = NULL, *end = NULL;
+ PyObject *dict;
if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockJobInfo",
&pyobj_domain, &path, &flags))
return NULL;
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-LIBVIRT_BEGIN_ALLOW_THREADS;
+ if ((dict = PyDict_New()) == NULL)
+ return NULL;
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
c_ret = virDomainGetBlockJobInfo(domain, path, &info, flags);
-LIBVIRT_END_ALLOW_THREADS;
+ LIBVIRT_END_ALLOW_THREADS;
- if (c_ret != 1)
+ if (c_ret == 0) {
+ return dict;
+ } else if (c_ret < 0) {
+ Py_DECREF(dict);
return VIR_PY_NONE;
+ }
- if ((ret = PyDict_New()) == NULL)
- return VIR_PY_NONE;
+ if ((type = libvirt_intWrap(info.type)) == NULL ||
+ PyDict_SetItemString(dict, "type", type) < 0)
+ goto error;
+ Py_DECREF(type);
- PyDict_SetItem(ret, libvirt_constcharPtrWrap("type"),
- libvirt_intWrap(info.type));
- PyDict_SetItem(ret, libvirt_constcharPtrWrap("bandwidth"),
- libvirt_ulongWrap(info.bandwidth));
- PyDict_SetItem(ret, libvirt_constcharPtrWrap("cur"),
- libvirt_ulonglongWrap(info.cur));
- PyDict_SetItem(ret, libvirt_constcharPtrWrap("end"),
- libvirt_ulonglongWrap(info.end));
+ if ((bandwidth = libvirt_ulongWrap(info.bandwidth)) == NULL ||
+ PyDict_SetItemString(dict, "bandwidth", bandwidth) < 0)
+ goto error;
+ Py_DECREF(bandwidth);
- return ret;
+ if ((cur = libvirt_ulonglongWrap(info.cur)) == NULL ||
+ PyDict_SetItemString(dict, "cur", cur) < 0)
+ goto error;
+ Py_DECREF(cur);
+
+ if ((end = libvirt_ulonglongWrap(info.end)) == NULL ||
+ PyDict_SetItemString(dict, "end", end) < 0)
+ goto error;
+ Py_DECREF(end);
+
+ return dict;
+
+error:
+ Py_DECREF(dict);
+ Py_XDECREF(type);
+ Py_XDECREF(bandwidth);
+ Py_XDECREF(cur);
+ Py_XDECREF(end);
+ return NULL;
}
static PyObject *
--
1.8.1.4
11 years, 3 months
[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, 3 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, 3 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, 3 months
[libvirt] [PATCH v3] xml: introduce startupPolicy for chardev device
by Seiji Aguchi
[Problem]
Currently, guest OS's messages can be logged to a local disk of host OS
by creating chadevs with options below.
-chardev file,id=charserial0,path=<log file's path> -device isa-serial,chardev=chardevserial0,id=serial0
When a hardware failure happens in the disk, qemu-kvm can't create the
chardevs. In this case, guest OS doesn't boot up.
Actually, there are users who don't desire that guest OS goes down due
to a hardware failure of a log disk only. Therefore, qemu should offer
some way to boot guest OS up even if the log disk is broken.
[Solution]
This patch supports startupPolicy for chardev.
The starupPolicy is introduced just in cases where chardev is "file"
because this patch aims for making guest OS boot up when a hardware
failure happens.
In other cases (pty, dev, pipe and unix) it is not introduced
because they don't access to hardware.
The policy works as follows.
- If the value is "optional", guestOS boots up by dropping the chardev.
- If other values are specified, guestOS fails to boot up. (the default)
Description about original startupPolicy attribute:
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=e5a84d74a278
Signed-off-by: Seiji Aguchi <seiji.aguchi(a)hds.com>
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Change from v2
- To pass "make check", add followings.
- Add serial source optional testing.
- check if startupPolicy is NULL in virDomainChrSourceDefParseXML().
- Add xml format of startupPolicy in virDomainChrSourceDefFormat().
Patch v2 and comment from Eric Blake
- https://www.redhat.com/archives/libvir-list/2013-May/msg01814.html
- https://www.redhat.com/archives/libvir-list/2013-May/msg01943.html
---
docs/formatdomain.html.in | 16 ++++++++-
docs/schemas/domaincommon.rng | 3 ++
src/conf/domain_conf.c | 22 +++++++++++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_process.c | 25 +++++++++++++-
.../qemuxml2argv-serial-source-optional.args | 9 +++++
.../qemuxml2argv-serial-source-optional.xml | 35 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 2 +
tests/qemuxml2xmltest.c | 1 +
tests/virt-aa-helper-test | 3 ++
10 files changed, 113 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 7601aaa..5c9d4fb 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4281,13 +4281,27 @@ qemu-kvm -net nic,model=? /dev/null
<p>
A file is opened and all data sent to the character
device is written to the file.
+ <span class="since">Since 1.0.6</span>, it is possible to define
+ policy on what happens if the file is not accessible when
+ booting or migrating. This is done by
+ a <code>startupPolicy</code> attribute:
</p>
+ <ul>
+ <li>If the value is "mandatory" (the default), the guest fails
+ to boot or migrate if the file is not found.</li>
+ <li>If the value is "optional", a missing file is at boot or
+ migration is substituted with /dev/null, so the guest still sees
+ the device but the host no longer tracks guest data on the device.</li>
+ <li>If the value is "requisite", the file is required for
+ booting, but optional on migration.</li>
+ </ul>
+
<pre>
...
<devices>
<serial type="file">
- <source path="/var/log/vm/vm-serial.log"/>
+ <source path="/var/log/vm/vm-serial.log" startupPolicy="optional"/>
<target port="1"/>
</serial>
</devices>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 745b959..10b3365 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2817,6 +2817,9 @@
</optional>
<optional>
<attribute name="path"/>
+ <optional>
+ <ref name="startupPolicy"/>
+ </optional>
</optional>
<optional>
<attribute name="host"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 10cb7f6..279ff9e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6819,6 +6819,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
char *path = NULL;
char *mode = NULL;
char *protocol = NULL;
+ char *startupPolicy = NULL;
int remaining = 0;
while (cur != NULL) {
@@ -6839,6 +6840,9 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
!(flags & VIR_DOMAIN_XML_INACTIVE)))
path = virXMLPropString(cur, "path");
+ if (startupPolicy == NULL &&
+ def->type == VIR_DOMAIN_CHR_TYPE_FILE)
+ startupPolicy = virXMLPropString(cur, "startupPolicy");
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
@@ -6911,6 +6915,13 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
def->data.file.path = path;
path = NULL;
+
+ if (startupPolicy) {
+ def->data.file.startupPolicy =
+ virDomainStartupPolicyTypeFromString(startupPolicy);
+ startupPolicy = NULL;
+ }
+
break;
case VIR_DOMAIN_CHR_TYPE_STDIO:
@@ -15014,8 +15025,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
if (def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
(def->data.file.path &&
!(flags & VIR_DOMAIN_XML_INACTIVE))) {
- virBufferEscapeString(buf, " <source path='%s'/>\n",
- def->data.file.path);
+ virBufferEscapeString(buf, " <source path='%s'",
+ def->data.file.path);
+
+ if (def->data.file.path && def->data.file.startupPolicy) {
+ const char *policy =
+virDomainStartupPolicyTypeToString(def->data.file.startupPolicy);
+ virBufferAsprintf(buf, " startupPolicy='%s'", policy);
+ }
+ virBufferAddLit(buf, "/>\n");
}
break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f265966..0899556 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1102,6 +1102,7 @@ struct _virDomainChrSourceDef {
/* no <source> for null, vc, stdio */
struct {
char *path;
+ int startupPolicy; /* enum virDomainStartupPolicy */
} file; /* pty, file, pipe, or device */
struct {
char *host;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a46d944..35d63d5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2511,7 +2511,30 @@ qemuProcessPrepareChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED,
virReportSystemError(errno,
_("Unable to pre-create chardev file '%s'"),
dev->source.data.file.path);
- return -1;
+ if (dev->source.data.file.startupPolicy !=
+ VIR_DOMAIN_STARTUP_POLICY_OPTIONAL) {
+ return -1;
+ }
+ VIR_FREE(dev->source.data.file.path);
+ /*
+ * Change a destination to /dev/null to boot guest OS up
+ * even if a log disk is broken.
+ */
+ VIR_WARN("Switch the destination to /dev/null");
+ dev->source.data.file.path = strdup("/dev/null");
+
+ if (!(dev->source.data.file.path)) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if ((fd = open(dev->source.data.file.path,
+ O_CREAT | O_APPEND, S_IRUSR|S_IWUSR)) < 0) {
+ virReportSystemError(errno,
+ _("Unable to pre-create chardev file '%s'"),
+ dev->source.data.file.path);
+ return -1;
+ }
}
VIR_FORCE_CLOSE(fd);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.args
new file mode 100644
index 0000000..9ffe8de
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \
+-S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi -boot c -usb -hdc /tmp/idedisk.img \
+-chardev file,id=charserial0,path=/tmp/serial.log \
+-device isa-serial,chardev=charserial0,id=serial0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.xml
new file mode 100644
index 0000000..1aeb82a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-source-optional.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='file' device='disk'>
+ <source file='/tmp/idedisk.img'/>
+ <target dev='hdc' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <serial type='file'>
+ <source path='/tmp/serial.log' startupPolicy='optional'/>
+ <target port='0'/>
+ </serial>
+ <console type='file'>
+ <source path='/tmp/serial.log' startupPolicy='optional'/>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0f96eef..588c922 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -728,6 +728,8 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("console-compat-chardev",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("serial-source-optional",
+ QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("channel-guestfwd",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 77cac3f..9faca1f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -234,6 +234,7 @@ mymain(void)
DO_TEST("console-virtio-many");
DO_TEST("channel-guestfwd");
DO_TEST("channel-virtio");
+ DO_TEST("serial-source-optional");
DO_TEST("hostdev-usb-address");
DO_TEST("hostdev-pci-address");
diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test
index af91c61..7172fd6 100755
--- a/tests/virt-aa-helper-test
+++ b/tests/virt-aa-helper-test
@@ -255,6 +255,9 @@ testme "0" "disk (empty cdrom)" "-r -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='file'><source path='$tmpdir/serial.log'/><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
testme "0" "serial" "-r -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='file'><source path='$tmpdir/serial.log' startupPolicy='optional'/><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
+testme "0" "serial" "-r -u $valid_uuid" "$test_xml"
+
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='pty'><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
testme "0" "serial (pty)" "-r -u $valid_uuid" "$test_xml"
-- 1.7.1
11 years, 3 months
[libvirt] [PATCH 0/5] Introduce API to query IP addresses for given domain
by nehaljwani
This feature has been requested for a very long time. Since qemu guest
agent gives us reliable results, now the wait is over.
The RFC was first proposed by Michal Privoznik:
http://www.mail-archive.com/libvir-list@redhat.com/msg51857.html
A patch was submitted, using structs:
http://www.mail-archive.com/libvir-list@redhat.com/msg57141.html
Another patch was submitted, using XML:
http://www.mail-archive.com/libvir-list@redhat.com/msg57829.html
Neither of the patches were accepted, probably due to lack of extensibility
and usability. Hence, we thought of using virTypedParameters for reporting
list of interfaces along with their MAC address and IP addresses. The RFC
can be found here:
http://www.mail-archive.com/libvir-list@redhat.com/msg79793.html
The idea of extensibility was rejected and rendered out of scope of
libvirt. Hence, we were back to structs.
This API is called virDomainInterfacesAddresses which returns a dynamically
allocated array of virDomainInterface struct. The great disadvantage is
once this gets released, it's written in stone and we cannot change
or add an item into it.
The API supports two methods:
* Return information (list of all associated interfaces with MAC address
and IP addresses) of all of the domain interfaces by default (if
no interface name is provided)
* Return information for the specified interface (if an interface name
is provided)
The API queries qemu guest agent to obtain ip addresses and MAC address
of each interface the given domain is associated with. In the future,
support for more flags will be added to support for DHCP and snooping methods
nehaljwani (5):
domifaddr: Implement the public API
domifaddr: Implement the remote protocol
domifaddr: Implement the API for qemu
domifaddr: Add virsh support
domifaddr: Expose python binding
daemon/remote.c | 123 ++++++++++++++++++++++++++++++++
examples/python/Makefile.am | 2 +-
examples/python/README | 1 +
examples/python/domipaddrs.py | 50 ++++++++++++++
include/libvirt/libvirt.h.in | 32 +++++++++
python/generator.py | 1 +
python/libvirt-override-api.xml | 8 ++-
python/libvirt-override.c | 117 +++++++++++++++++++++++++++++++
src/driver.h | 7 ++
src/libvirt.c | 99 ++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++
src/qemu/qemu_agent.c | 150 ++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 4 ++
src/qemu/qemu_driver.c | 57 +++++++++++++++
src/remote/remote_driver.c | 93 +++++++++++++++++++++++++
src/remote/remote_protocol.x | 32 ++++++++-
src/remote_protocol-structs | 24 +++++++
tools/virsh-domain-monitor.c | 103 +++++++++++++++++++++++++++
tools/virsh.pod | 10 +++
19 files changed, 914 insertions(+), 4 deletions(-)
create mode 100755 examples/python/domipaddrs.py
--
1.7.11.7
11 years, 3 months
[libvirt] [PATCH 0/2] Support settings the 'removable' flag for USB disks
by Fred A. Kemp
From: "Fred A. Kemp" <anonym(a)lavabit.com>
The commit message of patch #2 explains the purpose of this patch set.
A review would be greatly appreciated!
Note that I've only added the new capability for usb-storage.removable
to the qemu help tests of qemu(-kvm) version 1.2.0, since that's what I
had easily available to get the output of `-device usb-storage,?` from.
I hope that's not an issue, otherwise, is there a way to obtain these
outputs without having to hunt down and install all supported versions?
Previous submissions of this patch set to this list:
http://www.redhat.com/archives/libvir-list/2013-March/msg01051.html
http://www.redhat.com/archives/libvir-list/2013-May/msg02039.html
Cheers!
Fred A. Kemp (2):
qemu: Add capability flag for usb-storage
qemu: Support setting the 'removable' flag for USB disks
docs/formatdomain.html.in | 8 +++--
docs/schemas/domaincommon.rng | 8 +++++
src/conf/domain_conf.c | 31 ++++++++++++++++++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 10 +++++++
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_command.c | 23 +++++++++++++--
tests/qemuhelpdata/qemu-1.2.0-device | 11 +++++++
tests/qemuhelpdata/qemu-kvm-1.2.0-device | 11 +++++++
tests/qemuhelptest.c | 20 +++++++++----
.../qemuxml2argv-disk-usb-device-removable.args | 8 +++++
.../qemuxml2argv-disk-usb-device-removable.xml | 27 +++++++++++++++++
tests/qemuxml2argvtest.c | 6 +++-
13 files changed, 151 insertions(+), 15 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.xml
--
1.7.10.4
11 years, 3 months
[libvirt] [PATCHv3] build: avoid -lgcrypt with newer gnutls
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=951637
Newer gnutls uses nettle, rather than gcrypt, which is a lot nicer
regarding initialization. Yet we were unconditionally initializing
gcrypt even when gnutls wouldn't be using it, and having two crypto
libraries linked into libvirt.so is pointless, but mostly harmless
(it doesn't crash, but does interfere with certification efforts).
There are three distinct version ranges to worry about when
determining which crypto lib gnutls uses, per these gnutls mails:
2.12: http://lists.gnu.org/archive/html/gnutls-devel/2011-03/msg00034.html
3.0: http://lists.gnu.org/archive/html/gnutls-devel/2011-07/msg00035.html
If pkg-config can prove version numbers and/or list the crypto
library used for static linking, we have our proof; if not, it
is safer (even if pointless) to continue to use gcrypt ourselves.
* configure.ac (WITH_GNUTLS): Probe whether to add -lgcrypt, and
define a witness WITH_GNUTLS_GCRYPT.
* src/libvirt.c (virTLSMutexInit, virTLSMutexDestroy)
(virTLSMutexLock, virTLSMutexUnlock, virTLSThreadImpl)
(virGlobalInit): Honor the witness.
* libvirt.spec.in (BuildRequires): Make gcrypt usage conditional,
no longer needed in Fedora 19.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
v3: configure logic is enhanced to try harder to get the
right answer for gentoo. I tested with Fedora 19 and RHEL 6,
but need feedback from a gentoo tester before this can go in.
configure.ac | 37 ++++++++++++++++++++++++++++++-------
libvirt.spec.in | 2 ++
src/libvirt.c | 10 ++++++----
3 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1817126..e3d148c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1076,12 +1076,26 @@ if test "x$with_gnutls" != "xno"; then
LIBS="$LIBS $GNUTLS_LIBS"
GNUTLS_FOUND=no
+ GNUTLS_GCRYPT=unknown
if test -x "$PKG_CONFIG" ; then
+ dnl Triple probe: gnutls < 2.12 only used gcrypt, gnutls >= 3.0 uses
+ dnl only nettle, and versions in between had a configure option.
+ dnl Our goal is to avoid gcrypt if we can prove gnutls uses nettle,
+ dnl but it is a safe fallback to use gcrypt if we can't prove anything.
+ if $PKG_CONFIG --exists 'gnutls >= 3.0'; then
+ GNUTLS_GCRYPT=no
+ elif $PKG_CONFIG --exists 'gnutls >= 2.12'; then
+ GNUTLS_GCRYPT=probe
+ else
+ GNUTLS_GCRYPT=yes
+ fi
PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_REQUIRED,
[GNUTLS_FOUND=yes], [GNUTLS_FOUND=no])
fi
if test "$GNUTLS_FOUND" = "no"; then
+ dnl pkg-config couldn't help us, assume gcrypt is necessary
fail=0
+ GNUTLS_GCRYPT=yes
AC_CHECK_HEADER([gnutls/gnutls.h], [], [fail=1])
AC_CHECK_LIB([gnutls], [gnutls_handshake],[], [fail=1], [-lgcrypt])
@@ -1098,13 +1112,22 @@ if test "x$with_gnutls" != "xno"; then
AC_MSG_ERROR([You must install the GnuTLS library in order to compile and run libvirt])
fi
else
- dnl Not all versions of gnutls include -lgcrypt, and so we add
- dnl it explicitly for the calls to gcry_control/check_version
- GNUTLS_LIBS="$GNUTLS_LIBS -lgcrypt"
-
- dnl We're not using gcrypt deprecated features so define
- dnl GCRYPT_NO_DEPRECATED to avoid deprecated warnings
- GNUTLS_CFLAGS="$GNUTLS_CFLAGS -DGCRYPT_NO_DEPRECATED"
+ dnl See comments above about when to use gcrypt.
+ if test "$GNUTLS_GCRYPT" = probe; then
+ case `$PKG_CONFIG --libs --static gnutls` in
+ *gcrypt*) GNUTLS_GCRYPT=yes ;;
+ *nettle*) GNUTLS_GCRYPT=no ;;
+ *) GNUTLS_GCRYPT=unknown ;;
+ esac
+ fi
+ if test "$GNUTLS_GCRYPT" = yes || test "$GNUTLS_GCRYPT" = unknown; then
+ GNUTLS_LIBS="$GNUTLS_LIBS -lgcrypt"
+ dnl We're not using gcrypt deprecated features so define
+ dnl GCRYPT_NO_DEPRECATED to avoid deprecated warnings
+ GNUTLS_CFLAGS="$GNUTLS_CFLAGS -DGCRYPT_NO_DEPRECATED"
+ AC_DEFINE_UNQUOTED([WITH_GNUTLS_GCRYPT], 1,
+ [set to 1 if it is known or assumed that GNUTLS uses gcrypt])
+ fi
dnl gnutls 3.x moved some declarations to a new header
AC_CHECK_HEADERS([gnutls/crypto.h], [], [], [[
diff --git a/libvirt.spec.in b/libvirt.spec.in
index fce7f91..7fd3c85 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -438,7 +438,9 @@ BuildRequires: readline-devel
BuildRequires: ncurses-devel
BuildRequires: gettext
BuildRequires: libtasn1-devel
+%if (0%{?rhel} && 0%{?rhel} < 7) || (0%{?fedora} && 0%{?fedora} < 19)
BuildRequires: libgcrypt-devel
+%endif
BuildRequires: gnutls-devel
BuildRequires: libattr-devel
%if %{with_libvirtd}
diff --git a/src/libvirt.c b/src/libvirt.c
index 8157488..66e8248 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -55,7 +55,9 @@
#include "intprops.h"
#include "virconf.h"
#if WITH_GNUTLS
-# include <gcrypt.h>
+# if WITH_GNUTLS_GCRYPT
+# include <gcrypt.h>
+# endif
# include "rpc/virnettlscontext.h"
#endif
#include "vircommand.h"
@@ -270,7 +272,7 @@ winsock_init(void)
#endif
-#ifdef WITH_GNUTLS
+#ifdef WITH_GNUTLS_GCRYPT
static int virTLSMutexInit(void **priv)
{
virMutexPtr lock = NULL;
@@ -323,7 +325,7 @@ static struct gcry_thread_cbs virTLSThreadImpl = {
virTLSMutexUnlock,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
-#endif
+#endif /* WITH_GNUTLS_GCRYPT */
/* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This
* assumes you pass fewer than 15 arguments to VIR_DOMAIN_DEBUG, but
@@ -407,7 +409,7 @@ virGlobalInit(void)
virErrorInitialize() < 0)
goto error;
-#ifdef WITH_GNUTLS
+#ifdef WITH_GNUTLS_GCRYPT
/*
* This sequence of API calls it copied exactly from
* gnutls 2.12.23 source lib/gcrypt/init.c, with
--
1.7.1
11 years, 3 months
[libvirt] [PATCH 0/3] Add tests for network update XML parsing
by Ján Tomko
Ján Tomko (3):
Add space before the slash in dns srv entries
Reverse logic allowing partial DHCP host XML
Test network XML update
src/conf/network_conf.h | 9 +
src/libvirt_private.syms | 1 +
src/conf/network_conf.c | 25 +-
tests/Makefile.am | 9 +-
tests/networkxml2xmltest.c | 3 +
tests/networkxml2xmlupdatetest.c | 372 +++++++++++++++++++++
.../nat-network-dns-srv-records.xml | 27 ++
.../nat-network-dns-srv-records.xml | 27 ++
.../networkxml2xmlupdatein/dhcp-range-existing.xml | 1 +
tests/networkxml2xmlupdatein/dhcp-range.xml | 1 +
.../dns-host-gateway-incomplete.xml | 3 +
tests/networkxml2xmlupdatein/dns-host-pudding.xml | 3 +
.../dns-txt-record-example.xml | 1 +
.../dns-txt-record-snowman.xml | 1 +
tests/networkxml2xmlupdatein/host-existing.xml | 1 +
tests/networkxml2xmlupdatein/host-incomplete.xml | 1 +
.../networkxml2xmlupdatein/host-new-incomplete.xml | 1 +
tests/networkxml2xmlupdatein/host-new.xml | 1 +
tests/networkxml2xmlupdatein/host-updated.xml | 1 +
tests/networkxml2xmlupdatein/interface-eth1.xml | 1 +
tests/networkxml2xmlupdatein/interface-eth47.xml | 1 +
.../networkxml2xmlupdatein/portgroup-alice-new.xml | 10 +
tests/networkxml2xmlupdatein/portgroup-alison.xml | 11 +
tests/networkxml2xmlupdatein/srv-record-donkey.xml | 1 +
.../networkxml2xmlupdatein/srv-record-invalid.xml | 1 +
.../networkxml2xmlupdatein/srv-record-protocol.xml | 1 +
.../networkxml2xmlupdatein/srv-record-service.xml | 1 +
tests/networkxml2xmlupdatein/srv-record.xml | 1 +
.../networkxml2xmlupdatein/unparsable-dns-host.xml | 1 +
.../dhcp6host-routed-network-another-range.xml | 27 ++
.../dhcp6host-routed-network-range.xml | 27 ++
.../nat-network-dns-more-hosts.xml | 19 ++
.../nat-network-dns-srv-record.xml | 26 ++
.../nat-network-dns-srv-records.xml | 27 ++
.../nat-network-dns-txt-none.xml | 23 ++
.../nat-network-dns-txt-records.xml | 27 ++
.../nat-network-forward-ifaces.xml | 27 ++
.../nat-network-host-updated.xml | 23 ++
.../networkxml2xmlupdateout/nat-network-hosts.xml | 24 ++
.../nat-network-no-forward-ifaces.xml | 24 ++
.../nat-network-no-hosts.xml | 10 +
.../nat-network-no-range.xml | 22 ++
.../nat-network-one-host.xml | 22 ++
tests/networkxml2xmlupdateout/nat-network.xml | 23 ++
.../openvswitch-net-modified.xml | 33 ++
.../openvswitch-net-more-portgroups.xml | 44 +++
.../openvswitch-net-without-alice.xml | 23 ++
47 files changed, 949 insertions(+), 19 deletions(-)
create mode 100644 tests/networkxml2xmlupdatetest.c
create mode 100644 tests/networkxml2xmlin/nat-network-dns-srv-records.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-srv-records.xml
create mode 100644 tests/networkxml2xmlupdatein/dhcp-range-existing.xml
create mode 100644 tests/networkxml2xmlupdatein/dhcp-range.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-host-gateway-incomplete.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-host-pudding.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-txt-record-example.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-txt-record-snowman.xml
create mode 100644 tests/networkxml2xmlupdatein/host-existing.xml
create mode 100644 tests/networkxml2xmlupdatein/host-incomplete.xml
create mode 100644 tests/networkxml2xmlupdatein/host-new-incomplete.xml
create mode 100644 tests/networkxml2xmlupdatein/host-new.xml
create mode 100644 tests/networkxml2xmlupdatein/host-updated.xml
create mode 100644 tests/networkxml2xmlupdatein/interface-eth1.xml
create mode 100644 tests/networkxml2xmlupdatein/interface-eth47.xml
create mode 100644 tests/networkxml2xmlupdatein/portgroup-alice-new.xml
create mode 100644 tests/networkxml2xmlupdatein/portgroup-alison.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-donkey.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-invalid.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-protocol.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-service.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record.xml
create mode 100644 tests/networkxml2xmlupdatein/unparsable-dns-host.xml
create mode 100644 tests/networkxml2xmlupdateout/dhcp6host-routed-network-another-range.xml
create mode 100644 tests/networkxml2xmlupdateout/dhcp6host-routed-network-range.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-srv-record.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-srv-records.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-txt-none.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-txt-records.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-forward-ifaces.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-host-updated.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-hosts.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-no-forward-ifaces.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-no-hosts.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-no-range.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-one-host.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network.xml
create mode 100644 tests/networkxml2xmlupdateout/openvswitch-net-modified.xml
create mode 100644 tests/networkxml2xmlupdateout/openvswitch-net-more-portgroups.xml
create mode 100644 tests/networkxml2xmlupdateout/openvswitch-net-without-alice.xml
--
1.8.1.5
11 years, 3 months
[libvirt] [PATCH v5 0/2] add startupPolicy support for harddisks
by Guannan Ren
These patches are based on code
https://www.redhat.com/archives/libvir-list/2013-July/msg01741.html
The set of patches is trying to add 'startupPolicy' support for guest
hard disks.
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. migration is not supported yet.
Guannan Ren(2)
[PATCH v5 1/2] conf: add startupPolicy attribute for harddisk
[PATCH v5 2/2] qemu: support to drop disk with 'optional' startupPolicy
docs/formatdomain.html.in | 8 ++++++--
docs/schemas/domaincommon.rng | 6 ++++++
include/libvirt/libvirt.h.in | 1 +
src/conf/domain_conf.c | 31 +++++++++++++++++++++++--------
src/qemu/qemu_domain.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
5 files changed, 97 insertions(+), 26 deletions(-)
11 years, 3 months