[libvirt] [PATCH] virsh: avoid compiler warning on mingw
by Eric Blake
We don't use gnulib's sanitizations for vfprintf, but vshDebug
was used with %zu, which means that it would fail on mingw.
Thank goodness the compiler indirectly caught this for us :)
virsh.c: In function 'vshDebug':
virsh.c:12105:5: warning: function might be possible candidate for
'ms_printf' format attribute [-Wmissing-format-attribute]
since mingw <stdio.h> hasn't yet added gcc attributes to vfprintf.
* tools/virsh.c (vshDebug): Avoid vfprintf.
(vshPrintExtra): Use lighter-weight fputs.
Reported by Matthias Bolte.
---
tools/virsh.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 27140f3..0212b99 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -12096,6 +12096,7 @@ static void
vshDebug(vshControl *ctl, int level, const char *format, ...)
{
va_list ap;
+ char *str;
va_start(ap, format);
vshOutputLogFile(ctl, VSH_ERR_DEBUG, format, ap);
@@ -12105,8 +12106,14 @@ vshDebug(vshControl *ctl, int level, const char *format, ...)
return;
va_start(ap, format);
- vfprintf(stdout, format, ap);
+ if (virVasprintf(&str, format, ap) < 0) {
+ /* Skip debug messages on low memory */
+ va_end(ap);
+ return;
+ }
va_end(ap);
+ fputs(str, stdout);
+ VIR_FREE(str);
}
static void
@@ -12125,7 +12132,7 @@ vshPrintExtra(vshControl *ctl, const char *format, ...)
return;
}
va_end(ap);
- fprintf(stdout, "%s", str);
+ fputs(str, stdout);
VIR_FREE(str);
}
--
1.7.4.4
13 years, 8 months
[libvirt] [PATCH 0/4] Unify error messages
by Michal Privoznik
As libvirt error codes evolved over time, it was more unclear to know, which
code should be use in what cases. This patch series tries to correct those
places, so we don't say it is internal error, when in fact incorrect XML was
given. Also some error messages were changed to give more hints.
Michal Privoznik (4):
Fix error messages codes when TypeFromString fails
New error code VIR_ERR_XML_CONFIG
Improve incorrect root element error messages
Change XML parsing error codes when details are presented.
include/libvirt/virterror.h | 1 +
src/conf/cpu_conf.c | 13 ++--
src/conf/domain_conf.c | 165 +++++++++++++++++++-----------------
src/conf/interface_conf.c | 56 ++++++------
src/conf/network_conf.c | 20 +++--
src/conf/node_device_conf.c | 10 ++-
src/conf/nwfilter_conf.c | 16 ++--
src/conf/secret_conf.c | 14 ++--
src/conf/storage_conf.c | 66 ++++++++-------
src/conf/storage_encryption_conf.c | 14 ++--
src/security/virt-aa-helper.c | 3 +-
src/test/test_driver.c | 13 ++-
src/util/virterror.c | 6 ++
src/util/xml.c | 2 +-
14 files changed, 218 insertions(+), 181 deletions(-)
--
1.7.4.4
13 years, 8 months
[libvirt] [PATCH V3] xen: check if device is assigned to guest before reattaching
by Yufang Zhang
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=664059
This is the version3 patch for BZ#664059. Reattaching pci device back to
host without destroying guest or detaching device from guest would cause
host to crash. This patch adds a check before doing device reattach. If
the device is being assigned to guest, libvirt refuses to reattach device
to host. The patch only works for Xen, for it just checks xenstore to get
pci device information. This version fixes some formatting problem and moves
lock-unlock out of loop so that the check is atomic.
Signed-off-by: Yufang Zhang <yuzhang(a)redhat.com>
---
src/xen/xen_driver.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 2a07b7b..dd94fbc 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1927,11 +1927,70 @@ out:
}
static int
+xenUnifiedNodeDeviceAssignedDomainId (virNodeDevicePtr dev)
+{
+ int numdomains;
+ int ret = -1, i;
+ int *ids = NULL;
+ char *bdf = NULL;
+ char *xref = NULL;
+ unsigned int domain, bus, slot, function;
+ virConnectPtr conn = dev->conn;
+ xenUnifiedPrivatePtr priv = conn->privateData;
+
+ /* Get active domains */
+ numdomains = xenUnifiedNumOfDomains(conn);
+ if (numdomains < 0) {
+ return ret;
+ }
+ if (numdomains > 0){
+ if (VIR_ALLOC_N(ids, numdomains) < 0) {
+ virReportOOMError();
+ goto out;
+ }
+ if ((numdomains = xenUnifiedListDomains(conn, &ids[0], numdomains)) < 0) {
+ goto out;
+ }
+ }
+
+ /* Get pci bdf */
+ if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
+ goto out;
+
+ if (virAsprintf(&bdf, "%04x:%02x:%02x.%0x",
+ domain, bus, slot, function) < 0) {
+ virReportOOMError();
+ goto out;
+ }
+
+ xenUnifiedLock(priv);
+ /* Check if bdf is assigned to one of active domains */
+ for (i = 0; i < numdomains; i++ ) {
+ xref = xenStoreDomainGetPCIID(conn, ids[i], bdf);
+ if (xref == NULL) {
+ continue;
+ } else {
+ ret = ids[i];
+ break;
+ }
+ }
+ xenUnifiedUnlock(priv);
+
+ VIR_FREE(xref);
+ VIR_FREE(bdf);
+out:
+ VIR_FREE(ids);
+
+ return ret;
+}
+
+static int
xenUnifiedNodeDeviceReAttach (virNodeDevicePtr dev)
{
pciDevice *pci;
unsigned domain, bus, slot, function;
int ret = -1;
+ int domid;
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
@@ -1940,6 +1999,14 @@ xenUnifiedNodeDeviceReAttach (virNodeDevicePtr dev)
if (!pci)
return -1;
+ /* Check if device is assigned to an active guest */
+ if ((domid = xenUnifiedNodeDeviceAssignedDomainId(dev)) >= 0) {
+ xenUnifiedError(VIR_ERR_INTERNAL_ERROR,
+ _("Device %s has been assigned to guest %d"),
+ dev->name, domid);
+ goto out;
+ }
+
if (pciReAttachDevice(pci, NULL) < 0)
goto out;
--
1.7.4
13 years, 8 months
[libvirt] [PATCHv12 1/3] libvirt/qemu - support persistent modification of devices
by KAMEZAWA Hiroyuki
Rebased ont the latest git tree, which makes this work easier.
This series adds support for attach/detach/update disks of domain config.
==
This patch adds functions for modify domain's persistent definition.
To do error recovery in easy way, we use a copy of vmdef and update it.
The whole sequence will be:
make a copy of domain definition.
if (flags & MODIFY_CONFIG)
update copied domain definition
if (flags & MODIF_LIVE)
do hotplug.
if (no error)
save copied one to the file and update cached definition.
else
discard copied definition.
This patch is mixuture of Eric Blake's work and mine.
From: Eric Blake <eblake(a)redhat.com>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
Changelog: v11 -> v12
- rebased and fixed hunks.
- renamed qemudDomain....to qemuDomain...
(virDomainObjCopyPersistentDef): make a copy of persistent vm definition
(qemuDomainAttach/Detach/UpdateDeviceConfig) : callbacks. now empty
(qemuDomainModifyDeviceFlags): add support for MODIFY_CONFIG and MODIFY_CURRENT
---
src/conf/domain_conf.c | 18 ++++++
src/conf/domain_conf.h | 3 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 147 ++++++++++++++++++++++++++++++++++++----------
4 files changed, 137 insertions(+), 32 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 381e692..6c1098a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9509,3 +9509,21 @@ cleanup:
return ret;
}
+
+
+virDomainDefPtr
+virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom)
+{
+ char *xml;
+ virDomainDefPtr cur, ret;
+
+ cur = virDomainObjGetPersistentDef(caps, dom);
+
+ xml = virDomainDefFormat(cur, VIR_DOMAIN_XML_WRITE_FLAGS);
+ if (!xml)
+ return NULL;
+
+ ret = virDomainDefParseString(caps, xml, VIR_DOMAIN_XML_READ_FLAGS);
+
+ return ret;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6ea30b9..ddf111a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1288,6 +1288,9 @@ int virDomainObjSetDefTransient(virCapsPtr caps,
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
virDomainObjPtr domain);
+virDomainDefPtr
+virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom);
+
void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainObjPtr dom);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ba7739d..f732431 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -287,6 +287,7 @@ virDomainMemballoonModelTypeToString;
virDomainNetDefFree;
virDomainNetTypeToString;
virDomainObjAssignDef;
+virDomainObjCopyPersistentDef;
virDomainObjSetDefTransient;
virDomainObjGetPersistentDef;
virDomainObjIsDuplicate;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 771678e..fd85c8a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4073,6 +4073,46 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm,
return ret;
}
+static int
+qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr dev)
+{
+ switch (dev->type) {
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("persistent attach of device is not supported"));
+ return -1;
+ }
+ return 0;
+}
+
+
+static int
+qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr dev)
+{
+ switch (dev->type) {
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("persistent detach of device is not supported"));
+ return -1;
+ }
+ return 0;
+}
+
+static int
+qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr dev)
+{
+ switch (dev->type) {
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("persistent update of device is not supported"));
+ return -1;
+ }
+ return 0;
+}
+
/* Actions for qemuDomainModifyDeviceFlags */
enum {
QEMU_DEVICE_ATTACH,
@@ -4088,6 +4128,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
struct qemud_driver *driver = dom->conn->privateData;
virBitmapPtr qemuCaps = NULL;
virDomainObjPtr vm = NULL;
+ virDomainDefPtr vmdef = NULL;
virDomainDeviceDefPtr dev = NULL;
bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
int ret = -1;
@@ -4097,12 +4138,6 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
(action == QEMU_DEVICE_UPDATE ?
VIR_DOMAIN_DEVICE_MODIFY_FORCE : 0), -1);
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
- return -1;
- }
-
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
@@ -4116,12 +4151,27 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm)) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot attach device on inactive domain"));
- goto endjob;
+ if (virDomainObjIsActive(vm)) {
+ if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
+ flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+ } else {
+ if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
+ flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
+ /* check consistency between flags and the vm state */
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s",
+ _("cannot do live update a device on "
+ "inactive domain"));
+ goto endjob;
+ }
}
+ if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("cannot modify device on transient domain"));
+ goto endjob;
+ }
dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
VIR_DOMAIN_XML_INACTIVE);
if (dev == NULL)
@@ -4132,35 +4182,68 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
&qemuCaps) < 0)
goto endjob;
- switch (action) {
- case QEMU_DEVICE_ATTACH:
- ret = qemuDomainAttachDeviceLive(vm, dev, dom, qemuCaps);
- break;
- case QEMU_DEVICE_DETACH:
- ret = qemuDomainDetachDeviceLive(vm, dev, dom, qemuCaps);
- break;
- case QEMU_DEVICE_UPDATE:
- ret = qemuDomainUpdateDeviceLive(vm, dev, dom, qemuCaps, force);
- break;
- default:
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- _("unknown domain modify action %d"), action);
- break;
- }
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ /* Make a copy for updated domain. */
+ vmdef = virDomainObjCopyPersistentDef(driver->caps, vm);
+ if (!vmdef)
+ goto endjob;
+ switch (action) {
+ case QEMU_DEVICE_ATTACH:
+ ret = qemuDomainAttachDeviceConfig(vmdef, dev);
+ break;
+ case QEMU_DEVICE_DETACH:
+ ret = qemuDomainDetachDeviceConfig(vmdef, dev);
+ break;
+ case QEMU_DEVICE_UPDATE:
+ ret = qemuDomainUpdateDeviceConfig(vmdef, dev);
+ break;
+ default:
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown domain modify action %d"), action);
+ break;
+ }
+ } else
+ ret = 0;
- /*
- * update domain status forcibly because the domain status may be changed
- * even if we attach the device failed. For example, a new controller may
- * be created.
- */
- if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
- ret = -1;
+ if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
+ switch (action) {
+ case QEMU_DEVICE_ATTACH:
+ ret = qemuDomainAttachDeviceLive(vm, dev, dom, qemuCaps);
+ break;
+ case QEMU_DEVICE_DETACH:
+ ret = qemuDomainDetachDeviceLive(vm, dev, dom, qemuCaps);
+ break;
+ case QEMU_DEVICE_UPDATE:
+ ret = qemuDomainUpdateDeviceLive(vm, dev, dom, qemuCaps, force);
+ break;
+ default:
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown domain modify action %d"), action);
+ break;
+ }
+ /*
+ * update domain status forcibly because the domain status may be
+ * changed even if we attach the device failed. For example, a
+ * For example, a new controller may be created.
+ */
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ ret = -1;
+ }
+ /* Finally, if no error until here, we can save config. */
+ if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
+ ret = virDomainSaveConfig(driver->configDir, vmdef);
+ if (!ret) {
+ virDomainObjAssignDef(vm, vmdef, false);
+ vmdef = NULL;
+ }
+ }
endjob:
if (qemuDomainObjEndJob(vm) == 0)
vm = NULL;
cleanup:
+ virDomainDefFree(vmdef);
virDomainDeviceDefFree(dev);
if (vm)
virDomainObjUnlock(vm);
--
1.7.4.1
13 years, 8 months
[libvirt] [PATCH] Xen: Do not generate net ifname if domain is inactive
by Jim Fehlig
The xend driver will generate a virDomainNetDef ifname if one is not
specified in xend sexpr, even if domain is inactive. The result is
network interface XML containing 'vif-1.Y' on dev attribute of target
element, e.g.
<interface type='bridge'>
<target dev='vif-1.0'/>
...
This patch changes the behavior to only generate the ifname if not
specified in xend sexpr *and* domain is not inactive (id != -1).
---
src/xenxs/xen_sxpr.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index d2ec370..66df786 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -547,12 +547,17 @@ xenParseSxprNets(virDomainDefPtr def,
}
tmp = sexpr_node(node, "device/vif/vifname");
- if (!tmp) {
+ /* If vifname is specified in xend config, include it in net
+ * definition regardless of domain state. If vifname is not
+ * specified, only generate one if domain is active (id != -1). */
+ if (tmp) {
+ if (!(net->ifname = strdup(tmp)))
+ goto no_memory;
+ } else if (def->id != -1) {
snprintf(buf, sizeof(buf), "vif%d.%d", def->id, vif_index);
- tmp = buf;
+ if (!(net->ifname = strdup(buf)))
+ goto no_memory;
}
- if (!(net->ifname = strdup(tmp)))
- goto no_memory;
tmp = sexpr_node(node, "device/vif/mac");
if (tmp) {
--
1.7.3.1
13 years, 8 months
[libvirt] [PATCH] Add warning message to XML definition files stored on disk
by Michal Privoznik
Users often edit XML domain file stored in configuration directory
thinking of modifying a domain/network/pool/etc. Thus it is wise
to let them know they are using the wrong way and give them hint.
---
src/conf/domain_conf.c | 2 ++
src/conf/network_conf.c | 1 +
src/conf/nwfilter_conf.c | 3 +++
src/conf/storage_conf.c | 2 ++
src/libvirt_private.syms | 1 +
src/util/util.c | 22 ++++++++++++++++++++++
src/util/util.h | 2 ++
7 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2a681d9..4cd1228 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8543,6 +8543,7 @@ int virDomainSaveConfig(const char *configDir,
VIR_DOMAIN_XML_WRITE_FLAGS)))
goto cleanup;
+ virSavePrependWarning(&xml);
if (virDomainSaveXML(configDir, def, xml))
goto cleanup;
@@ -8563,6 +8564,7 @@ int virDomainSaveStatus(virCapsPtr caps,
if (!(xml = virDomainObjFormat(caps, obj, flags)))
goto cleanup;
+ virSavePrependWarning(&xml);
if (virDomainSaveXML(statusDir, obj->def, xml))
goto cleanup;
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 5738757..82f10e6 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -959,6 +959,7 @@ int virNetworkSaveConfig(const char *configDir,
if (!(xml = virNetworkDefFormat(def)))
goto cleanup;
+ virSavePrependWarning(&xml);
if (virNetworkSaveXML(configDir, def, xml))
goto cleanup;
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 09dc32b..fcd0b24 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2282,6 +2282,7 @@ int virNWFilterSaveConfig(const char *configDir,
if (!(xml = virNWFilterDefFormat(def)))
goto cleanup;
+ virSavePrependWarning(&xml);
if (virNWFilterSaveXML(configDir, def, xml))
goto cleanup;
@@ -2635,6 +2636,8 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
return -1;
}
+ virSavePrependWarning(&xml);
+
if ((fd = open(nwfilter->configFile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 116898d..96aa567 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1542,6 +1542,8 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
return -1;
}
+ virSavePrependWarning(&xml);
+
if ((fd = open(pool->configFile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1b22be6..f2c005e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -946,6 +946,7 @@ virRandom;
virRandomInitialize;
virRun;
virRunWithHook;
+virSavePrependWarning;
virSetBlocking;
virSetCloseExec;
virSetInherit;
diff --git a/src/util/util.c b/src/util/util.c
index 1bb0328..c6a4634 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -3204,3 +3204,25 @@ bool virIsDevMapperDevice(const char *devname ATTRIBUTE_UNUSED)
return false;
}
#endif
+
+int virSavePrependWarning(char **xml) {
+ char *retPtr = NULL;
+ int ret;
+
+ ret = virAsprintf(&retPtr, "%s\n%s",
+ _("<!--\n\
+WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE\n\
+OVERWRITTEN AND LOST. Changes to xml configurations should be made using virsh\n\
+edit or other application using the libvirt API. See:\n\
+\n\
+http://wiki.libvirt.org/wiki/index.php?title=FAQ#Where_are_VM_config_files_stored.3F_How_do_I_edit_a_VM.27s_XML_config.3F\n\
+-->\n"),
+ *xml);
+
+ if (ret < 0)
+ return ret;
+
+ VIR_FREE(*xml);
+ *xml = retPtr;
+ return ret;
+}
diff --git a/src/util/util.h b/src/util/util.h
index d320c40..a6a91de 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -299,4 +299,6 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
char *virTimestamp(void);
bool virIsDevMapperDevice(const char *devname) ATTRIBUTE_NONNULL(1);
+
+int virSavePrependWarning(char **xml);
#endif /* __VIR_UTIL_H__ */
--
1.7.4.4
13 years, 8 months
[libvirt] [PATCH v2 0/5] Add TXT record and hosts support for DNS service and dnsmasq command-line regression testing
by Michal Novotny
Hi,
this is the patch to introduce the TXT record and DNS hosts support
for the DNS service on the virtual network. This can be defined using
the txt-record subelement in the dns element of the network XML
description. The definition of TXT record names containing spaces
is rejected with the error message that TXT record names in DNS
doesn't support spaces.
Also, regression testing for the dnsmasq command line has been
added to test whether the dnsmasq command-line is correct or not.
The new XML definition syntax is:
<dns>
<txt-record name="example" value="example value" />
<host ip='192.168.122.1'>
<hostname>gateway</hostname>
<hostname>host</hostname>
</host>
</dns>
Where multiple host elements can be defined to put the aliases
for specified IP addresses.
The patch series has been tested for the configuration and it
was working fine and also RelaxNG schema with the tests have
been both altered to add test cases to test those patches.
All of the patches passed the make, make check and make
syntax-check commands and it has been tested for the definition
described above and it was working fine (tested using dig for
DNS TXT record and nslookup in the guest for the DNS hosts).
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Michal Novotny (5):
Network: Add TXT record support for virtual DNS service
Network: Add regression tests for the command line arguments
Network: Move dnsmasqContext creation to
networkSaveDnsmasqHostsfile() and pass to dnsmasq only if
applicable
Network: Add additional hosts internal infrastructure
Network: Add support for DNS hosts definition in the network XML
docs/formatnetwork.html.in | 31 +++-
docs/schemas/network.rng | 20 ++
src/conf/network_conf.c | 183 ++++++++++++++
src/conf/network_conf.h | 25 ++
src/libvirt_private.syms | 1 +
src/network/bridge_driver.c | 103 ++++++--
src/network/bridge_driver.h | 3 +
src/util/dnsmasq.c | 266 +++++++++++++++++++-
src/util/dnsmasq.h | 22 ++-
tests/Makefile.am | 11 +
tests/networkxml2argvdata/isolated-network.argv | 1 +
tests/networkxml2argvdata/isolated-network.xml | 11 +
.../networkxml2argvdata/nat-network-dns-hosts.argv | 1 +
.../networkxml2argvdata/nat-network-dns-hosts.xml | 19 ++
.../nat-network-dns-txt-record.argv | 1 +
.../nat-network-dns-txt-record.xml | 24 ++
tests/networkxml2argvdata/nat-network.argv | 1 +
tests/networkxml2argvdata/nat-network.xml | 21 ++
tests/networkxml2argvdata/netboot-network.argv | 1 +
tests/networkxml2argvdata/netboot-network.xml | 14 +
.../networkxml2argvdata/netboot-proxy-network.argv | 1 +
.../networkxml2argvdata/netboot-proxy-network.xml | 13 +
tests/networkxml2argvdata/routed-network.argv | 1 +
tests/networkxml2argvdata/routed-network.xml | 9 +
tests/networkxml2argvtest.c | 120 +++++++++
tests/networkxml2xmlin/nat-network-dns-hosts.xml | 27 ++
.../nat-network-dns-txt-record.xml | 24 ++
tests/networkxml2xmlout/nat-network-dns-hosts.xml | 27 ++
.../nat-network-dns-txt-record.xml | 24 ++
tests/networkxml2xmltest.c | 2 +
30 files changed, 974 insertions(+), 33 deletions(-)
create mode 100644 tests/networkxml2argvdata/isolated-network.argv
create mode 100644 tests/networkxml2argvdata/isolated-network.xml
create mode 100644 tests/networkxml2argvdata/nat-network-dns-hosts.argv
create mode 100644 tests/networkxml2argvdata/nat-network-dns-hosts.xml
create mode 100644 tests/networkxml2argvdata/nat-network-dns-txt-record.argv
create mode 100644 tests/networkxml2argvdata/nat-network-dns-txt-record.xml
create mode 100644 tests/networkxml2argvdata/nat-network.argv
create mode 100644 tests/networkxml2argvdata/nat-network.xml
create mode 100644 tests/networkxml2argvdata/netboot-network.argv
create mode 100644 tests/networkxml2argvdata/netboot-network.xml
create mode 100644 tests/networkxml2argvdata/netboot-proxy-network.argv
create mode 100644 tests/networkxml2argvdata/netboot-proxy-network.xml
create mode 100644 tests/networkxml2argvdata/routed-network.argv
create mode 100644 tests/networkxml2argvdata/routed-network.xml
create mode 100644 tests/networkxml2argvtest.c
create mode 100644 tests/networkxml2xmlin/nat-network-dns-hosts.xml
create mode 100644 tests/networkxml2xmlin/nat-network-dns-txt-record.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-hosts.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-txt-record.xml
--
1.7.3.2
13 years, 8 months
[libvirt] libvirt-0.8.8 libvir: Security Labeling error : unable to set user and group to '0:0' on '...': Permission denied
by Nikola Ciprich
Hello,
I just noticed strange problem. While trying to start vm with cdrom image on a samba mount, I get:
libvir: Security Labeling error : unable to set user and group to '0:0' on '/home/cluster/images/interinformatics/CentOS-5.4-i386-bin-DVD.iso': Permission denied
I googled this up, and found some solutions, but none seems to be suitable for me. The biggest problem is I'm not using selinux at all, its completely disabled, and I don't have a chance to change mount parameters as well...
Is there any way to workaround this?
thanks a lot in advance!
BR
nik
--
-------------------------------------
Ing. Nikola CIPRICH
LinuxBox.cz, s.r.o.
28. rijna 168, 709 01 Ostrava
tel.: +420 596 603 142
fax: +420 596 621 273
mobil: +420 777 093 799
www.linuxbox.cz
mobil servis: +420 737 238 656
email servis: servis(a)linuxbox.cz
-------------------------------------
13 years, 8 months
[libvirt] [PATCH] network: fix return value of hostsFileWrite
by Laine Stump
The lone caller to hostsFileWrite (and the callers for at least 3
levels up the return stack) assume that the return value will be < 0
on failure. However, hostsFileWrite returns 0 on success, and a
positive errno on failure. This patch changes hostsFileWrite to return
-errno on failure.
---
src/util/dnsmasq.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c
index be230e1..2ba9355 100644
--- a/src/util/dnsmasq.c
+++ b/src/util/dnsmasq.c
@@ -159,19 +159,19 @@ hostsfileWrite(const char *path,
return rc;
if (virAsprintf(&tmp, "%s.new", path) < 0)
- return ENOMEM;
+ return -ENOMEM;
if (!(f = fopen(tmp, "w"))) {
istmp = false;
if (!(f = fopen(path, "w"))) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
}
for (i = 0; i < nhosts; i++) {
if (fputs(hosts[i].host, f) == EOF || fputc('\n', f) == EOF) {
- rc = errno;
+ rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
@@ -182,19 +182,19 @@ hostsfileWrite(const char *path,
}
if (VIR_FCLOSE(f) == EOF) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
if (istmp) {
if (rename(tmp, path) < 0) {
- rc = errno;
+ rc = -errno;
unlink(tmp);
goto cleanup;
}
if (unlink(tmp) < 0) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
}
--
1.7.3.4
13 years, 8 months
[libvirt] [PATCH] maint: fix comment typos
by Eric Blake
* src/esx/esx_driver.c: Fix spelling of 'relative'.
* src/util/util.c: Likewise.
---
Pushing under the trivial rule.
src/esx/esx_driver.c | 2 +-
src/util/util.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 79c1360..81e3c8e 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2413,7 +2413,7 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
VIR_DEBUG("usedCpuTimeCounterId %d END", priv->usedCpuTimeCounterId);
/*
- * FIXME: Cannot map between realtive used-cpu-time and absolute
+ * FIXME: Cannot map between relative used-cpu-time and absolute
* info->cpuTime
*/
}
diff --git a/src/util/util.c b/src/util/util.c
index 16454ed..a28af0b 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2040,7 +2040,7 @@ cleanup:
/*
- * Creates an absolute path for a potentialy realtive path.
+ * Creates an absolute path for a potentially relative path.
* Return 0 if the path was not relative, or on success.
* Return -1 on error.
*
--
1.7.4.4
13 years, 8 months