[libvirt] [PATCH 0/1] Support huge pages in guests
by Daniel P. Berrange
This patch is an update of John Cooper's original work from
last month
http://www.redhat.com/archives/libvir-list/2009-July/msg00753.html
Changes since that patch
- We create a directory $MOUNTPOINT/libvirt/qemu inside the hugetlbfs
mount point. This is neccessary because QEMU now runs as 'qemu:qemu'
in Fedora and thus cannot create files in the root. libvirtd will
automatically chown() this subdir to allow QEMU guests access
- Don't automatically probe for hugetlbfs mount if runing as an
unprivileged libvirtd, since user won't have access to the mount
unless administrator has manually created them a subdir.
- Change the XML to look like
<memoryBacking>
<hugepages/>
</memoryBacking>
This is because I fear we may have more config options for memory
backing store in the future, such as whether KVM can use KSM for
sharing on the guest.
- Add a test case for it in the XML -> ARGV convetor
- Document the new XML options
- Add the new XML options to the RNG schema
- Fix setup & auto-detection of hugetlbfs mount if no qemu.conf file
exists at all
- Add config parameter to the augeas schema
- Move the code which finds a mount point into util.c since its not
specific to QEMU
15 years, 2 months
[libvirt] [PATCH] mdns.c: remove dead initialization
by Jim Meyering
The only following uses of group look like this:
(always preceded by initialization):
AVAHI_DEBUG("Client collision/connecting %p", mdns->client);
group = mdns->group;
while (group) {
if (group->handle)
avahi_entry_group_reset(group->handle);
group = group->next;
}
So the value used in the initialization at the top is never used.
>From 515e4a4542ce396b8775c618cbe17a30b78299b4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 3 Sep 2009 13:45:22 +0200
Subject: [PATCH] mdns.c: remove dead initialization
* qemud/mdns.c (libvirtd_mdns_client_callback): Remove dead
initialization.
---
qemud/mdns.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/qemud/mdns.c b/qemud/mdns.c
index ae6ff08..73b7d11 100644
--- a/qemud/mdns.c
+++ b/qemud/mdns.c
@@ -178,7 +178,7 @@ static void libvirtd_mdns_create_services(struct libvirtd_mdns_group *group) {
static void libvirtd_mdns_client_callback(AvahiClient *c, AvahiClientState state, void *userdata) {
struct libvirtd_mdns *mdns = (struct libvirtd_mdns *)userdata;
- struct libvirtd_mdns_group *group = mdns->group;
+ struct libvirtd_mdns_group *group;
if (!mdns->client)
mdns->client = c;
--
1.6.4.2.395.ge3d52
15 years, 2 months
[libvirt] [PATCH] node_device_conf.c: remove dead initialization
by Jim Meyering
The following use of "caps" is the assignment in a for-loop,
so the initialization is unnecessary.
>From 7032a0b370db1a9489cf19fce0cabbb6959320ab Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 3 Sep 2009 13:38:57 +0200
Subject: [PATCH] node_device_conf.c: remove dead initialization
* src/node_device_conf.c (virNodeDeviceDefFormat): Remove dead
initialization.
---
src/node_device_conf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/node_device_conf.c b/src/node_device_conf.c
index 56a9bb5..5b25bb7 100644
--- a/src/node_device_conf.c
+++ b/src/node_device_conf.c
@@ -213,7 +213,7 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
const virNodeDeviceDefPtr def)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- virNodeDevCapsDefPtr caps = def->caps;
+ virNodeDevCapsDefPtr caps;
char *tmp;
virBufferAddLit(&buf, "<device>\n");
--
1.6.4.2.395.ge3d52
15 years, 2 months
[libvirt] [PATCH] Fix misc OOM bugs
by Daniel P. Berrange
* tests/testutils.c: Run test function twice, once to prime it for
static allocations, once to count the non-static allocations.
* tests/testutilsqemu.c: Initialize variable correctl
* src/capabilities.c: Don't free machines variable upon failure
since caller must do that
* src/xm_internal.c: Add missing check for OOM in building VIF
config param
---
src/capabilities.c | 17 +++++++++--------
src/xm_internal.c | 3 +++
tests/testutils.c | 12 ++++++++----
tests/testutilsqemu.c | 2 +-
4 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/src/capabilities.c b/src/capabilities.c
index 193a9fe..289180d 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -354,10 +354,6 @@ virCapabilitiesAddGuest(virCapsPtr caps,
if (loader &&
(guest->arch.defaultInfo.loader = strdup(loader)) == NULL)
goto no_memory;
- if (nmachines) {
- guest->arch.defaultInfo.nmachines = nmachines;
- guest->arch.defaultInfo.machines = machines;
- }
if (VIR_REALLOC_N(caps->guests,
caps->nguests + 1) < 0)
@@ -365,6 +361,11 @@ virCapabilitiesAddGuest(virCapsPtr caps,
caps->guests[caps->nguests] = guest;
caps->nguests++;
+ if (nmachines) {
+ guest->arch.defaultInfo.nmachines = nmachines;
+ guest->arch.defaultInfo.machines = machines;
+ }
+
return guest;
no_memory:
@@ -407,10 +408,6 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
if (loader &&
(dom->info.loader = strdup(loader)) == NULL)
goto no_memory;
- if (nmachines) {
- dom->info.nmachines = nmachines;
- dom->info.machines = machines;
- }
if (VIR_REALLOC_N(guest->arch.domains,
guest->arch.ndomains + 1) < 0)
@@ -418,6 +415,10 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
guest->arch.domains[guest->arch.ndomains] = dom;
guest->arch.ndomains++;
+ if (nmachines) {
+ dom->info.nmachines = nmachines;
+ dom->info.machines = machines;
+ }
return dom;
diff --git a/src/xm_internal.c b/src/xm_internal.c
index 71b852e..66f1e1c 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -2048,6 +2048,9 @@ static int xenXMDomainConfigFormatNet(virConnectPtr conn,
virBufferVSprintf(&buf, ",vifname=%s",
net->ifname);
+ if (virBufferError(&buf))
+ goto cleanup;
+
if (VIR_ALLOC(val) < 0) {
virReportOOMError(conn);
goto cleanup;
diff --git a/tests/testutils.c b/tests/testutils.c
index 7a1dbdc..5072fec 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -367,10 +367,7 @@ int virtTestMain(int argc,
}
}
- if (testOOM)
- virAllocTestInit();
-
- /* Run once to count allocs, and ensure it passes :-) */
+ /* Run once to prime any static allocations & ensure it passes */
ret = (func)(argc, argv);
if (ret != EXIT_SUCCESS)
goto cleanup;
@@ -385,6 +382,13 @@ int virtTestMain(int argc,
testOOM++;
virSetErrorFunc(NULL, virtTestErrorFuncQuiet);
+ virAllocTestInit();
+
+ /* Run again to count allocs, and ensure it passes :-) */
+ ret = (func)(argc, argv);
+ if (ret != EXIT_SUCCESS)
+ goto cleanup;
+
approxAlloc = virAllocTestCount();
testCounter++;
if (testDebug)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 58707e1..6b6a185 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -9,7 +9,7 @@ virCapsPtr testQemuCapsInit(void) {
struct utsname utsname;
virCapsPtr caps;
virCapsGuestPtr guest;
- virCapsGuestMachinePtr *machines;
+ virCapsGuestMachinePtr *machines = NULL;
int nmachines;
static const char *const x86_machines[] = {
"pc", "isapc"
--
1.6.2.5
15 years, 2 months
[libvirt] [PATCH] remote_internal.c: don't dereference a NULL "conn"
by Jim Meyering
Here's the test just before the else-if in the patch below:
if (conn &&
conn->driver &&
STREQ (conn->driver->name, "remote")) {
So, in the else-branch, "conn" is guaranteed to be NULL.
And dereferenced.
This may be only a theoretical risk, but if so,
the test of "conn" above should be changed to an assertion,
and/or the parameter should get the nonnull attribute.
>From a1b1d36d96f6b50ddf514539af85da20ca671bf5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 2 Sep 2009 11:54:38 +0200
Subject: [PATCH] remote_internal.c: don't dereference a NULL "conn"
* src/remote_internal.c (remoteDevMonOpen): Avoid NULL-dereference.
---
src/remote_internal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/remote_internal.c b/src/remote_internal.c
index ea50c11..141fef9 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -5148,7 +5148,7 @@ remoteDevMonOpen(virConnectPtr conn,
conn->devMonPrivateData = priv;
remoteDriverUnlock(priv);
return VIR_DRV_OPEN_SUCCESS;
- } else if (conn->networkDriver &&
+ } else if (conn && conn->networkDriver &&
STREQ (conn->networkDriver->name, "remote")) {
struct private_data *priv = conn->networkPrivateData;
remoteDriverLock(priv);
--
1.6.4.2.395.ge3d52
15 years, 2 months
[libvirt] [PATCH] test.c: don't use undefined local, "def"
by Jim Meyering
another real bug:
>From fd41bd47252654f84684830e02ecbeb3d26e7dee Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 3 Sep 2009 12:12:19 +0200
Subject: [PATCH] test.c: don't use undefined local, "def"
* src/test.c (testOpenVolumesForPool): Upon early virAsprintf or
virXPathNodeSet failure, "goto error" would take us to
virStorageVolDefFree(def), but with "def" not defined.
Initialize it to NULL.
---
src/test.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/test.c b/src/test.c
index 7c8f85b..895cce1 100644
--- a/src/test.c
+++ b/src/test.c
@@ -435,7 +435,7 @@ static int testOpenVolumesForPool(virConnectPtr conn,
char *vol_xpath;
int i, ret, func_ret = -1;
xmlNodePtr *vols = NULL;
- virStorageVolDefPtr def;
+ virStorageVolDefPtr def = NULL;
/* Find storage volumes */
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", poolidx) < 0) {
--
1.6.4.2.395.ge3d52
15 years, 2 months