forked from QubesOS/qubes-core-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update multiple IP address patch to the upstream accepted version
This include fix for memory leak. QubesOS/qubes-issues#718
- Loading branch information
Showing
3 changed files
with
129 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,58 @@ | ||
From 1afa40a1e5ea51a016ae2e6bf7be8f2e525154f5 Mon Sep 17 00:00:00 2001 | ||
Message-Id: <1afa40a1e5ea51a016ae2e6bf7be8f2e525154f5.1512152064.git-series.marmarek@invisiblethingslab.com> | ||
From: Marek Marczykowski-Górecki <[email protected]> | ||
Date: Fri, 1 Dec 2017 15:07:32 +0100 | ||
Subject: [PATCH 1/2] libxl: add support for multiple IP addresses | ||
From 82ef04fe79751ba98f48e220b7c2e9366935449a Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= | ||
<[email protected]> | ||
Date: Thu, 7 Dec 2017 03:27:45 +0100 | ||
Subject: [PATCH] libxl: add support for multiple IP addresses | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
Organization: Invisible Things Lab | ||
Cc: Marek Marczykowski-Górecki <[email protected]> | ||
|
||
vif-* scripts support it for a long time, and expect addresses to be | ||
separated by spaces. Add appropriate support to libxl driver. | ||
|
||
Reviewed-by: Jim Fehlig <[email protected]> | ||
Signed-off-by: Marek Marczykowski-Górecki <[email protected]> | ||
--- | ||
src/libxl/libxl_conf.c | 29 +++++++++++++++++++++++++++-- | ||
src/libxl/libxl_domain.c | 12 ------------ | ||
2 files changed, 27 insertions(+), 14 deletions(-) | ||
src/libxl/libxl_conf.c | 5 +++-- | ||
src/libxl/libxl_domain.c | 12 ------------ | ||
src/xenconfig/xen_common.c | 24 ++++++++++++++++++++++++ | ||
src/xenconfig/xen_common.h | 1 + | ||
4 files changed, 28 insertions(+), 14 deletions(-) | ||
|
||
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c | ||
index 2a9be69..f84ffc6 100644 | ||
index 2a9be6967..970cff205 100644 | ||
--- a/src/libxl/libxl_conf.c | ||
+++ b/src/libxl/libxl_conf.c | ||
@@ -1067,6 +1067,31 @@ libxlUpdateDiskDef(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk) | ||
ignore_value(virDomainDiskSetDriver(l_disk, driver)); | ||
} | ||
@@ -49,6 +49,7 @@ | ||
#include "virstoragefile.h" | ||
#include "secret_util.h" | ||
#include "cpu/cpu.h" | ||
+#include "xen_common.h" | ||
|
||
+static char * | ||
+libxlMakeIPList(virNetDevIPInfoPtr guestIP) | ||
+{ | ||
+ size_t i; | ||
+ char **address_array; | ||
+ char *ret = NULL; | ||
+ | ||
+ if (VIR_ALLOC_N(address_array, guestIP->nips + 1) < 0) | ||
+ return NULL; | ||
+ | ||
+ for (i = 0; i < guestIP->nips; i++) { | ||
+ address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address); | ||
+ if (!address_array[i]) | ||
+ goto cleanup; | ||
+ } | ||
+ address_array[guestIP->nips] = NULL; | ||
+ | ||
+ ret = virStringListJoin((const char**)address_array, " "); | ||
+ | ||
+ cleanup: | ||
+ while (i > 0) | ||
+ VIR_FREE(address_array[--i]); | ||
+ return ret; | ||
+} | ||
+ | ||
int | ||
libxlMakeNic(virDomainDefPtr def, | ||
virDomainNetDefPtr l_nic, | ||
@@ -1144,7 +1169,7 @@ libxlMakeNic(virDomainDefPtr def, | ||
|
||
#define VIR_FROM_THIS VIR_FROM_LIBXL | ||
@@ -1144,7 +1145,7 @@ libxlMakeNic(virDomainDefPtr def, | ||
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0) | ||
goto cleanup; | ||
if (l_nic->guestIP.nips > 0) { | ||
- x_nic->ip = virSocketAddrFormat(&l_nic->guestIP.ips[0]->address); | ||
+ x_nic->ip = libxlMakeIPList(&l_nic->guestIP); | ||
+ x_nic->ip = xenMakeIPList(&l_nic->guestIP); | ||
if (!x_nic->ip) | ||
goto cleanup; | ||
} | ||
@@ -1160,7 +1185,7 @@ libxlMakeNic(virDomainDefPtr def, | ||
@@ -1160,7 +1161,7 @@ libxlMakeNic(virDomainDefPtr def, | ||
} | ||
|
||
if (l_nic->guestIP.nips > 0) { | ||
- x_nic->ip = virSocketAddrFormat(&l_nic->guestIP.ips[0]->address); | ||
+ x_nic->ip = libxlMakeIPList(&l_nic->guestIP); | ||
+ x_nic->ip = xenMakeIPList(&l_nic->guestIP); | ||
if (!x_nic->ip) | ||
goto cleanup; | ||
} | ||
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c | ||
index d054b07..395c8a9 100644 | ||
index d054b0762..395c8a921 100644 | ||
--- a/src/libxl/libxl_domain.c | ||
+++ b/src/libxl/libxl_domain.c | ||
@@ -294,18 +294,6 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, | ||
|
@@ -88,7 +74,53 @@ index d054b07..395c8a9 100644 | |
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV || | ||
(dev->type == VIR_DOMAIN_DEVICE_NET && | ||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) { | ||
|
||
base-commit: 9f0ccc717ba9026c30ce38951a354dd66fa12e3b | ||
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c | ||
index ded0acab9..7f838b65e 100644 | ||
--- a/src/xenconfig/xen_common.c | ||
+++ b/src/xenconfig/xen_common.c | ||
@@ -1166,6 +1166,30 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial) | ||
return -1; | ||
} | ||
|
||
+char * | ||
+xenMakeIPList(virNetDevIPInfoPtr guestIP) | ||
+{ | ||
+ size_t i; | ||
+ char **address_array; | ||
+ char *ret = NULL; | ||
+ | ||
+ if (VIR_ALLOC_N(address_array, guestIP->nips + 1) < 0) | ||
+ return NULL; | ||
+ | ||
+ for (i = 0; i < guestIP->nips; i++) { | ||
+ address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address); | ||
+ if (!address_array[i]) | ||
+ goto cleanup; | ||
+ } | ||
+ address_array[guestIP->nips] = NULL; | ||
+ | ||
+ ret = virStringListJoin((const char**)address_array, " "); | ||
+ | ||
+ cleanup: | ||
+ while (i > 0) | ||
+ VIR_FREE(address_array[--i]); | ||
+ return ret; | ||
+} | ||
|
||
static int | ||
xenFormatNet(virConnectPtr conn, | ||
diff --git a/src/xenconfig/xen_common.h b/src/xenconfig/xen_common.h | ||
index 905569299..3b7a5db4f 100644 | ||
--- a/src/xenconfig/xen_common.h | ||
+++ b/src/xenconfig/xen_common.h | ||
@@ -67,6 +67,7 @@ int xenFormatConfigCommon(virConfPtr conf, | ||
virConnectPtr conn, | ||
const char *nativeFormat); | ||
|
||
+char *xenMakeIPList(virNetDevIPInfoPtr guestIP); | ||
|
||
int xenDomainDefAddImplicitInputDevice(virDomainDefPtr def); | ||
|
||
-- | ||
git-series 0.9.1 | ||
2.13.6 | ||
|
48 changes: 48 additions & 0 deletions
48
patches.qubes/0026-xenMakeIPList-Don-t-leak-address_array.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From 34fb67efae1d0ab2bd7f6177308061c0970b8486 Mon Sep 17 00:00:00 2001 | ||
From: Michal Privoznik <[email protected]> | ||
Date: Tue, 12 Dec 2017 15:00:15 +0100 | ||
Subject: [PATCH] xenMakeIPList: Don't leak @address_array | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
Organization: Invisible Things Lab | ||
Cc: Marek Marczykowski-Górecki <[email protected]> | ||
|
||
==32171== 32 bytes in 1 blocks are definitely lost in loss record 44 of 107 | ||
==32171== at 0x4C2DEF6: calloc (vg_replace_malloc.c:711) | ||
==32171== by 0x55744A9: virAllocN (viralloc.c:191) | ||
==32171== by 0x12CED2: xenMakeIPList (xen_common.c:1186) | ||
==32171== by 0x12D0BE: xenFormatNet (xen_common.c:1221) | ||
==32171== by 0x12F0D2: xenFormatVif (xen_common.c:1889) | ||
==32171== by 0x12F2B4: xenFormatConfigCommon (xen_common.c:1944) | ||
==32171== by 0x13BA32: xenFormatXL (xen_xl.c:1971) | ||
==32171== by 0x1186CA: testCompareParseXML (xlconfigtest.c:105) | ||
==32171== by 0x118A64: testCompareHelper (xlconfigtest.c:205) | ||
==32171== by 0x119E36: virTestRun (testutils.c:180) | ||
==32171== by 0x11970E: mymain (xlconfigtest.c:301) | ||
==32171== by 0x11BEE3: virTestMain (testutils.c:1119) | ||
|
||
Signed-off-by: Michal Privoznik <[email protected]> | ||
Reviewed-by: John Ferlan <[email protected]> | ||
Signed-off-by: Marek Marczykowski-Górecki <[email protected]> | ||
--- | ||
src/xenconfig/xen_common.c | 3 +-- | ||
1 file changed, 1 insertion(+), 2 deletions(-) | ||
|
||
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c | ||
index 40b148321..ff0df5fb7 100644 | ||
--- a/src/xenconfig/xen_common.c | ||
+++ b/src/xenconfig/xen_common.c | ||
@@ -1196,8 +1196,7 @@ xenMakeIPList(virNetDevIPInfoPtr guestIP) | ||
ret = virStringListJoin((const char**)address_array, " "); | ||
|
||
cleanup: | ||
- while (i > 0) | ||
- VIR_FREE(address_array[--i]); | ||
+ virStringListFree(address_array); | ||
return ret; | ||
} | ||
|
||
-- | ||
2.13.6 | ||
|