[libvirt] [PATCH 1/2] virStrndup: Accept negative values as string length
by Michal Privoznik
It may shorten the code a bit as the following pattern:
VIR_STRNDUP(dst, src, cond ? n : strlen(src))
is used on several places among our code. However, we can
move the strlen into virStrndup and thus write just:
VIR_STRNDUP(dst, src, cond ? n : -1)
---
src/util/virstring.c | 7 ++++++-
src/util/virstring.h | 11 ++++++++---
tests/virstringtest.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/src/util/virstring.c b/src/util/virstring.c
index fcbb375..b244e6c 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -568,12 +568,15 @@ virStrdup(char **dest,
* caller's body where virStrndup is called from. Consider
* using VIR_STRNDUP which sets these automatically.
*
+ * In case @n is smaller than zero, the whole @src string is
+ * copied.
+ *
* Returns: 0 for NULL src, 1 on successful copy, -1 otherwise.
*/
int
virStrndup(char **dest,
const char *src,
- size_t n,
+ ssize_t n,
bool report,
int domcode,
const char *filename,
@@ -582,6 +585,8 @@ virStrndup(char **dest,
{
if (!src)
return 0;
+ if (n < 0)
+ n = strlen(src);
if (!(*dest = strndup(src, n))) {
if (report)
virReportOOMErrorFull(domcode, filename, funcname, linenr);
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 534ce91..7063fe4 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -93,7 +93,7 @@ int virStrdup(char **dest, const char *src, bool report, int domcode,
const char *filename, const char *funcname, size_t linenr)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1);
-int virStrndup(char **dest, const char *src, size_t n, bool report, int domcode,
+int virStrndup(char **dest, const char *src, ssize_t n, bool report, int domcode,
const char *filename, const char *funcname, size_t linenr)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1);
@@ -132,7 +132,9 @@ int virStrndup(char **dest, const char *src, size_t n, bool report, int domcode,
* @n: the maximum number of bytes to copy
*
* Duplicate @src string and store it into @dst. If @src is longer than @n,
- * only @n bytes are copied and terminating null byte '\0' is added.
+ * only @n bytes are copied and terminating null byte '\0' is added. If @n
+ * is a negative number, then the whole @src string is copied. That is
+ * VIR_STRDUP(dst, src) and VIR_STRNDUP(dst, src, -1) are equal.
*
* This macro is safe to use on arguments with side effects.
*
@@ -150,7 +152,10 @@ int virStrndup(char **dest, const char *src, size_t n, bool report, int domcode,
* @n: the maximum number of bytes to copy
*
* Duplicate @src string and store it into @dst. If @src is longer than @n,
- * only @n bytes are copied and terminating null byte '\0' is added.
+ * only @n bytes are copied and terminating null byte '\0' is added. If @n
+ * is a negative number, then the whole @src string is copied. That is
+ * VIR_STRDUP_QUIET(dst, src) and VIR_STRNDUP_QUIET(dst, src, -1) are
+ * equal.
*
* This macro is safe to use on arguments with side effects.
*
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index da06c0f..3d0b55b 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -196,6 +196,39 @@ cleanup:
return ret;
}
+static int
+testStrndupNegative(const void *opaque ATTRIBUTE_UNUSED)
+{
+ int ret = -1;
+ char *dst;
+ const char *src = "Hello world";
+ int value;
+
+ if ((value = VIR_STRNDUP(dst, src, 5)) != 1) {
+ fprintf(stderr, "unexpected virStrndup result %d, expected 1\n", value);
+ goto cleanup;
+ }
+
+ if (STRNEQ_NULLABLE(dst, "Hello")) {
+ fprintf(stderr, "unexpected content '%s'", dst);
+ goto cleanup;
+ }
+
+ if ((value = VIR_STRNDUP(dst, src, -1)) != 1) {
+ fprintf(stderr, "unexpected virStrndup result %d, expected 1\n", value);
+ goto cleanup;
+ }
+
+ if (STRNEQ_NULLABLE(dst, src)) {
+ fprintf(stderr, "unexpected content '%s'", dst);
+ goto cleanup;
+ }
+
+ ret = 0;
+cleanup:
+ VIR_FREE(dst);
+ return ret;
+}
static int
mymain(void)
@@ -245,6 +278,9 @@ mymain(void)
if (virtTestRun("strdup", 1, testStrdup, NULL) < 0)
ret = -1;
+ if (virtTestRun("strdup", 1, testStrndupNegative, NULL) < 0)
+ ret = -1;
+
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH v2] Fix blkdeviotune for shutoff domain
by Martin Kletzander
Function qemuDomainSetBlockIoTune() was checking QEMU capabilities
even when !(flags & VIR_DOMAIN_AFFECT_LIVE) and the domain was
shutoff, resulting in the following problem:
virsh # domstate asdf; blkdeviotune asdf vda --write-bytes-sec 100
shut off
error: Unable to change block I/O throttle
error: unsupported configuration: block I/O throttling not supported with this QEMU binary
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=965016
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
Moved the job starting before anything happens
src/qemu/qemu_driver.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3df26b8..4a76f14 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13918,26 +13918,17 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom)))
return -1;
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
priv = vm->privateData;
cfg = virQEMUDriverGetConfig(driver);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto cleanup;
-
- if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("block I/O throttling not supported with this "
- "QEMU binary"));
- goto cleanup;
- }
-
- device = qemuDiskPathToAlias(vm, disk, &idx);
- if (!device) {
- goto cleanup;
- }
+ goto endjob;
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
- goto cleanup;
+ if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
+ goto endjob;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0)
@@ -13987,6 +13978,13 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("block I/O throttling not supported with this "
+ "QEMU binary"));
+ goto endjob;
+ }
+
/* If the user didn't specify bytes limits, inherit previous
* values; likewise if the user didn't specify iops
* limits. */
@@ -14011,9 +14009,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef);
- idx = virDomainDiskIndexByName(persistentDef, disk, true);
- if (idx < 0)
- goto endjob;
oldinfo = &persistentDef->disks[idx]->blkdeviotune;
if (!set_bytes) {
info.total_bytes_sec = oldinfo->total_bytes_sec;
@@ -14035,7 +14030,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
}
endjob:
- if (qemuDomainObjEndJob(driver, vm) == 0)
+ if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH] nwfilter: Remove error report in virNWFilterDHCPSnoopEnd
by Stefan Berger
Remove error reporting when calling the virNWFilterDHCPSnoopEnd
function with an interface for which no thread is snooping traffic.
Document the usage of this function.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/nwfilter/nwfilter_dhcpsnoop.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
Index: libvirt/src/nwfilter/nwfilter_dhcpsnoop.c
===================================================================
--- libvirt.orig/src/nwfilter/nwfilter_dhcpsnoop.c
+++ libvirt/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -2117,6 +2117,16 @@ err_exit:
return -1;
}
+/**
+ * End a DHCP snoop thread on the given interface or end all
+ * DHCP snoop threads.
+ *
+ * @ifname: Name of an interface or NULL to stop all snoop threads
+ *
+ * It is not an error to call this function with an interface name
+ * for which no thread is snooping traffic. In this case the call will
+ * be a no-op.
+ */
void
virNWFilterDHCPSnoopEnd(const char *ifname)
{
@@ -2130,11 +2140,8 @@ virNWFilterDHCPSnoopEnd(const char *ifna
if (ifname) {
ifkey = (char *)virHashLookup(virNWFilterSnoopState.ifnameToKey,
ifname);
- if (!ifkey) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("ifname \"%s\" not in key map"), ifname);
+ if (!ifkey)
goto cleanup;
- }
ignore_value(virHashRemoveEntry(virNWFilterSnoopState.ifnameToKey,
ifname));
11 years, 6 months
[libvirt] [PATCH] cgroups: Do not enforce nonexistent controllers
by Viktor Mihajlovski
Currently, the controllers argument to virCgroupDetect acts both as
a result filter and a required controller specification, which is
a bit overloaded. If both functionalities are needed, it would be
better to have them seperated into a filter and a requirement mask.
The only situation where it is used today is to ensure that only
CPU related controllers are used for the VCPU directories. But here
we clearly do not want to enforce the existence of cpu, cpuacct and
specifically not cpuset at the same time.
This commit changes the semantics of controllers to "filter only".
Should a required mask ever be needed, more work will have to be done.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/util/vircgroup.c | 8 ++++----
tests/vircgrouptest.c | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index cc144a5..4fe0944 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -375,18 +375,18 @@ static int virCgroupDetect(virCgroupPtr group,
}
if (controllers >= 0) {
- VIR_DEBUG("Validating controllers %d", controllers);
+ VIR_DEBUG("Filtering controllers %d", controllers);
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'",
virCgroupControllerTypeToString(i),
(1 << i) & controllers ? "yes" : "no",
NULLSTR(group->controllers[i].mountPoint));
if (((1 << i) & controllers)) {
- /* Ensure requested controller is present */
+ /* Remove non-existent controllers */
if (!group->controllers[i].mountPoint) {
- VIR_DEBUG("Requested controlled '%s' not mounted",
+ VIR_DEBUG("Requested controller '%s' not mounted, ignoring",
virCgroupControllerTypeToString(i));
- return -ENOENT;
+ controllers &= ~(1 << i);
}
} else {
/* Check whether a request to disable a controller
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index b00a187..262eb8b 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -176,7 +176,7 @@ static int testCgroupNewForDriver(const void *args ATTRIBUTE_UNUSED)
/* Asking for impossible combination since devices is not mounted */
if ((rv = virCgroupNewDriver("lxc", true,
(1 << VIR_CGROUP_CONTROLLER_DEVICES),
- &cgroup)) != -ENOENT) {
+ &cgroup)) != -ENXIO) {
fprintf(stderr, "Should not have created LXC cgroup: %d\n", -rv);
goto cleanup;
}
@@ -280,7 +280,7 @@ static int testCgroupNewForPartition(const void *args ATTRIBUTE_UNUSED)
/* Asking for impossible combination since devices is not mounted */
if ((rv = virCgroupNewPartition("/virtualmachines", true,
(1 << VIR_CGROUP_CONTROLLER_DEVICES),
- &cgroup)) != -ENOENT) {
+ &cgroup)) != -ENXIO) {
fprintf(stderr, "Should not have created /virtualmachines cgroup: %d\n", -rv);
goto cleanup;
}
--
1.7.9.5
11 years, 6 months
[libvirt] [PATCH] Fix blkdeviotune for shutoff domain
by Martin Kletzander
Function qemuDomainSetBlockIoTune() was creating job and checking QEMU
capabilities even when !(flags & VIR_DOMAIN_AFFECT_LIVE) and the
domain was shutoff. Fix this with a little cleanup.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=965016
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_driver.c | 52 ++++++++++++++++++++++----------------------------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3df26b8..49432f0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13921,27 +13921,12 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
priv = vm->privateData;
cfg = virQEMUDriverGetConfig(driver);
- if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto cleanup;
-
- if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("block I/O throttling not supported with this "
- "QEMU binary"));
- goto cleanup;
- }
-
- device = qemuDiskPathToAlias(vm, disk, &idx);
- if (!device) {
- goto cleanup;
- }
-
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0)
- goto endjob;
+ goto cleanup;
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
@@ -13976,17 +13961,30 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
(info.total_bytes_sec && info.write_bytes_sec)) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("total and read/write of bytes_sec cannot be set at the same time"));
- goto endjob;
+ goto cleanup;
}
if ((info.total_iops_sec && info.read_iops_sec) ||
(info.total_iops_sec && info.write_iops_sec)) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("total and read/write of iops_sec cannot be set at the same time"));
- goto endjob;
+ goto cleanup;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("block I/O throttling not supported with this "
+ "QEMU binary"));
+ goto cleanup;
+ }
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
/* If the user didn't specify bytes limits, inherit previous
* values; likewise if the user didn't specify iops
* limits. */
@@ -14004,16 +14002,16 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, &info);
qemuDomainObjExitMonitor(driver, vm);
- if (ret < 0)
- goto endjob;
+ if (ret < 0) {
+ if (!qemuDomainObjEndJob(driver, vm))
+ vm = NULL;
+ goto cleanup;
+ }
vm->def->disks[idx]->blkdeviotune = info;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef);
- idx = virDomainDiskIndexByName(persistentDef, disk, true);
- if (idx < 0)
- goto endjob;
oldinfo = &persistentDef->disks[idx]->blkdeviotune;
if (!set_bytes) {
info.total_bytes_sec = oldinfo->total_bytes_sec;
@@ -14030,14 +14028,10 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (ret < 0) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Write to config file failed"));
- goto endjob;
+ goto cleanup;
}
}
-endjob:
- if (qemuDomainObjEndJob(driver, vm) == 0)
- vm = NULL;
-
cleanup:
VIR_FREE(device);
if (vm)
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH] virsh: Fix regression of vol-resize
by Osier Yang
Introduced by commit 1daa4ba33acf. vshCommandOptStringReq returns
0 on *success* or the option is not required && not present, both
are right result. Error out when returning 0 is not correct.
---
tools/virsh-volume.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index a222cca..e16a385 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -1076,7 +1076,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false;
- if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) <= 0)
+ if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
goto cleanup;
virSkipSpaces(&capacityStr);
if (*capacityStr == '-') {
--
1.8.1.4
11 years, 6 months
[libvirt] [PATCH v4 00/13] Introduce VIR_STRDUP
by Michal Privoznik
Previously this aimed on dropping OOM report from almost
everywhere (v1), then just prepare the ground (v2). Now, it just
aims on introducing VIR_STRDUP and VIR_STRNDUP which do report
OOM error. This will cause rebase conflicts, for sure. Sorry.
Patches available at:
git://gitorious.org/~zippy2/libvirt/michal-staging.git
branch oom5
Michal Privoznik (13):
Adapt to VIR_STRDUP and VIR_STRNDUP in src/conf/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/openvz/*
Change virConnectDomainEventGraphicsCallback signature
_virConnectCredential: turn @prompt into char *
Adapt to VIR_STRDUP and VIR_STRNDUP in src/qemu/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/remote/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/rpc/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/security/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/util/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/xen/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/xenapi/*
Adapt to VIR_STRDUP and VIR_STRNDUP in src/xenxs/*
Introduce syntax-check rule to prefer VIR_STRDUP over strdup
cfg.mk | 8 +
include/libvirt/libvirt.h.in | 16 +-
src/conf/capabilities.c | 30 +--
src/conf/cpu_conf.c | 20 +-
src/conf/domain_conf.c | 119 +++--------
src/conf/domain_event.c | 41 ++--
src/conf/node_device_conf.c | 28 ++-
src/conf/nwfilter_conf.c | 17 +-
src/conf/nwfilter_params.c | 34 +---
src/conf/snapshot_conf.c | 11 +-
src/conf/storage_conf.c | 13 +-
src/conf/virchrdev.c | 12 +-
src/openvz/openvz_conf.c | 45 ++--
src/openvz/openvz_driver.c | 29 +--
src/qemu/qemu_capabilities.c | 79 +++-----
src/qemu/qemu_cgroup.c | 4 +-
src/qemu/qemu_command.c | 428 +++++++++++++++------------------------
src/qemu/qemu_conf.c | 64 +++---
src/qemu/qemu_domain.c | 26 +--
src/qemu/qemu_driver.c | 129 ++++--------
src/qemu/qemu_hotplug.c | 15 +-
src/qemu/qemu_migration.c | 17 +-
src/qemu/qemu_monitor_json.c | 63 ++----
src/qemu/qemu_monitor_text.c | 15 +-
src/qemu/qemu_process.c | 64 +++---
src/remote/remote_driver.c | 116 ++++-------
src/rpc/gendispatch.pl | 21 +-
src/rpc/virnetclient.c | 16 +-
src/rpc/virnetmessage.c | 27 ++-
src/rpc/virnetsaslcontext.c | 6 +-
src/rpc/virnetserver.c | 6 +-
src/rpc/virnetserverclient.c | 10 +-
src/rpc/virnetservermdns.c | 6 +-
src/rpc/virnetsocket.c | 10 +-
src/rpc/virnetsshsession.c | 78 ++++---
src/rpc/virnettlscontext.c | 26 +--
src/security/security_apparmor.c | 20 +-
src/security/security_dac.c | 21 +-
src/security/security_nop.c | 7 +-
src/security/security_selinux.c | 79 ++------
src/security/virt-aa-helper.c | 4 +-
src/util/virauth.c | 17 +-
src/util/virauthconfig.c | 8 +-
src/util/virbitmap.c | 9 +-
src/util/vircgroup.c | 37 ++--
src/util/vircommand.c | 33 ++-
src/util/virconf.c | 34 +---
src/util/virdnsmasq.c | 22 +-
src/util/virebtables.c | 34 ++--
src/util/virebtables.h | 2 +-
src/util/virerror.c | 19 +-
src/util/virfile.c | 28 ++-
src/util/virhash.c | 5 +-
src/util/viridentity.c | 14 +-
src/util/virinitctl.c | 4 +-
src/util/viriptables.c | 4 +-
src/util/virjson.c | 18 +-
src/util/virkeyfile.c | 13 +-
src/util/virlockspace.c | 25 +--
src/util/virlog.c | 27 +--
src/util/virnetdevmacvlan.c | 16 +-
src/util/virnetdevtap.c | 11 +-
src/util/virnetdevvportprofile.c | 4 +-
src/util/virobject.c | 16 +-
src/util/virpci.c | 13 +-
src/util/virscsi.c | 6 +-
src/util/virsexpr.c | 37 +---
src/util/virsocketaddr.c | 9 +-
src/util/virstoragefile.c | 18 +-
src/util/virstring.c | 17 +-
src/util/virsysinfo.c | 293 +++++++++++----------------
src/util/virtypedparam.c | 14 +-
src/util/viruri.c | 58 +++---
src/util/virutil.c | 57 ++----
src/util/virxml.c | 5 +-
src/xen/block_stats.c | 16 +-
src/xen/xen_driver.c | 9 +-
src/xen/xen_hypervisor.c | 19 +-
src/xen/xen_inotify.c | 15 +-
src/xen/xend_internal.c | 68 ++-----
src/xen/xm_internal.c | 9 +-
src/xen/xs_internal.c | 44 ++--
src/xenapi/xenapi_driver.c | 59 +++---
src/xenapi/xenapi_utils.c | 39 ++--
src/xenxs/xen_sxpr.c | 200 ++++++++----------
src/xenxs/xen_xm.c | 91 ++++-----
86 files changed, 1244 insertions(+), 2032 deletions(-)
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH] virCgroupAddTaskStrController: s/-1/-ENOMEM/
by Michal Privoznik
Within whole vircgroup.c we 'return -errno', e.g. 'return -ENOMEM'.
However, in this specific function virCgroupAddTaskStrController
we weren't returning -ENOMEM but -1 despite fact that later in
the function we are returning one of errno values indeed.
---
Notes:
Pushing under trivial rule. This change has been sort of ACKed
previously though:
https://www.redhat.com/archives/libvir-list/2013-May/msg01731.html
However, Eric suggested to be pushed as a separate patch.
src/util/vircgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index cc144a5..13b7332 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1028,7 +1028,7 @@ static int virCgroupAddTaskStrController(virCgroupPtr group,
char *endp;
if (!(str = strdup(pidstr)))
- return -1;
+ return -ENOMEM;
cur = str;
while (*cur != '\0') {
--
1.8.2.1
11 years, 6 months
[libvirt] [libvirt-sandbox][PATCH] Add missing get_unit_path function into class Container
by Alex Jia
RHBZ:https://bugzilla.redhat.com/show_bug.cgi?id=966307
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
With the patch, we can successfully clone an existing Secure container,
but I met a Warning, I think it may be a LibvirtGObject question,
# virt-sandbox-service clone http1 clonebox
Created sandbox container dir /var/lib/libvirt/filesystems/clonebox
Created unit file /etc/libvirt-sandbox/services/clonebox.sandbox
/usr/lib64/python2.7/site-packages/gi/types.py:47: Warning: g_key_file_set_string: assertion `string != NULL' failed
return info.invoke(*args, **kwargs)
Created sandbox config /etc/libvirt-sandbox/services/clonebox.sandbox
bin/virt-sandbox-service | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index 4496b29..2595ea2 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -60,6 +60,7 @@ class Container:
DEFAULT_PATH = "/var/lib/libvirt/filesystems"
DEFAULT_IMAGE = "/var/lib/libvirt/images/%s.raw"
SELINUX_FILE_TYPE = "svirt_lxc_file_t"
+ DEFAULT_UNIT = "/etc/systemd/system/%s_sandbox.service"
def __init__(self, name=None, uri = "lxc:///", path = DEFAULT_PATH, config=None, create=False):
self.uri = uri
@@ -132,6 +133,11 @@ class Container:
name = self.get_name()
return self.DEFAULT_IMAGE % name
+ def get_unit_path(self, name = None):
+ if not name:
+ name = self.get_name()
+ return self.DEFAULT_UNIT % name
+
def set_image(self, size):
self.use_image = True
self.size = size * MB
--
1.7.1
11 years, 6 months
[libvirt] [PATCH] xen: Resolve Coverity FORWARD_NULL issue
by John Ferlan
Commit '18b14012' refactored the Xen code resulting in a Coverity
warning about possible NULL reference if the path where the XM driver
takes puts the def on it's list. Moved/duplicated the virGetDomain()
call to pacify the possible NULL deref.
NOTE: I did ping Dan B, but he is away, so rather than wait or take
the chance this ends up in the upcoming release, I made the change.
---
src/xen/xen_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index cc6e486..9eab3fc 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1658,13 +1658,14 @@ xenUnifiedDomainDefineXML(virConnectPtr conn, const char *xml)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (xenXMDomainDefineXML(conn, def) < 0)
goto cleanup;
+ ret = virGetDomain(conn, def->name, def->uuid);
def = NULL; /* XM driver owns it now */
} else {
if (xenDaemonDomainDefineXML(conn, def) < 0)
goto cleanup;
+ ret = virGetDomain(conn, def->name, def->uuid);
}
- ret = virGetDomain(conn, def->name, def->uuid);
if (ret)
ret->id = -1;
--
1.8.1.4
11 years, 6 months