[libvirt] [PATCH 0/3] more virCommand cleanups
by Eric Blake
When I first reviewed Cole's virCommand cleanups, I pointed out some
possible later cleanups. Here they are.
Eric Blake (3):
command: reduce duplicated debug messages
command: avoid double close
storage: avoid an intermediate malloc
src/storage/storage_backend.c | 20 ++++++------
src/util/command.c | 64 ++++++++++++++++++++--------------------
2 files changed, 42 insertions(+), 42 deletions(-)
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] docs: improve VIR_DOMAIN_AFFECT_CURRENT description
by Eric Blake
* include/libvirt/libvirt.h.in (virDomainModificationImpact): Reword.
---
include/libvirt/libvirt.h.in | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 76ad908..a7c5f72 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -144,11 +144,16 @@ typedef enum {
/**
* virDomainModificationImpact:
*
- * Several APIs take flags to determine whether a change to the domain
- * affects just the running instance, just the persistent definition,
- * or both. The use of VIR_DOMAIN_AFFECT_CURRENT will resolve to
- * either VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG according
- * to current domain state. VIR_DOMAIN_AFFECT_LIVE requires a running
+ * Several modification APIs take flags to determine whether a change
+ * to the domain affects just the running instance, just the
+ * persistent definition, or both at the same time. The counterpart
+ * query APIs also take the same flags to determine whether to query
+ * the running instance or persistent definition, although both cannot
+ * be queried at once.
+ *
+ * The use of VIR_DOMAIN_AFFECT_CURRENT will resolve to either
+ * VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG according to
+ * current domain state. VIR_DOMAIN_AFFECT_LIVE requires a running
* domain, and VIR_DOMAIN_AFFECT_CONFIG requires a persistent domain
* (whether or not it is running).
*/
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] Fix errno return in safezero()
by Daniel P. Berrange
Most of the safezero() implementations return -1 on error,
setting errno. The safezero() impl using posix_fallocate()
though returned a positive errno value on error (due to
the unusual API contract of posix_fallocate() compared to
most syscall APIs).
* src/util/util.c: Ensure safezero() returns -1 and sets
errno on error.
* src/storage/storage_backend.c: Change safezero != 0 to
< 0 for detecting errors
---
src/storage/storage_backend.c | 4 ++--
src/util/util.c | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index d269e4c..63e3005 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -331,7 +331,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
if (bytes > remain)
bytes = remain;
- if (safezero(fd, 0, vol->allocation - remain, bytes) != 0) {
+ if (safezero(fd, 0, vol->allocation - remain, bytes) < 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file '%s'"),
vol->target.path);
@@ -340,7 +340,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
remain -= bytes;
}
} else { /* No progress bars to be shown */
- if (safezero(fd, 0, 0, remain) != 0) {
+ if (safezero(fd, 0, 0, remain) < 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file '%s'"),
vol->target.path);
diff --git a/src/util/util.c b/src/util/util.c
index d00f065..dbfe2ee 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -136,7 +136,11 @@ safewrite(int fd, const void *buf, size_t count)
#ifdef HAVE_POSIX_FALLOCATE
int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
{
- return posix_fallocate(fd, offset, len);
+ int ret = posix_fallocate(fd, offset, len);
+ if (ret == 0)
+ return 0;
+ errno = ret;
+ return -1;
}
#else
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] Add missing error reporting when loading mac filter config for QEMU
by Daniel P. Berrange
If the 'mac_filter' configuration parameter is enabled, and there
is a failure to enable filtering, no error is reported back to
the caller. Also fix some bogus whitespace indentation for
hugetlbfs_mount
* src/qemu/qemu_conf.c: Add missing error reporting
---
src/qemu/qemu_conf.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b00b391..3d8aba4 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -378,16 +378,16 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
}
}
- p = virConfGetValue (conf, "hugetlbfs_mount");
- CHECK_TYPE ("hugetlbfs_mount", VIR_CONF_STRING);
- if (p && p->str) {
- VIR_FREE(driver->hugetlbfs_mount);
- if (!(driver->hugetlbfs_mount = strdup(p->str))) {
- virReportOOMError();
- virConfFree(conf);
- return -1;
- }
- }
+ p = virConfGetValue (conf, "hugetlbfs_mount");
+ CHECK_TYPE ("hugetlbfs_mount", VIR_CONF_STRING);
+ if (p && p->str) {
+ VIR_FREE(driver->hugetlbfs_mount);
+ if (!(driver->hugetlbfs_mount = strdup(p->str))) {
+ virReportOOMError();
+ virConfFree(conf);
+ return -1;
+ }
+ }
p = virConfGetValue (conf, "mac_filter");
CHECK_TYPE ("mac_filter", VIR_CONF_LONG);
@@ -398,12 +398,16 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
virReportSystemError(errno,
_("failed to enable mac filter in '%s'"),
__FILE__);
+ virConfFree(conf);
+ return -1;
}
if ((errno = networkDisableAllFrames(driver))) {
virReportSystemError(errno,
_("failed to add rule to drop all frames in '%s'"),
__FILE__);
+ virConfFree(conf);
+ return -1;
}
}
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] Add missing checks for NULL in domain lock manager
by Daniel P. Berrange
The domain lock manager forgot to include a bunch of checks
for NULL which could occur on OOM
* src/locking/domain_lock.c: Add checks for NULL
---
src/locking/domain_lock.c | 49 ++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index 771ed53..feb3f98 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -157,10 +157,13 @@ int virDomainLockProcessStart(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
bool paused)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
+ virLockManagerPtr lock;
int ret;
int flags = VIR_LOCK_MANAGER_ACQUIRE_RESTRICT;
+ if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
+ return -1;
+
if (paused)
flags |= VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY;
@@ -175,9 +178,13 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
char **state)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
- int ret = virLockManagerRelease(lock, state, 0);
+ virLockManagerPtr lock;
+ int ret;
+
+ if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
+ return -1;
+ ret = virLockManagerRelease(lock, state, 0);
virLockManagerFree(lock);
return ret;
@@ -187,9 +194,13 @@ int virDomainLockProcessResume(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
const char *state)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
- int ret = virLockManagerAcquire(lock, state, 0);
+ virLockManagerPtr lock;
+ int ret;
+
+ if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
+ return -1;
+ ret = virLockManagerAcquire(lock, state, 0);
virLockManagerFree(lock);
return ret;
@@ -199,9 +210,13 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
char **state)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
- int ret = virLockManagerInquire(lock, state, 0);
+ virLockManagerPtr lock;
+ int ret;
+ if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
+ return -1;
+
+ ret = virLockManagerInquire(lock, state, 0);
virLockManagerFree(lock);
return ret;
@@ -212,9 +227,12 @@ int virDomainLockDiskAttach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainDiskDefPtr disk)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
+ virLockManagerPtr lock;
int ret = -1;
+ if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
+ return -1;
+
if (virDomainLockManagerAddDisk(lock, disk) < 0)
goto cleanup;
@@ -233,9 +251,12 @@ int virDomainLockDiskDetach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainDiskDefPtr disk)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
+ virLockManagerPtr lock;
int ret = -1;
+ if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
+ return -1;
+
if (virDomainLockManagerAddDisk(lock, disk) < 0)
goto cleanup;
@@ -255,9 +276,12 @@ int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainLeaseDefPtr lease)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
+ virLockManagerPtr lock;
int ret = -1;
+ if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
+ return -1;
+
if (virDomainLockManagerAddLease(lock, lease) < 0)
goto cleanup;
@@ -276,9 +300,12 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainLeaseDefPtr lease)
{
- virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
+ virLockManagerPtr lock;
int ret = -1;
+ if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
+ return -1;
+
if (virDomainLockManagerAddLease(lock, lease) < 0)
goto cleanup;
--
1.7.4.4
13 years, 6 months
[libvirt] Virt Tools Blog Planet (RSS feed aggregator)
by Daniel P. Berrange
The virt-tools.org website, launched last year, provides tutorials,
videos, documentation, online help and roadmaps relevant to libvirt,
libguestfs, gtk-vnc, spice, other related libraries, and tools or
applications like virt-manager & virt-install. The site goal is to
inform & assist end users, system administrators & application
developers who wish to learn about the capabilities of the virt tools
stack. The focus of most content is the, state of the art, Linux native
KVM hypervisor, but writing about using other hypervisors using virt
tools is also welcome.
Today we are launching a new part of the site, the Blog Planet, to
aggregate feeds from people working on virt tools related projects:
http://planet.virt-tools.org/index.html
The site is seeded with a mere 2 blogs thus far, and so we are looking
for content from other people working on libvirt, libguestfs, gtk-vnc,
spice, and any other infrastructure/tools which integrate with them.
The aim is for the Blog Planet to contain content directly useful to
end users, system administrators and application developers. To that
end, it is desirable if your blog feed can be filtered to just include
content directly related to virt tools.
Any wordpress users can trivially do this by assigning either categories
or tags to their posts, which the provide dedicated RSS feeds; other blog
software hopefully has similar capabilities.
To be included on the planet, send (off-list) your RSS feed URL and a
Hackergotchi face icon (upto an absolute max of 96x96 pixels in size).
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
13 years, 6 months
[libvirt] [PATCH 1/2] qemu: Scrape stdout for virtio console pty
by Cole Robinson
Currently we forget to do this and have to fallback to info chardev (which
also fails, see following patch)
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_process.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1efe024..349c25a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -989,6 +989,16 @@ qemuProcessFindCharDevicePTYs(virDomainObjPtr vm,
}
}
+ if (vm->def->console) {
+ virDomainChrDefPtr chr = vm->def->console;
+ if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
+ chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
+ if ((ret = qemuProcessExtractTTYPath(output, &offset,
+ &chr->source.data.file.path)) != 0)
+ return ret;
+ }
+ }
+
return 0;
}
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] Add support for network filter code in LXC driver
by Daniel P. Berrange
The LXC driver networking uses veth device pairs. These can
be easily hooked into the network filtering code.
* src/lxc/lxc_driver.c: Add calls to setup/teardown nwfilter
---
src/lxc/lxc_driver.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 8eb87a2..4d14466 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -52,7 +52,7 @@
#include "hooks.h"
#include "files.h"
#include "fdstream.h"
-
+#include "domain_nwfilter.h"
#define VIR_FROM_THIS VIR_FROM_LXC
@@ -1027,6 +1027,8 @@ static void lxcVmCleanup(lxc_driver_t *driver,
vethDelete(vm->def->nets[i]->ifname);
}
+ virDomainConfVMNWFilterTeardown(vm);
+
if (driver->cgroup &&
virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) == 0) {
virCgroupRemove(cgroup);
@@ -1146,6 +1148,10 @@ static int lxcSetupInterfaces(virConnectPtr conn,
if (vethInterfaceUpOrDown(parentVeth, 1) < 0)
goto error_exit;
+
+ if (def->nets[i]->filter &&
+ virDomainConfNWFilterInstantiate(conn, def->nets[i]) < 0)
+ goto error_exit;
}
rc = 0;
@@ -1538,8 +1544,10 @@ cleanup:
vethDelete(veths[i]);
VIR_FREE(veths[i]);
}
- if (rc != 0)
+ if (rc != 0) {
VIR_FORCE_CLOSE(priv->monitor);
+ virDomainConfVMNWFilterTeardown(vm);
+ }
VIR_FORCE_CLOSE(parentTty);
VIR_FREE(logfile);
return rc;
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH 2/2] Try stdin for input when no file is specified
by Michael Williams
Modify virFileReadAll to check for redirected stdin input when
no file is specified. This means that not every file argument
needs to be required.
Signed-off-by: Michael Williams <mspacex(a)gmail.com>
---
src/util/util.c | 10 +++++-
tools/virsh.c | 99
+++++++++++++++++++++++++++++++++++--------------------
2 files changed, 72 insertions(+), 37 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 554d68e..84b3ae5 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -445,7 +445,15 @@ int virFileReadAll(const char *path, int maxlen,
char **buf)
{
int fd;
- if (strcmp(path,"-") == 0)
+ if (!path) {
+ if (isatty(fileno(stdin))) {
+ virReportSystemError(EINVAL, "%s", _("Missing <file>
argument"));
+ return -1;
+ } else
+ path = "-";
+ }
+
+ if (strcmp(path,"-") == 0) fd = fileno(stdin);
else
fd = open(path, O_RDONLY);
diff --git a/tools/virsh.c b/tools/virsh.c
index 76478dc..5b90b72 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1248,7 +1248,7 @@ static const vshCmdInfo info_create[] = {
};
static const vshCmdOptDef opts_create[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML
domain description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML domain
description")},
#ifndef WIN32
{"console", VSH_OT_BOOL, 0, N_("attach to console after creation")},
#endif
@@ -1271,8 +1271,10 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -1308,7 +1310,7 @@ static const vshCmdInfo info_define[] = {
};
static const vshCmdOptDef opts_define[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML
domain description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML domain
description")},
{NULL, 0, 0, NULL}
};
@@ -1323,8 +1325,10 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -3801,7 +3805,7 @@ static const vshCmdInfo info_domxmlfromnative[] = {
static const vshCmdOptDef opts_domxmlfromnative[] = {
{"format", VSH_OT_DATA, VSH_OFLAG_REQ, N_("source config data
format")},
- {"config", VSH_OT_DATA, VSH_OFLAG_REQ, N_("config data file to
import from")},
+ {"config", VSH_OT_DATA, 0, N_("config data file to import from")},
{NULL, 0, 0, NULL}
};
@@ -3847,7 +3851,7 @@ static const vshCmdInfo info_domxmltonative[] = {
static const vshCmdOptDef opts_domxmltonative[] = {
{"format", VSH_OT_DATA, VSH_OFLAG_REQ, N_("target config data type
format")},
- {"xml", VSH_OT_DATA, VSH_OFLAG_REQ, N_("xml data file to export
from")},
+ {"xml", VSH_OT_DATA, 0, N_("xml data file to export from")},
{NULL, 0, 0, NULL}
};
@@ -4447,8 +4451,10 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -4478,7 +4484,7 @@ static const vshCmdInfo info_network_define[] = {
};
static const vshCmdOptDef opts_network_define[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML
network description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML network
description")},
{NULL, 0, 0, NULL}
};
@@ -5249,7 +5255,7 @@ static const vshCmdInfo info_interface_define[] = {
};
static const vshCmdOptDef opts_interface_define[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML
interface description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML interface
description")},
{NULL, 0, 0, NULL}
};
@@ -5264,8 +5270,10 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd
*cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -5494,7 +5502,7 @@ static const vshCmdInfo info_nwfilter_define[] = {
};
static const vshCmdOptDef opts_nwfilter_define[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML
network filter description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML network filter
description")},
{NULL, 0, 0, NULL}
};
@@ -5509,8 +5517,10 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd
*cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -5832,7 +5842,7 @@ static const vshCmdInfo info_pool_create[] = {
};
static const vshCmdOptDef opts_pool_create[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
+ {"file", VSH_OT_DATA, 0,
N_("file containing an XML pool description")},
{NULL, 0, 0, NULL}
};
@@ -5848,8 +5858,10 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -5882,7 +5894,7 @@ static const vshCmdInfo info_node_device_create[] = {
};
static const vshCmdOptDef opts_node_device_create[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
+ {"file", VSH_OT_DATA, 0,
N_("file containing an XML description of the device")},
{NULL, 0, 0, NULL}
};
@@ -5898,8 +5910,10 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd
*cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -6092,7 +6106,7 @@ static const vshCmdInfo info_pool_define[] = {
};
static const vshCmdOptDef opts_pool_define[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML
pool description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML pool
description")},
{NULL, 0, 0, NULL}
};
@@ -6107,8 +6121,10 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -7338,7 +7354,7 @@ static const vshCmdInfo info_vol_create[] = {
static const vshCmdOptDef opts_vol_create[] = {
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML vol
description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML vol description")},
{NULL, 0, 0, NULL}
};
@@ -7358,7 +7374,8 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
VSH_BYNAME)))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0) {
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
virStoragePoolFree(pool);
return false;
}
@@ -7395,7 +7412,7 @@ static const vshCmdInfo info_vol_create_from[] = {
static const vshCmdOptDef opts_vol_create_from[] = {
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML vol
description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML vol description")},
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("input vol name or key")},
{"inputpool", VSH_OT_STRING, 0, N_("pool name or uuid of the input
volume's pool")},
{NULL, 0, 0, NULL}
@@ -7416,7 +7433,8 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME)))
goto cleanup;
- if (vshCommandOptString(cmd, "file", &from) <= 0) {
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
goto cleanup;
}
@@ -7570,7 +7588,7 @@ static const vshCmdInfo info_vol_upload[] = {
static const vshCmdOptDef opts_vol_upload[] = {
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name, key or path")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file")},
+ {"file", VSH_OT_DATA, 0, N_("file")},
{"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
{"offset", VSH_OT_INT, 0, N_("volume offset to upload to") },
{"length", VSH_OT_INT, 0, N_("amount of data to upload") },
@@ -7670,7 +7688,7 @@ static const vshCmdInfo info_vol_download[] = {
static const vshCmdOptDef opts_vol_download[] = {
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name, key or path")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file")},
+ {"file", VSH_OT_DATA, 0, N_("file")},
{"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
{"offset", VSH_OT_INT, 0, N_("volume offset to download from") },
{"length", VSH_OT_INT, 0, N_("amount of data to download") },
@@ -8380,7 +8398,7 @@ static const vshCmdInfo info_secret_define[] = {
};
static const vshCmdOptDef opts_secret_define[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing secret
attributes in XML")},
+ {"file", VSH_OT_DATA, 0, N_("file containing secret attributes in
XML")},
{NULL, 0, 0, NULL}
};
@@ -8395,8 +8413,10 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -9325,7 +9345,7 @@ static const vshCmdInfo info_attach_device[] = {
static const vshCmdOptDef opts_attach_device[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
+ {"file", VSH_OT_DATA, 0, N_("XML file")},
{"persistent", VSH_OT_BOOL, 0, N_("persist device attachment")},
{NULL, 0, 0, NULL}
};
@@ -9345,7 +9365,8 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0) {
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
virDomainFree(dom);
return false;
}
@@ -9390,7 +9411,7 @@ static const vshCmdInfo info_detach_device[] = {
static const vshCmdOptDef opts_detach_device[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
+ {"file", VSH_OT_DATA, 0, N_("XML file")},
{"persistent", VSH_OT_BOOL, 0, N_("persist device detachment")},
{NULL, 0, 0, NULL}
};
@@ -9410,7 +9431,8 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0) {
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
virDomainFree(dom);
return false;
}
@@ -9455,7 +9477,7 @@ static const vshCmdInfo info_update_device[] = {
static const vshCmdOptDef opts_update_device[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
+ {"file", VSH_OT_DATA, 0, N_("XML file")},
{"persistent", VSH_OT_BOOL, 0, N_("persist device update")},
{"force", VSH_OT_BOOL, 0, N_("force device update")},
{NULL, 0, 0, NULL}
@@ -9476,7 +9498,8 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0) {
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
virDomainFree(dom);
return false;
}
@@ -10042,7 +10065,7 @@ static const vshCmdInfo info_cpu_compare[] = {
};
static const vshCmdOptDef opts_cpu_compare[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML CPU
description")},
+ {"file", VSH_OT_DATA, 0, N_("file containing an XML CPU description")},
{NULL, 0, 0, NULL}
};
@@ -10057,8 +10080,10 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
@@ -10104,7 +10129,7 @@ static const vshCmdInfo info_cpu_baseline[] = {
};
static const vshCmdOptDef opts_cpu_baseline[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing XML CPU
descriptions")},
+ {"file", VSH_OT_DATA, 0, N_("file containing XML CPU descriptions")},
{NULL, 0, 0, NULL}
};
@@ -10128,8 +10153,10 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (vshCommandOptString(cmd, "file", &from) <= 0)
+ if (vshCommandOptString(cmd, "file", &from) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
return false;
+ }
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
return false;
--
1.7.3.4
13 years, 6 months
[libvirt] [PATCH v4 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 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.
The <dns> element have to be present on the <ip> level, i.e.
one level upper than it was in version 2 of the patch since
the definition affects all the IP addresses on the network.
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.
This is the new version for latest libvirt codebase so please
review the patchset.
Thanks,
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Michal Novotny (5):
Add TXT record support for virtual DNS service
Network: Add regression tests for the command-line arguments
Network: Move dnsmasqContext creation to
networkSaveDnsmasqHostsfile()
Network: Add additional hosts internal infrastructure
Network: Add support for DNS hosts definition to the network XML
docs/formatnetwork.html.in | 31 +++
docs/schemas/network.rng | 21 ++
src/Makefile.am | 11 +-
src/conf/network_conf.c | 212 +++++++++++++++
src/conf/network_conf.h | 25 ++
src/libvirt_network.syms | 6 +
src/libvirt_private.syms | 1 +
src/network/bridge_driver.c | 118 ++++++---
src/network/bridge_driver.h | 3 +
src/util/dnsmasq.c | 285 ++++++++++++++++++--
src/util/dnsmasq.h | 22 ++-
tests/Makefile.am | 10 +
tests/networkxml2argvdata/isolated-network.argv | 1 +
tests/networkxml2argvdata/isolated-network.xml | 11 +
.../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 | 100 +++++++
.../nat-network-dns-txt-record.xml | 24 ++
.../nat-network-dns-txt-record.xml | 24 ++
tests/networkxml2xmltest.c | 2 +
28 files changed, 941 insertions(+), 52 deletions(-)
create mode 100644 src/libvirt_network.syms
create mode 100644 tests/networkxml2argvdata/isolated-network.argv
create mode 100644 tests/networkxml2argvdata/isolated-network.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-txt-record.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-txt-record.xml
--
1.7.3.2
13 years, 6 months