[libvirt] [PATCH] util: clang is failing due to unused variables.
by Julio Faracco
After some recent patches, clang is throwing some errors related to
unused variables. This is not happening when we use GCC with -Werror
enabled. Only clang reports this warning.
make[3]: Entering directory '/home/julio/Desktop/virt/libvirt/src'
CC util/libvirt_util_la-virscsivhost.lo
CC util/libvirt_util_la-virusb.lo
CC util/libvirt_util_la-virmdev.lo
util/virmdev.c:373:36: error: unused variable 'ret' [-Werror,-Wunused-variable]
VIR_AUTOPTR(virMediatedDevice) ret = virMediatedDeviceListSteal(list, dev);
^
1 error generated.
Makefile:11579: recipe for target 'util/libvirt_util_la-virmdev.lo' failed
make[3]: *** [util/libvirt_util_la-virmdev.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
util/virscsivhost.c:112:37: error: unused variable 'tmp' [-Werror,-Wunused-variable]
VIR_AUTOPTR(virSCSIVHostDevice) tmp = virSCSIVHostDeviceListSteal(list, dev);
^
1 error generated.
Makefile:11411: recipe for target 'util/libvirt_util_la-virscsivhost.lo' failed
make[3]: *** [util/libvirt_util_la-virscsivhost.lo] Error 1
util/virusb.c:511:31: error: unused variable 'ret' [-Werror,-Wunused-variable]
VIR_AUTOPTR(virUSBDevice) ret = virUSBDeviceListSteal(list, dev);
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/util/virmdev.c | 3 ++-
src/util/virscsivhost.c | 3 ++-
src/util/virusb.c | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 4050835cc1..63df4e40d8 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -370,7 +370,8 @@ void
virMediatedDeviceListDel(virMediatedDeviceListPtr list,
virMediatedDevicePtr dev)
{
- VIR_AUTOPTR(virMediatedDevice) ret = virMediatedDeviceListSteal(list, dev);
+ VIR_AUTOPTR(virMediatedDevice) ret ATTRIBUTE_UNUSED
+ = virMediatedDeviceListSteal(list, dev);
}
diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index 280d0dc2fd..e07cd46ba9 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -109,7 +109,8 @@ void
virSCSIVHostDeviceListDel(virSCSIVHostDeviceListPtr list,
virSCSIVHostDevicePtr dev)
{
- VIR_AUTOPTR(virSCSIVHostDevice) tmp = virSCSIVHostDeviceListSteal(list, dev);
+ VIR_AUTOPTR(virSCSIVHostDevice) tmp ATTRIBUTE_UNUSED
+ = virSCSIVHostDeviceListSteal(list, dev);
}
diff --git a/src/util/virusb.c b/src/util/virusb.c
index 609d54836f..73a1041097 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -508,7 +508,8 @@ void
virUSBDeviceListDel(virUSBDeviceListPtr list,
virUSBDevicePtr dev)
{
- VIR_AUTOPTR(virUSBDevice) ret = virUSBDeviceListSteal(list, dev);
+ VIR_AUTOPTR(virUSBDevice) ret ATTRIBUTE_UNUSED
+ = virUSBDeviceListSteal(list, dev);
}
virUSBDevicePtr
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] audit: Share virtType fallback logic
by Cole Robinson
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/conf/domain_audit.c | 91 +++++++++++++----------------------------
1 file changed, 28 insertions(+), 63 deletions(-)
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index d9be638f05..fc13338d64 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -68,6 +68,21 @@ virDomainAuditGetRdev(const char *path ATTRIBUTE_UNUSED)
#endif
+static const char *
+virDomainAuditGetVirtType(virDomainDefPtr def)
+{
+ const char *virt;
+
+ if (!(virt = virDomainVirtTypeToString(def->virtType))) {
+ VIR_WARN("Unexpected virt type %d while encoding audit message",
+ def->virtType);
+ virt = "?";
+ }
+
+ return virt;
+}
+
+
static void
virDomainAuditGenericDev(virDomainObjPtr vm,
const char *type,
@@ -82,7 +97,7 @@ virDomainAuditGenericDev(virDomainObjPtr vm,
char *vmname = NULL;
char *oldsrc = NULL;
char *newsrc = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
/* if both new and old source aren't provided don't log anything */
if (!newsrcpath && !oldsrcpath)
@@ -99,12 +114,6 @@ virDomainAuditGenericDev(virDomainObjPtr vm,
if (!(vmname = virAuditEncode("vm", vm->def->name)))
goto no_memory;
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message",
- vm->def->virtType);
- virt = "?";
- }
-
if (!(newsrc = virAuditEncode(newdev, VIR_AUDIT_STR(newsrcpath))))
goto no_memory;
@@ -312,7 +321,7 @@ virDomainAuditNetDevice(virDomainDefPtr vmDef, virDomainNetDefPtr netDef,
char *vmname;
char *dev_name = NULL;
char *rdev;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vmDef);
virUUIDFormat(vmDef->uuid, uuidstr);
virMacAddrFormat(&netDef->mac, macstr);
@@ -324,11 +333,6 @@ virDomainAuditNetDevice(virDomainDefPtr vmDef, virDomainNetDefPtr netDef,
goto cleanup;
}
- if (!(virt = virDomainVirtTypeToString(vmDef->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vmDef->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
"virt=%s resrc=net reason=open %s uuid=%s net=%s %s rdev=%s",
virt, vmname, uuidstr, macstr, dev_name, VIR_AUDIT_STR(rdev));
@@ -356,7 +360,8 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
char *vmname;
char *address = NULL;
char *device = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
+
virDomainHostdevSubsysUSBPtr usbsrc = &hostdev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
@@ -369,11 +374,6 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
switch ((virDomainHostdevMode) hostdev->mode) {
case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
@@ -509,7 +509,7 @@ virDomainAuditRedirdev(virDomainObjPtr vm, virDomainRedirdevDefPtr redirdev,
char *vmname;
char *address = NULL;
char *device = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
@@ -517,11 +517,6 @@ virDomainAuditRedirdev(virDomainObjPtr vm, virDomainRedirdevDefPtr redirdev,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
switch (redirdev->bus) {
case VIR_DOMAIN_REDIRDEV_BUS_USB:
if (VIR_STRDUP_QUIET(address, "USB redirdev") < 0) {
@@ -571,7 +566,7 @@ virDomainAuditTPM(virDomainObjPtr vm, virDomainTPMDefPtr tpm,
char *vmname;
char *path = NULL;
char *device = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
@@ -579,11 +574,6 @@ virDomainAuditTPM(virDomainObjPtr vm, virDomainTPMDefPtr tpm,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
path = tpm->data.passthrough.source.data.file.path;
@@ -639,7 +629,7 @@ virDomainAuditCgroup(virDomainObjPtr vm, virCgroupPtr cgroup,
char *vmname;
char *controller = NULL;
char *detail;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
@@ -647,11 +637,6 @@ virDomainAuditCgroup(virDomainObjPtr vm, virCgroupPtr cgroup,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
ignore_value(virCgroupPathOfController(cgroup,
VIR_CGROUP_CONTROLLER_DEVICES,
NULL, &controller));
@@ -757,7 +742,7 @@ virDomainAuditResource(virDomainObjPtr vm, const char *resource,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
@@ -765,11 +750,6 @@ virDomainAuditResource(virDomainObjPtr vm, const char *resource,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
"virt=%s resrc=%s reason=%s %s uuid=%s old-%s=%lld new-%s=%lld",
virt, resource, reason, vmname, uuidstr,
@@ -809,7 +789,7 @@ virDomainAuditLifecycle(virDomainObjPtr vm, const char *op,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
@@ -818,11 +798,6 @@ virDomainAuditLifecycle(virDomainObjPtr vm, const char *op,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, success,
"virt=%s op=%s reason=%s %s uuid=%s vm-pid=%lld",
virt, op, reason, vmname, uuidstr, (long long)vm->pid);
@@ -909,7 +884,7 @@ virDomainAuditInit(virDomainObjPtr vm,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
@@ -918,11 +893,6 @@ virDomainAuditInit(virDomainObjPtr vm,
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, true,
"virt=%s op=init %s uuid=%s vm-pid=%lld init-pid=%lld pid-ns=%lld",
virt, vmname, uuidstr, (long long)vm->pid, (long long)initpid,
@@ -942,8 +912,8 @@ virDomainAuditSecurityLabel(virDomainObjPtr vm, bool success)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
size_t i;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
@@ -951,11 +921,6 @@ virDomainAuditSecurityLabel(virDomainObjPtr vm, bool success)
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
for (i = 0; i < vm->def->nseclabels; i++) {
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_ID, success,
"virt=%s %s uuid=%s vm-ctx=%s img-ctx=%s model=%s",
@@ -976,7 +941,7 @@ virDomainAuditShmem(virDomainObjPtr vm,
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname = virAuditEncode("vm", vm->def->name);
const char *srcpath = virDomainChrSourceDefGetPath(&def->server.chr);
- const char *virt = virDomainVirtTypeToString(vm->def->virtType);
+ const char *virt = virDomainAuditGetVirtType(vm->def);
char *shmpath = NULL;
virUUIDFormat(vm->def->uuid, uuidstr);
@@ -1018,7 +983,7 @@ virDomainAuditInput(virDomainObjPtr vm,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt = virDomainVirtTypeToString(vm->def->virtType);
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] virpci: Drop unused @ret in virPCIDeviceListDel
by Michal Privoznik
So after 00dc991ca16730 the function is one line long and the
line is declaring a variable which is never used in fact. Replace
it with actual free() call instead of autofree.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under build breaker rule as this is causing clang to complain.
Huh, who uses that? :-P
src/util/virpci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 634df8d35f..6cf2acf2d1 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2003,7 +2003,7 @@ void
virPCIDeviceListDel(virPCIDeviceListPtr list,
virPCIDevicePtr dev)
{
- VIR_AUTOPTR(virPCIDevice) ret = virPCIDeviceListSteal(list, dev);
+ virPCIDeviceFree(virPCIDeviceListSteal(list, dev));
}
int
--
2.16.4
6 years, 3 months
[libvirt] [PATCH v2 00/41] use GNU C's cleanup attribute in src/util (batch II)
by Sukrit Bhatnagar
This second series of patches also modifies a few files in src/util
to use VIR_AUTOFREE and VIR_AUTOPTR for automatic freeing of memory
and get rid of some VIR_FREE macro invocations and *Free function
calls.
The argument type of virCgroupFree is changed from virCgroupPtr *
to virCgroupPtr and that of virUSBDeviceListAdd is changed to take
a double pointer to virUSBDevice.
Sukrit Bhatnagar (41):
util: error: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: buffer: typedef for struct _virBufferEscapePair
util: buffer: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: buffer: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: buffer: use VIR_AUTOPTR for aggregate types
util: hash: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: cgroup: modify virCgroupFree to take virCgroupPtr
util: cgroup: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: cgroup: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: cgroup: use VIR_AUTOPTR for aggregate types
util: mdev: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: mdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: mdev: use VIR_AUTOPTR for aggregate types
util: firewall: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: firewall: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: firewall: use VIR_AUTOPTR for aggregate types
util: hook: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: hook: use VIR_AUTOPTR for aggregate types
util: pci: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: pci: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: pci: use VIR_AUTOPTR for aggregate types
util: usb: modify virUSBDeviceListAdd to take double pointer
util: usb: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: usb: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: usb: use VIR_AUTOPTR for aggregate types
util: scsi: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: scsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: scsi: use VIR_AUTOPTR for aggregate types
util: scsivhost: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: scsivhost: use VIR_AUTOPTR for aggregate types
util: netdevvlan: define cleanup function using
VIR_DEFINE_AUTOPTR_FUNC
util: hostdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: hostdev: use VIR_AUTOPTR for aggregate types
util: hostmem: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: iptables: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: iscsi: use VIR_AUTOPTR for aggregate types
util: kmod: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: kmod: use VIR_AUTOPTR for aggregate types
util: lease: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: lease: use VIR_AUTOPTR for aggregate types
src/libvirt-lxc.c | 4 +-
src/lxc/lxc_cgroup.c | 4 +-
src/lxc/lxc_container.c | 2 +-
src/lxc/lxc_controller.c | 2 +-
src/lxc/lxc_domain.c | 2 +-
src/lxc/lxc_process.c | 10 +-
src/qemu/qemu_cgroup.c | 16 +-
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_driver.c | 34 +--
src/qemu/qemu_process.c | 2 +-
src/util/virbuffer.c | 38 ++-
src/util/virbuffer.h | 9 +-
src/util/vircgroup.c | 746 +++++++++++++++++------------------------------
src/util/vircgroup.h | 11 +-
src/util/vircgrouppriv.h | 2 +-
src/util/virerror.c | 1 -
src/util/virerror.h | 3 +
src/util/virfirewall.c | 53 ++--
src/util/virfirewall.h | 3 +
src/util/virhash.c | 1 -
src/util/virhash.h | 4 +
src/util/virhook.c | 26 +-
src/util/virhostdev.c | 168 ++++-------
src/util/virhostmem.c | 57 ++--
src/util/viriptables.c | 52 ++--
src/util/viriscsi.c | 89 ++----
src/util/virkmod.c | 38 +--
src/util/virlease.c | 82 ++----
src/util/virmdev.c | 84 ++----
src/util/virmdev.h | 4 +
src/util/virnetdevvlan.c | 1 -
src/util/virnetdevvlan.h | 4 +
src/util/virpci.c | 352 ++++++++--------------
src/util/virpci.h | 7 +
src/util/virscsi.c | 63 ++--
src/util/virscsi.h | 3 +
src/util/virscsivhost.c | 19 +-
src/util/virscsivhost.h | 3 +
src/util/virusb.c | 42 ++-
src/util/virusb.h | 5 +-
tests/vircgrouptest.c | 42 +--
tests/virusbtest.c | 4 +-
42 files changed, 800 insertions(+), 1294 deletions(-)
--
1.8.3.1
6 years, 3 months
[libvirt] [PATCH 0/3] lxc: Simplify virLXCProcessStart a tiny bit
by Michal Privoznik
These are basically follow up patches as suggested by Erik in his
review:
https://www.redhat.com/archives/libvir-list/2018-July/msg01767.html
Michal Prívozník (3):
util: Rework virStringListAdd
lxc: Turn @veths into a string list in virLXCProcessStart
lxc: Use VIR_AUTOPTR for @veths in virLXCProcessStart
src/lxc/lxc_process.c | 25 +++++++++----------------
src/util/virmacmap.c | 8 ++------
src/util/virstring.c | 34 ++++++++++++++--------------------
src/util/virstring.h | 4 ++--
tests/virstringtest.c | 6 +-----
5 files changed, 28 insertions(+), 49 deletions(-)
--
2.16.4
6 years, 3 months
[libvirt] [PATCH] news: Usb and sata for virsh attach-disk --address
by Han Han
Signed-off-by: Han Han <hhan(a)redhat.com>
---
docs/news.xml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml
index fc7924ad5f..a68ef2dc1c 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -76,6 +76,16 @@
using attach-disk or attach-interface commands.
</description>
</change>
+ <change>
+ <summary>
+ virsh: Support usb and sata address to attach-disk
+ </summary>
+ <description>
+ Usb or sata address could be used when attach-disk with --address.
+ For example, use usb address as usb:<bus>.<port>, use
+ sata address as <controller>.<bus>.<unit>.
+ </description>
+ </change>
</section>
<section title="Bug fixes">
</section>
--
2.18.0
6 years, 3 months
[libvirt] [dbus PATCH] gitignore: Ignore Vim swap files
by Andrea Bolognani
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Pushed as trivial.
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index e89a5d3..b4abf66 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
*.log
*.o
*.pyc
+*.swp
*.trs
*Makefile
*Makefile.in
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] lxc: Don't return early in virLXCProcessSetupInterfaces
by Michal Privoznik
There are two places in the loop body that just return instead of
jumping onto the cleanup label. The problem is the cleanup code
is not ran in those cases.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
src/lxc/lxc_process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index d021a890f7..442756a6f1 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -544,7 +544,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
net = def->nets[i];
if (virLXCProcessValidateInterface(net) < 0)
- return -1;
+ goto cleanup;
if (virDomainNetAllocateActualDevice(def, net) < 0)
goto cleanup;
@@ -612,7 +612,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
/* Make sure all net definitions will have a name in the container */
if (!net->ifname_guest) {
if (virAsprintf(&net->ifname_guest, "eth%zu", niface) < 0)
- return -1;
+ goto cleanup;
niface++;
}
}
--
2.16.4
6 years, 3 months
[libvirt] [PATCH RFC 0/2] util: Add VIR_ENUM_IMPL_LABEL
by Cole Robinson
This series adds VIR_ENUM_IMPL_LABEL and a demo conversion.
VIR_ENUM_IMPL_LABEL allows passing in a string that briefly
describes the value the enum represents, which we use to
generate error messages for FromString and ToString
function failures.
This will allow us to drop a lot of code and unique strings
that need translating.
Patch 2 is an example usage, converting virDomainVirtType
enum. It's not a full conversion for this particular enum,
just a demo. The enum creation now looks like
VIR_ENUM_IMPL_LABEL(virDomainVirt,
"domain type",
VIR_DOMAIN_VIRT_LAST, ...
FromString failure reports this error for value 'zzzz'
invalid argument: Unknown 'domain type' value 'zzzz'
ToString failure reports this error for unknown type=83
internal error: Unknown 'domain type' internal value '83'
Seems like a win to me but I'm interested in other opinions.
This could also be a good BiteSizedTask for converting existing
enums
Cole Robinson (2):
util: Add VIR_ENUM_IMPL_LABEL
conf: Convert virDomainVirtType to VIR_ENUM_IMPL_LABEL
src/conf/domain_conf.c | 10 ++--------
src/util/virutil.c | 20 ++++++++++++++++----
src/util/virutil.h | 15 ++++++++++-----
3 files changed, 28 insertions(+), 17 deletions(-)
--
2.17.1
6 years, 3 months