[libvirt] [PATCH v2] Fix Memory Leak in virQEMUCapsInitGuestFromBinary()
by Nehal J Wani
While running qemucaps2xmltest, it was found that valgrind pointed out
the following memory leaks:
==29896== 0 bytes in 1 blocks are definitely lost in loss record 1 of 65
==29896== at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==29896== by 0x4C6B45E: virAllocN (viralloc.c:191)
==29896== by 0x4232A9: virQEMUCapsGetMachineTypesCaps (qemu_capabilities.c:1999)
==29896== by 0x4234E7: virQEMUCapsInitGuestFromBinary (qemu_capabilities.c:789)
==29896== by 0x41F10B: testQemuCapsXML (qemucaps2xmltest.c:118)
==29896== by 0x41FFD1: virtTestRun (testutils.c:201)
==29896== by 0x41EE7A: mymain (qemucaps2xmltest.c:203)
==29896== by 0x42074D: virtTestMain (testutils.c:789)
==29896== by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==29896==
==29896== 0 bytes in 1 blocks are definitely lost in loss record 2 of 65
==29896== at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==29896== by 0x4C6B45E: virAllocN (viralloc.c:191)
==29896== by 0x4232A9: virQEMUCapsGetMachineTypesCaps (qemu_capabilities.c:1999)
==29896== by 0x4234E7: virQEMUCapsInitGuestFromBinary (qemu_capabilities.c:789)
==29896== by 0x41F10B: testQemuCapsXML (qemucaps2xmltest.c:118)
==29896== by 0x41FFD1: virtTestRun (testutils.c:201)
==29896== by 0x41EEA3: mymain (qemucaps2xmltest.c:204)
==29896== by 0x42074D: virtTestMain (testutils.c:789)
==29896== by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
---
src/qemu/qemu_capabilities.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7673592..aef8bc1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -789,6 +789,10 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
if (virQEMUCapsGetMachineTypesCaps(qemubinCaps, &nmachines, &machines) < 0)
goto cleanup;
+ /* Free unneeded memory given by malloc(0) */
+ if (!nmachines)
+ VIR_FREE(machines);
+
/* We register kvm as the base emulator too, since we can
* just give -no-kvm to disable acceleration if required */
if ((guest = virCapabilitiesAddGuest(caps,
--
1.7.1
10 years, 9 months
[libvirt] [TCK] nwfilter tests and libvirt commit 4f209434
by Mike Latimer
Hi,
As I've been looking through libvirt-tck tests, I found that commit 4f209434
(in libvirt) changes a condition that the nwfilter/050-apply-verify-host.t
relies on.
Specifically, the 050-apply-verify-host.t test creates a number of filters with
invalid values (such as dscp='64', and protocol='256'). Without commit
4f209434, these invalid values are silently dropped off the end of the rule, as
in the following example:
#virsh nwfilter-define <xml with illegal value:>
<filter name='tck-testcase'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='in'>
<ip srcipaddr='10.1.2.3' srcipmask='255.255.255.254'
dstipaddr='10.1.2.3' dstipmask='255.255.255.128'
protocol='255' dscp='64'
/>
</rule>
#virsh nwfilter-dumpxml tck-testcase
<rule action='accept' direction='in' priority='500'>
<ip srcipaddr='10.1.2.3' srcipmask='31' dstipaddr='10.1.2.3'
dstipmask='25' protocol='255'/>
</rule>
With commit 4f209434 in place, the entire filter is rejected with the following
error: 'internal error: dscp has illegal value 64'. As the filter is not
created, the testing of that filter by the 050-apply-verify-host test fails.
I agree that the change is the right thing to do, but I'm wondering how best
to handle the now failing tests. This test (050-apply-verify-host.t) runs
~1200 subtests, and about 10% of those tests fail due to the change. I'm
thinking that the illegal options (and only those illegal options) should be
removed from the now broken tests, and a few new tests added to specifically
test for the failure to add the entire rule when illegal data is passed.
Thoughts?
BTW - Is anyone else running the full libvirt-tck suite against recent
versions of libvirt? There are quite a few issues (such as this one) which
should be easily seen...
Thanks,
Mike
10 years, 9 months
[libvirt] [PATCH v4 0/2] fix query-command-line-options
by Amos Kong
This patchset fixed some issues of query-command-line-options:
* some new options that haven't argument can't be queried. (eg: -enable-fips)
* some legacy options that have argument can't be queried. (eg: -vnc display)
More discussion:
http://marc.info/?l=qemu-devel&m=139081830416684&w=2
V2: remove duplicate option tables, update schema (eric)
V3: fix typo in commitlog and export qemu_options talbe (eric)
V4: avoid the duplicate static table (eric)
Amos Kong (2):
qmp: rename query_option_descs() to get_param_infolist()
query-command-line-options: query all the options in qemu-options.hx
qapi-schema.json | 8 ++++++--
qemu-options.h | 10 ++++++++++
util/qemu-config.c | 50 +++++++++++++++++++++++++++++++++++++++++---------
vl.c | 15 ---------------
4 files changed, 57 insertions(+), 26 deletions(-)
--
1.8.5.3
10 years, 9 months
[libvirt] [PATCH] bhyve: add domainLookupByID
by Wojciech Macek
Implement domainLookupByID as required by OpenStack stuff.
Wojciech Macek (1):
bhyve: add domainLookupByID
src/bhyve/bhyve_driver.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
--
1.9.0
10 years, 9 months
[libvirt] [RFC PATCH] Behaviour of topology, vcpus and maxcpus
by Nikunj A Dadhania
I have observed the following with libvirt xml:
<vcpu>6</vcpu>
<cpu>
<topology sockets='1' cores='4' threads='2'/>
</cpu>
So according to the topology maximum supported is 8 vcpus, while the
libvirt sets that to 6 - specified in <vcpu> tag. Shouldn't libvirt
error this out as the mismatch between the topology definition and the
vcpu count?
There is an upper bound check already in place where if we have maxcpu >
topology-supported cpus, that errors out. For eg.
<vcpu>12</vcpu>
<cpu>
<topology sockets='1' cores='4' threads='2'/>
</cpu>
The below patch make sures that libvirt does the lower bound check as
well.
Regards
Nikunj
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f96110b..aa25940 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12933,6 +12933,14 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error;
}
+ if (def->cpu->sockets &&
+ def->maxvcpus <
+ def->cpu->sockets * def->cpu->cores * def->cpu->threads) {
+ virReportError(VIR_ERR_XML_DETAIL, "%s",
+ _("CPUs provided is less than topology"));
+ goto error;
+ }
+
if (def->cpu->cells_cpus > def->maxvcpus) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Number of CPUs in <numa> exceeds the"
10 years, 9 months
[libvirt] [PATCH v6 0/3] fix query-command-line-options
by Amos Kong
This patchset fixed some issues of query-command-line-options:
* some new options that haven't argument can't be queried. (eg: -enable-fips)
* some legacy options that have argument can't be queried. (eg: -vnc display)
More discussion:
http://marc.info/?l=qemu-devel&m=139081830416684&w=2
https://www.redhat.com/archives/libvir-list/2014-March/msg00318.html
V2: remove duplicate option tables, update schema (eric)
V3: fix typo in commitlog and export qemu_options talbe (eric)
V4: avoid the duplicate static table (eric)
V5: rename new field, other fix (markus)
V6: add implied-name (eric, markus)
Thanks for your review!
Amos Kong (3):
qmp: rename query_option_descs() to get_param_info()
query-command-line-options: expose implicit parameter name
query-command-line-options: query all the options in qemu-options.hx
qapi-schema.json | 16 +++++++++++++---
qemu-options.h | 12 ++++++++++++
util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++--------------
vl.c | 19 ++-----------------
4 files changed, 65 insertions(+), 34 deletions(-)
--
1.8.5.3
10 years, 9 months
[libvirt] [PATCH] Fix Memory Leak in testGetCaps()
by Nehal J Wani
While running qemucaps2xmltest, it was found that valgrind pointed out
the following memory leaks:
==27045== 160 (112 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 51 of 65
==27045== at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==27045== by 0x4C6BACD: virAllocVar (viralloc.c:560)
==27045== by 0x4CAF095: virObjectNew (virobject.c:193)
==27045== by 0x421453: virQEMUCapsNew (qemu_capabilities.c:1805)
==27045== by 0x41F04F: testQemuCapsXML (qemucaps2xmltest.c:72)
==27045== by 0x41FFD1: virtTestRun (testutils.c:201)
==27045== by 0x41EE7A: mymain (qemucaps2xmltest.c:203)
==27045== by 0x42074D: virtTestMain (testutils.c:789)
==27045== by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==27045==
==27045== 160 (112 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 52 of 65
==27045== at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==27045== by 0x4C6BACD: virAllocVar (viralloc.c:560)
==27045== by 0x4CAF095: virObjectNew (virobject.c:193)
==27045== by 0x421453: virQEMUCapsNew (qemu_capabilities.c:1805)
==27045== by 0x41F04F: testQemuCapsXML (qemucaps2xmltest.c:72)
==27045== by 0x41FFD1: virtTestRun (testutils.c:201)
==27045== by 0x41EEA3: mymain (qemucaps2xmltest.c:204)
==27045== by 0x42074D: virtTestMain (testutils.c:789)
==27045== by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
---
tests/qemucaps2xmltest.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index 8bf6738..cef5735 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -125,6 +125,7 @@ testGetCaps(char *capsData, const testQemuData *data)
goto error;
}
+ virObjectUnref(qemuCaps);
return caps;
error:
--
1.7.1
10 years, 9 months
[libvirt] [PATCH v3 0/2] bhyve: add xml2args unittest
by Roman Bogorodskiy
Changes from v2:
- Make virBhyveTapGetRealDeviceName a stub on non-FreeBSD
- Add bhyvexml2argvdata and bhyvexml2argvmock.c to EXTRA_DIST
- Include bhyve headers in tests only if WITH_BHYVE is defined
- Don't use 'util/' for #include when not needed
Changes from v1:
- Chase MAC address support by adding virMacAddrGenerate() mock, so
we can get a constant MAC address
- Add a test for the case when MAC address is specified in the
domain xml
Roman Bogorodskiy (2):
Move virBhyveTapGetRealDeviceName to virnetdevtap
bhyve: add xml2args unittest
src/bhyve/bhyve_command.c | 74 +---------
src/libvirt_private.syms | 1 +
src/util/virnetdevtap.c | 87 ++++++++++++
src/util/virnetdevtap.h | 3 +
tests/Makefile.am | 26 ++++
.../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args | 3 +
tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.xml | 24 ++++
tests/bhyvexml2argvdata/bhyvexml2argv-base.args | 3 +
tests/bhyvexml2argvdata/bhyvexml2argv-base.xml | 20 +++
.../bhyvexml2argv-disk-virtio.args | 3 +
.../bhyvexml2argv-disk-virtio.xml | 20 +++
tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args | 3 +
tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.xml | 21 +++
tests/bhyvexml2argvmock.c | 49 +++++++
tests/bhyvexml2argvtest.c | 153 +++++++++++++++++++++
15 files changed, 417 insertions(+), 73 deletions(-)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.xml
create mode 100644 tests/bhyvexml2argvmock.c
create mode 100644 tests/bhyvexml2argvtest.c
--
1.8.4.2
10 years, 9 months
[libvirt] [PATCH v3 for 2.0] update names in option tables to match with actual command-line spelling
by Amos Kong
We want to establish a mapping between option name and option table,
then we can search related option table by option name.
This patch makes all the member name of QemuOptsList to match with
actual command-line spelling(option name).
[ Important Note ]
The QemuOptsList member name values are ABI, changing them can break
existing -readconfig configuration files.
This patch changes:
from to introduced in
acpi acpitable 0c764a9 v1.5.0
boot-opts boot 3d3b830 v1.0
smp-opts smp 12b7f57 v1.6.0
All three have calcified into ABI already.
I have updated the release note of 2.0
http://wiki.qemu.org/ChangeLog/2.0#ABI_breaking
Signed-off-by: Amos Kong <akong(a)redhat.com>
---
V2: fix name in acpi option table
V3: mention ABI break in commitlog (Markus)
---
hw/acpi/core.c | 8 ++++----
hw/nvram/fw_cfg.c | 4 ++--
include/qemu/option.h | 2 +-
vl.c | 14 +++++++-------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 79414b4..12e9ae8 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -54,16 +54,16 @@ static const char unsigned dfl_hdr[ACPI_TABLE_HDR_SIZE - ACPI_TABLE_PFX_SIZE] =
char unsigned *acpi_tables;
size_t acpi_tables_len;
-static QemuOptsList qemu_acpi_opts = {
- .name = "acpi",
+static QemuOptsList qemu_acpitable_opts = {
+ .name = "acpitable",
.implied_opt_name = "data",
- .head = QTAILQ_HEAD_INITIALIZER(qemu_acpi_opts.head),
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_acpitable_opts.head),
.desc = { { 0 } } /* validated with OptsVisitor */
};
static void acpi_register_config(void)
{
- qemu_add_opts(&qemu_acpi_opts);
+ qemu_add_opts(&qemu_acpitable_opts);
}
machine_init(acpi_register_config);
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 282341a..3e6b048 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -125,7 +125,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
const char *temp;
/* get user configuration */
- QemuOptsList *plist = qemu_find_opts("boot-opts");
+ QemuOptsList *plist = qemu_find_opts("boot");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "splash");
@@ -191,7 +191,7 @@ static void fw_cfg_reboot(FWCfgState *s)
const char *temp;
/* get user configuration */
- QemuOptsList *plist = qemu_find_opts("boot-opts");
+ QemuOptsList *plist = qemu_find_opts("boot");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "reboot-timeout");
diff --git a/include/qemu/option.h b/include/qemu/option.h
index 8c0ac34..96b7c29 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -102,7 +102,7 @@ typedef struct QemuOptDesc {
} QemuOptDesc;
struct QemuOptsList {
- const char *name;
+ const char *name; /* option name */
const char *implied_opt_name;
bool merge_lists; /* Merge multiple uses of option into a single list? */
QTAILQ_HEAD(, QemuOpts) head;
diff --git a/vl.c b/vl.c
index 02bf8ec..c8002ea 100644
--- a/vl.c
+++ b/vl.c
@@ -388,7 +388,7 @@ static QemuOptsList qemu_machine_opts = {
};
static QemuOptsList qemu_boot_opts = {
- .name = "boot-opts",
+ .name = "boot",
.implied_opt_name = "order",
.merge_lists = true,
.head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
@@ -1357,7 +1357,7 @@ static void numa_add(const char *optarg)
}
static QemuOptsList qemu_smp_opts = {
- .name = "smp-opts",
+ .name = "smp",
.implied_opt_name = "cpus",
.merge_lists = true,
.head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head),
@@ -3245,7 +3245,7 @@ int main(int argc, char **argv, char **envp)
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
- opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("boot"), optarg, 1);
if (!opts) {
exit(1);
}
@@ -3614,7 +3614,7 @@ int main(int argc, char **argv, char **envp)
break;
}
case QEMU_OPTION_acpitable:
- opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("acpitable"), optarg, 1);
if (!opts) {
exit(1);
}
@@ -3681,7 +3681,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_smp:
- if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) {
+ if (!qemu_opts_parse(qemu_find_opts("smp"), optarg, 1)) {
exit(1);
}
break;
@@ -4006,7 +4006,7 @@ int main(int argc, char **argv, char **envp)
data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR;
}
- smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
+ smp_parse(qemu_opts_find(qemu_find_opts("smp"), NULL));
machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
if (smp_cpus > machine->max_cpus) {
@@ -4190,7 +4190,7 @@ int main(int argc, char **argv, char **envp)
bios_name = qemu_opt_get(machine_opts, "firmware");
boot_order = machine->default_boot_order;
- opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
+ opts = qemu_opts_find(qemu_find_opts("boot"), NULL);
if (opts) {
char *normal_boot_order;
const char *order, *once;
--
1.8.5.3
10 years, 9 months