[libvirt] [PATCH] parallels: Cleanup partly opened drivers on connect open failure
by Michal Privoznik
Well, the parallelsConnectOpen() joins several sub-driver openings
into one big if condition. If any of sub-driver fails to open, the
whole API finishes immediately. The problem is, sub-drivers may have
left some memory allocated. Fortunately, we have a free function for
that: parallelsConnectClose(). This is, however, not prepared for
partially allocated driver structure. So, prepare the free function
for it and call it at the right place, in the if body.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
This commit assumes that virNetworkObjListFree() accepts NULL,
and thus depends on this patch (which has been ACKed already):
https://www.redhat.com/archives/libvir-list/2015-February/msg01127.html
Should I push both during freeze or wait until after the release?
src/parallels/parallels_driver.c | 7 ++++++-
src/parallels/parallels_network.c | 4 ++++
src/parallels/parallels_storage.c | 6 ++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index c9338b5..650b790 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -264,8 +264,10 @@ parallelsConnectOpen(virConnectPtr conn,
if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS ||
(ret = parallelsStorageOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS ||
- (ret = parallelsNetworkOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS)
+ (ret = parallelsNetworkOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS) {
+ parallelsConnectClose(conn);
return ret;
+ }
return VIR_DRV_OPEN_SUCCESS;
}
@@ -275,6 +277,9 @@ parallelsConnectClose(virConnectPtr conn)
{
parallelsConnPtr privconn = conn->privateData;
+ if (!privconn)
+ return 0;
+
parallelsNetworkClose(conn);
parallelsStorageClose(conn);
diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 3e7087d..c5834c5 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -336,6 +336,10 @@ parallelsNetworkOpen(virConnectPtr conn,
int parallelsNetworkClose(virConnectPtr conn)
{
parallelsConnPtr privconn = conn->privateData;
+
+ if (!privconn)
+ return 0;
+
parallelsDriverLock(privconn);
virNetworkObjListFree(&privconn->networks);
parallelsDriverUnlock(privconn);
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index d2c5bf2..56c1b42 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -72,9 +72,15 @@ parallelsStorageClose(virConnectPtr conn)
{
parallelsConnPtr privconn = conn->privateData;
+ if (!privconn)
+ return 0;
+
virStorageDriverStatePtr storageState = privconn->storageState;
privconn->storageState = NULL;
+ if (!storageState)
+ return 0;
+
parallelsStorageLock(storageState);
virStoragePoolObjListFree(&privconn->pools);
VIR_FREE(storageState->configDir);
--
2.0.5
9 years, 8 months
[libvirt] [libvirt-designer][PATCH] Makefile: Build tests at the same time as the rest
by Michal Privoznik
Currently, since we were using check_PROGRAMS in the Makefile
template, the test program build was postponed until 'make check'
was run. That's not optimal. Lets build (not run!) test program
in the 'make all' phase.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
>From my libvirt development experience, I'm used to just run make
from my text editor. For instance, when changing some function
header, I just run make and let the compiler catch all the places
that need fixing. I think it's common practice.
libvirt-designer/Makefile.am | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libvirt-designer/Makefile.am b/libvirt-designer/Makefile.am
index bda4240..fd7627d 100644
--- a/libvirt-designer/Makefile.am
+++ b/libvirt-designer/Makefile.am
@@ -82,9 +82,9 @@ libvirt-designer-enum-types.c: $(DESIGNER_HEADER_FILES) libvirt-designer-enum-ty
$(AM_V_GEN) ( $(GLIB_MKENUMS) --template $(srcdir)/libvirt-designer-enum-types.c.template $(DESIGNER_HEADER_FILES:%=$(srcdir)/%) ) | \
sed -e "s/G_TYPE_VIR_CONFIG/GVIR_CONFIG_TYPE/" -e "s/g_vir/gvir/" > libvirt-designer-enum-types.c
-check_PROGRAMS = test-designer-domain
+noinst_PROGRAMS = test-designer-domain
-TESTS = $(check_PROGRAMS)
+TESTS = $(noinst_PROGRAMS)
test_designer_domain_CFLAGS = \
-I$(top_srcdir) \
--
2.0.5
9 years, 8 months
[libvirt] [PATCH] storage: tweak condition to properly test lseek
by Erik Skultety
According to the POSIX standard, off_t (returned by lseek) is defined as
signed integral type no shorter than int. Because our offset variable is defined
as unsigned long long, the original check was passed successfully if UINT64_MAX had
been used as offset value, due to implicit conversion.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177219
---
src/fdstream.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index 5d80fc2..b8ea86e 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -610,7 +610,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
}
if (offset &&
- lseek(fd, offset, SEEK_SET) != offset) {
+ lseek(fd, offset, SEEK_SET) < 0) {
virReportSystemError(errno,
_("Unable to seek %s to %llu"),
path, offset);
--
1.9.3
9 years, 8 months
[libvirt] [PATCH] virsh: tweak domif-getlink link state reporting message
by Erik Skultety
According to docs, we only support 2 link states for an interface
up/down, 'up' being the default state if link state is unspecified in
domain's XML, so the message when no link state is provided should be
changed a little.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1141119
---
tools/virsh-domain-monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 925eb1b..18ce9ae 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -756,7 +756,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
if ((state = virXPathString("string(./link/@state)", ctxt)))
vshPrint(ctl, "%s %s", iface, state);
else
- vshPrint(ctl, "%s default", iface);
+ vshPrint(ctl, "%s up", iface);
ret = true;
--
1.9.3
9 years, 8 months
[libvirt] [libvirt-designer 1/2] Fix gvir_designer_domain_get_fallback_disk_controller leak
by Christophe Fergeau
When the list of devices is empty (osinfo_list_get_length(devices) ==
0), the 'devices' object would be leaked.
---
libvirt-designer/libvirt-designer-domain.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
index c1a0e83..6629fb5 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -1517,7 +1517,7 @@ gvir_designer_domain_get_fallback_disk_controller(GVirDesignerDomain *design,
GError **error)
{
OsinfoEntity *dev = NULL;
- OsinfoDeviceList *devices;
+ OsinfoDeviceList *devices = NULL;
OsinfoFilter *filter;
int virt_type;
@@ -1552,9 +1552,11 @@ gvir_designer_domain_get_fallback_disk_controller(GVirDesignerDomain *design,
dev = osinfo_list_get_nth(OSINFO_LIST(devices), 0);
g_object_ref(G_OBJECT(dev));
- g_object_unref(G_OBJECT(devices));
cleanup:
+ if (devices != NULL)
+ g_object_unref(G_OBJECT(devices));
+
return OSINFO_DEVICE(dev);
}
--
2.1.0
9 years, 8 months
[libvirt] [libvirt-designer][PATCH] test: Add new SimpleDisk test
by Michal Privoznik
This test is meant for adding CDROM, floppy and disk to a domain.
For now, each method has _file and _device variant, which are
tested for now.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Funny, when reviewing Chritophe's patches, I've found one forgotten branch too.
libvirt-designer/test-designer-domain.c | 101 ++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/libvirt-designer/test-designer-domain.c b/libvirt-designer/test-designer-domain.c
index bbd5a28..90f7e68 100644
--- a/libvirt-designer/test-designer-domain.c
+++ b/libvirt-designer/test-designer-domain.c
@@ -125,6 +125,41 @@ static const gchar *capslxcxml =
" </guest>"
"</capabilities>";
+static const gchar *domain_machine_simple_iso_result =
+ "<domain>\n"
+ " <devices>\n"
+ " <disk type=\"file\">\n"
+ " <source file=\"/foo/bar1\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hda\"/>\n"
+ " </disk>\n"
+ " <disk type=\"block\">\n"
+ " <source dev=\"/foo/bar2\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hdb\"/>\n"
+ " </disk>\n"
+ " <disk type=\"file\">\n"
+ " <source file=\"/foo/bar3\"/>\n"
+ " <driver name=\"qemu\" type=\"qcow2\"/>\n"
+ " <target bus=\"ide\" dev=\"hdc\"/>\n"
+ " </disk>\n"
+ " <disk type=\"block\">\n"
+ " <source dev=\"/foo/bar4\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hdd\"/>\n"
+ " </disk>\n"
+ " <disk type=\"file\">\n"
+ " <source file=\"/foo/bar5\"/>\n"
+ " <driver name=\"qemu\" type=\"bochs\"/>\n"
+ " <target bus=\"ide\" dev=\"hde\"/>\n"
+ " </disk>\n"
+ " <disk type=\"block\">\n"
+ " <source dev=\"/foo/bar6\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hdf\"/>\n"
+ " </disk>\n"
+ " </devices>\n"
+ "</domain>";
static void test_domain_machine_setup(GVirDesignerDomain **design, gconstpointer opaque)
{
@@ -142,6 +177,49 @@ static void test_domain_machine_setup(GVirDesignerDomain **design, gconstpointer
}
+static void test_domain_machine_simple_disk_setup(GVirDesignerDomain **design, gconstpointer opaque)
+{
+ GError *error = NULL;
+ GVirConfigDomainDisk *disk;
+ OsinfoOs *os = osinfo_os_new("http://myoperatingsystem/amazing/4.2");
+ OsinfoDb *db = osinfo_db_new();
+ OsinfoPlatform *platform = osinfo_platform_new("http://myhypervisor.org/awesome/6.6.6");
+ GVirConfigCapabilities *caps = gvir_config_capabilities_new_from_xml(capsqemuxml, NULL);
+
+ *design = gvir_designer_domain_new(db, os, platform, caps);
+ g_assert(*design);
+
+ disk = gvir_designer_domain_add_cdrom_file(*design, "/foo/bar1", "raw", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_cdrom_device(*design, "/foo/bar2", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_disk_file(*design, "/foo/bar3", "qcow2", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_disk_device(*design, "/foo/bar4", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_floppy_file(*design, "/foo/bar5", "bochs", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_disk_device(*design, "/foo/bar6", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ g_object_unref(os);
+ g_object_unref(db);
+ g_object_unref(platform);
+ g_object_unref(caps);
+}
+
+
static void test_domain_container_setup(GVirDesignerDomain **design, gconstpointer opaque)
{
OsinfoOs *os = osinfo_os_new("http://myoperatingsystem/amazing/4.2");
@@ -243,6 +321,22 @@ static void test_domain_machine_alt_arch_run(GVirDesignerDomain **design, gconst
g_object_unref(osconfig);
}
+static void test_domain_machine_simple_disk_run(GVirDesignerDomain **design, gconstpointer opaque)
+{
+ GError *error = NULL;
+ gboolean ret;
+ GVirConfigDomain *config;
+ gchar *xml;
+
+ config = gvir_designer_domain_get_config(*design);
+ xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(config));
+ g_test_message("XML %s", xml);
+ g_assert_cmpstr(xml,
+ ==,
+ domain_machine_simple_iso_result);
+ g_free(xml);
+}
+
static void test_domain_container_host_arch_run(GVirDesignerDomain **design, gconstpointer opaque)
{
GError *error = NULL;
@@ -362,5 +456,12 @@ int main(int argc, char **argv)
test_domain_container_setup,
test_domain_container_alt_arch_run,
test_domain_teardown);
+ g_test_add("/TestDesignerDomain/SimpleDisk",
+ GVirDesignerDomain *,
+ &domain,
+ test_domain_machine_simple_disk_setup,
+ test_domain_machine_simple_disk_run,
+ test_domain_teardown);
+
return g_test_run();
}
--
2.0.5
9 years, 8 months
[libvirt] overlayfs support to lxc driver
by Vasiliy Tolstov
Hello. I'm interesting in implementing overlayfs support to lxc libvirt driver.
As i see i simply can utilize filesystem type='template' for this usage.
In case os template fs i need to mount with lowerdir
/var/lib/libvirt/filesystems/template to
/var/lib/libvirt/filesystems/name
But i have problem: overlayfs fs need upperdir that store differences
and mountpoint that used by clients. In case of libvirt usage -
upperdir need to be places in /var/lib/libvirt/filesystems, but where
i can put mountpoint dir ? /var/run/libvirt or in /tmp/libvirt-XXXXX ?
Also what is the preferred way to integrate overlayfs support to
libvirt? I can addd mount type to filesystem type='mount' or use (like
now) template type. What is the preferred way?
Thanks
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
jabber: vase(a)selfip.ru
9 years, 8 months
[libvirt] [libvirt-designer 0/7]
by Christophe Fergeau
Hey,
After seeing the libvirt-designer GSoC idea, I remembered about a bunch of
libvirt-designer patches I had never sent :) Here they are, a few leak
fixes/build cleanups, and addition of 2 new methods for completeness.
Christophe
9 years, 8 months
[libvirt] [PATCH] qemu: fix not remove the pidfile when close a vm after restart libvirtd
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1197600
when create a happy vm and then restart libvirtd, we will loss
priv->pidfile, because we don't check if it is there is a pidfile.
However we only use this pidfile when we start the vm, and won't use
it after it start, so this is not a big deal.
But it is strange when vm is offline but pidfile still exist, so
remove vmname.pid in state dir (maybe /run/libvirt/qemu/)when
priv->pidfile is NULL.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/qemu/qemu_process.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 515402e..46b93b3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -92,6 +92,7 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
{
char ebuf[1024];
char *file = NULL;
+ char *pidfile = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
@@ -99,16 +100,19 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) < 0)
goto cleanup;
+ if (virAsprintf(&pidfile, "%s/%s.pid", cfg->stateDir, vm->def->name) < 0)
+ goto cleanup;
+
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_WARN("Failed to remove domain XML for %s: %s",
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
VIR_FREE(file);
- if (priv->pidfile &&
- unlink(priv->pidfile) < 0 &&
+ if (unlink(priv->pidfile ? priv->pidfile : pidfile) < 0 &&
errno != ENOENT)
VIR_WARN("Failed to remove PID file for %s: %s",
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
+ VIR_FREE(pidfile);
ret = 0;
cleanup:
--
1.8.3.1
9 years, 8 months