[libvirt] [PATCH v2] bhyve: Add support for VNC autoport
by Roman Bogorodskiy
From: Alexander Nusov <alexander.nusov(a)nfvexpress.com>
This patch adds support for automatic VNC port assignment for bhyve guests.
---
Changes from v1:
* Call virPortAllocatorRelease() in virBhyveProcessStop() to release
VNC port; that's done unconditionally of using autoport
* Call virPortAllocatorSetUsed(.., true) in virBhyveProcessReconnect()
to reserve already used VNC ports after daemon restart
* Call virPortAllocatorSetUsed(.., true) in bhyveBuildGraphicsArgStr()
for domains that don't use autoport so allocator didn't try to use
ports allocated by these domains
* In dryRun mode (i.e. for domxml-to-native) don't allocate any ports
* Add a couple of unit tests
Note 1: while adding tests I noticed that port allocator will actually
skip already bound ports, so I'm wondering if it makes any sense to use
virPortAllocatorSetUsed(.., true)? Right now I cannot come up with any
case to trigger this except probably some races when spawning guests
simultaneously, but that's hard to reproduce.
Note 2: there are still some cases where resources allocated during
command preparation are not properly cleaned up; that's not only VNC
ports, but also TAP devices. I plan to add proper cleanup routines
separately.
src/bhyve/bhyve_command.c | 25 +++++++++++--
src/bhyve/bhyve_driver.c | 5 +++
src/bhyve/bhyve_process.c | 20 +++++++++++
src/bhyve/bhyve_utils.h | 3 ++
.../bhyvexml2argv-vnc-autoport.args | 12 +++++++
.../bhyvexml2argv-vnc-autoport.ldargs | 1 +
.../bhyvexml2argv-vnc-autoport.xml | 26 ++++++++++++++
tests/bhyvexml2argvtest.c | 7 ++++
.../bhyvexml2xmlout-vnc-autoport.xml | 41 ++++++++++++++++++++++
tests/bhyvexml2xmltest.c | 1 +
10 files changed, 138 insertions(+), 3 deletions(-)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-autoport.xml
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index eae5cb3ca..e62b5df66 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -330,15 +330,19 @@ bhyveBuildLPCArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
}
static int
-bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
+bhyveBuildGraphicsArgStr(const virDomainDef *def,
virDomainGraphicsDefPtr graphics,
virDomainVideoDefPtr video,
virConnectPtr conn,
- virCommandPtr cmd)
+ virCommandPtr cmd,
+ bool dryRun)
{
virBuffer opt = VIR_BUFFER_INITIALIZER;
virDomainGraphicsListenDefPtr glisten = NULL;
bool escapeAddr;
+ unsigned short port;
+
+ bhyveConnPtr driver = conn->privateData;
if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) ||
def->os.bootloader ||
@@ -401,6 +405,20 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
virBufferAdd(&opt, glisten->address, -1);
}
+ if (!dryRun) {
+ if (graphics->data.vnc.autoport) {
+ if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
+ return -1;
+ graphics->data.vnc.port = port;
+ } else {
+ if (virPortAllocatorSetUsed(driver->remotePorts,
+ graphics->data.vnc.port,
+ true) < 0)
+ VIR_WARN("Failed to mark VNC port '%d' as used by '%s'",
+ graphics->data.vnc.port, def->name);
+ }
+ }
+
virBufferAsprintf(&opt, ":%d", graphics->data.vnc.port);
break;
default:
@@ -553,7 +571,8 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
if (def->ngraphics && def->nvideos) {
if (def->ngraphics == 1 && def->nvideos == 1) {
- if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->videos[0], conn, cmd) < 0)
+ if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->videos[0],
+ conn, cmd, dryRun) < 0)
goto error;
add_lpc = true;
} else {
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index ed2221a35..bffeea7d9 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -52,6 +52,7 @@
#include "viraccessapicheck.h"
#include "virhostcpu.h"
#include "virhostmem.h"
+#include "virportallocator.h"
#include "conf/domain_capabilities.h"
#include "bhyve_conf.h"
@@ -1219,6 +1220,7 @@ bhyveStateCleanup(void)
virObjectUnref(bhyve_driver->closeCallbacks);
virObjectUnref(bhyve_driver->domainEventState);
virObjectUnref(bhyve_driver->config);
+ virObjectUnref(bhyve_driver->remotePorts);
virMutexDestroy(&bhyve_driver->lock);
VIR_FREE(bhyve_driver);
@@ -1265,6 +1267,9 @@ bhyveStateInitialize(bool privileged,
if (!(bhyve_driver->domainEventState = virObjectEventStateNew()))
goto cleanup;
+ if (!(bhyve_driver->remotePorts = virPortAllocatorNew(_("display"), 5900, 65535, 0)))
+ goto cleanup;
+
bhyve_driver->hostsysinfo = virSysinfoRead();
if (!(bhyve_driver->config = virBhyveDriverConfigNew()))
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index a97e300ff..7211156ca 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -293,6 +293,16 @@ virBhyveProcessStop(bhyveConnPtr driver,
/* Cleanup network interfaces */
bhyveNetCleanup(vm);
+ /* VNC autoport cleanup */
+ if ((vm->def->ngraphics == 1) &&
+ vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+ if (virPortAllocatorRelease(driver->remotePorts,
+ vm->def->graphics[0]->data.vnc.port) < 0) {
+ VIR_WARN("Failed to release VNC port for '%s'",
+ vm->def->name);
+ }
+ }
+
ret = 0;
virCloseCallbacksUnset(driver->closeCallbacks, vm,
@@ -412,6 +422,16 @@ virBhyveProcessReconnect(virDomainObjPtr vm,
if (STREQ(expected_proctitle, proc_argv[0])) {
ret = 0;
priv->mon = bhyveMonitorOpen(vm, data->driver);
+ if (vm->def->ngraphics == 1 &&
+ vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+ int vnc_port = vm->def->graphics[0]->data.vnc.port;
+ if (virPortAllocatorSetUsed(data->driver->remotePorts,
+ vnc_port,
+ true) < 0) {
+ VIR_WARN("Failed to mark VNC port '%d' as used by '%s'",
+ vnc_port, vm->def->name);
+ }
+ }
}
}
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index db50e012a..8ad2698d4 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -28,6 +28,7 @@
# include "virdomainobjlist.h"
# include "virthread.h"
# include "virclosecallbacks.h"
+# include "virportallocator.h"
# define BHYVE_AUTOSTART_DIR SYSCONFDIR "/libvirt/bhyve/autostart"
# define BHYVE_CONFIG_DIR SYSCONFDIR "/libvirt/bhyve"
@@ -58,6 +59,8 @@ struct _bhyveConn {
virCloseCallbacksPtr closeCallbacks;
+ virPortAllocatorPtr remotePorts;
+
unsigned bhyvecaps;
unsigned grubcaps;
};
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.args
new file mode 100644
index 000000000..039526ff3
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.args
@@ -0,0 +1,12 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5900 \
+-s 1,lpc bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.ldargs
new file mode 100644
index 000000000..421376db9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.xml
new file mode 100644
index 000000000..afb73f040
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-autoport.xml
@@ -0,0 +1,26 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='-1' autoport='yes'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index c8f8c685a..95fada0bd 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -145,6 +145,11 @@ mymain(void)
if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL)
return EXIT_FAILURE;
+ if (!(driver.remotePorts = virPortAllocatorNew("display", 5900, 65535,
+ VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK)))
+ return EXIT_FAILURE;
+
+
# define DO_TEST_FULL(name, flags) \
do { \
static struct testInfo info = { \
@@ -193,6 +198,7 @@ mymain(void)
DO_TEST("net-e1000");
DO_TEST("uefi");
DO_TEST("vnc");
+ DO_TEST("vnc-autoport");
/* Address allocation tests */
DO_TEST("addr-single-sata-disk");
@@ -231,6 +237,7 @@ mymain(void)
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
+ virObjectUnref(driver.remotePorts);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-autoport.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-autoport.xml
new file mode 100644
index 000000000..d6cfe76b7
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-autoport.xml
@@ -0,0 +1,41 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:00:00:00'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='gop' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index b3759919e..c16eb2b2c 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -105,6 +105,7 @@ mymain(void)
DO_TEST_DIFFERENT("serial-grub");
DO_TEST_DIFFERENT("serial-grub-nocons");
DO_TEST_DIFFERENT("vnc");
+ DO_TEST_DIFFERENT("vnc-autoport");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
--
2.13.1
7 years, 4 months
[libvirt] [PATCH RESEND] Interface: return appropriate status for bridge device
by Lin Ma
In function udevInterfaceIsActive, The current design relies on the sys
attribute 'operstate' to determine whether the interface is active.
For the device node of virtual network(say virbr0), There is already a
dummy tap device to maintain a fixed mac on it, So it's available and
its status should be considered as active. But if no anyelse tap device
connects to it, The value of operstate of virbr0 in sysfs is 'down', So
udevInterfaceIsActive returns 0, It causes 'virsh iface-list --all' to
report the status of virbr0 as 'inactive'.
This patch fixes the issue by counting slave devices for bridge device.
Signed-off-by: Lin Ma <lma(a)suse.com>
---
src/interface/interface_backend_udev.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 5d0fc64..9ac4674 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -1127,6 +1127,11 @@ udevInterfaceIsActive(virInterfacePtr ifinfo)
struct udev_device *dev;
virInterfaceDefPtr def = NULL;
int status = -1;
+ struct dirent **member_list = NULL;
+ const char *devtype;
+ int member_count = 0;
+ char *member_path;
+ size_t i;
dev = udev_device_new_from_subsystem_sysname(udev, "net",
ifinfo->name);
@@ -1146,6 +1151,23 @@ udevInterfaceIsActive(virInterfacePtr ifinfo)
/* Check if it's active or not */
status = STREQ(udev_device_get_sysattr_value(dev, "operstate"), "up");
+ if (!status) {
+ devtype = udev_device_get_devtype(dev);
+ if (STREQ_NULLABLE(devtype, "bridge")) {
+ if (virAsprintf(&member_path, "%s/%s",
+ udev_device_get_syspath(dev), "brif") < 0)
+ goto cleanup;
+ member_count = scandir(member_path, &member_list,
+ udevBridgeScanDirFilter, alphasort);
+ if (member_count > 0)
+ status = 1;
+ for (i = 0; i < member_count; i++)
+ VIR_FREE(member_list[i]);
+ VIR_FREE(member_list);
+ VIR_FREE(member_path);
+ }
+ }
+
udev_device_unref(dev);
cleanup:
--
2.9.2
7 years, 4 months
[libvirt] [PATCH v3 0/2] Allow saving VM state to pipe
by Chen Hanxiao
This series introduce flag VIR_DOMAIN_SAVE_DIRECT
to enable command 'save' to write to PIPE.
This will write QEMU_SAVE_MAGIC directly.
Base upon patches from Roy Keene <rkeene(a)knightpoint.com>
with some fixes.
Change from original patch:
1) Check whether the specified path is a PIPE.
2) Rebase on upstream.
3) Add doc for virsh command
v3:
add doc/news.xml
rebase on upstream
v2-resend:
rebase on upstream
v2:
rename VIR_DOMAIN_SAVE_PIPE to VIR_DOMAIN_SAVE_DIRECT
remove S_ISFIFO check
Chen Hanxiao (2):
qemu: Allow qemuDomainSaveMemory saving VM state to a pipe
virsh: introduce flage --direct for save command
docs/news.xml | 9 +++++++
include/libvirt/libvirt-domain.h | 1 +
src/qemu/qemu_driver.c | 54 ++++++++++++++++++++++++++--------------
tools/virsh-domain.c | 6 +++++
tools/virsh.pod | 5 +++-
5 files changed, 56 insertions(+), 19 deletions(-)
--
2.7.4
7 years, 4 months
[libvirt] [libvirt-php PATCH 0/7] add bindings for NWFilter APIs
by Dawid Zamirski
Hello,
This series adds support for libvirt's virNWFilter* APIs. Since it
introduces new resource type, I took the opportunity to cleanup the
driver code a little:
* in patches 1-3: added macros to take care of the differences in how
PHP5 and PHP7 handle resource types.
* in patch 4: libvirt_doman_get_connect was segfaulting when called
multiple times because it was not bumping reference count on the
resource it was returning to the calling code.
* in patch 5: added a macro to take care of the differences in how PHP5
and PHP7 initialize arrays.
* patches 6 and 7: implement the missing binding to NWFilter APIs.
Dawid Zamirski (7):
move macros to header file.
add wrappers for PHP resource handling.
update code to use resource handling macros
fix libvirt_doman_get_connect implementation.
add and use VIRT_ARRAY_INIT macro
add nwfilter resource type
implement NWFilter API bindings.
src/libvirt-php.c | 923 +++++++++++++++++++++++++++++++-----------------------
src/libvirt-php.h | 150 ++++++++-
2 files changed, 672 insertions(+), 401 deletions(-)
--
2.13.0
7 years, 4 months
[libvirt] [PATCH 0/3] libxl: Add a test suite for libxl_domain_config generator
by Jim Fehlig
Long ago danpb posted some patches to test libvirt domXML to
libxl_domain_config conversion
https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html
Some of the prerequisite patches were pushed, but we've never managed
to push patches actually providing the conversion tests. I sent several
follow-ups to Dan's work but never converged on a satisfactory solution
for all the Xen versions supported by libvirt. The last attempt was in
Sept 2014
https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html
I tried to revive the work in Jan 2015, but that also stalled
https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html
Fast-forward over 2.5 years from the first attempt and libvirt no longer
supports older Xen versions 4.2 and 4.3 that were proving to be problematic.
Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json,
which provides a way to implement the conversion tests that work with all
Xen versions >= 4.5 (including latest xen.git master).
The previous approaches compared a static json doc with the results of
domXML->libxl_domain_config conversion done in the libxl driver.
As discussed in those approaches, the json doc returned from
libxl_domain_config_to_json can change over Xen releases as the
libxl_domain_config object gains new fields, making it difficult to
compare the conversion with a static doc.
I had some time last week to pick at this thorn and reworked the test
to make use of libxl_domain_config_from_json introduced in Xen 4.5.
Instead of comparing the conversion results directly to a static json doc,
the static doc is first round-tripped through _from_json -> _to_json. Any
new fields added to libxl_domain_config object are then included in both
docs, allowing comparison across multiple Xen releases.
Patch3 provides the conversion tests using this new approach. The tests
are not run on Xen 4.4 (oldest version currently supported by libvirt)
since it does not provide libxl_domain_config_from_json.
Patches 1 and 2 fix some issues found while working on the tests.
See their commit messages for details.
Jim Fehlig (3):
libxl: determine device model version from emulator name
libxl: relax checks on <emulator>
libxl: Add a test suite for libxl_domain_config generator
m4/virt-driver-libxl.m4 | 6 +-
src/libxl/libxl_capabilities.c | 37 ++---
src/libxl/libxl_conf.c | 14 --
tests/Makefile.am | 18 ++-
tests/libxlxml2domconfigdata/basic-hvm.json | 89 +++++++++++
tests/libxlxml2domconfigdata/basic-hvm.xml | 36 +++++
tests/libxlxml2domconfigdata/basic-pv.json | 65 ++++++++
tests/libxlxml2domconfigdata/basic-pv.xml | 28 ++++
tests/libxlxml2domconfigdata/moredevs-hvm.json | 111 +++++++++++++
tests/libxlxml2domconfigdata/moredevs-hvm.xml | 63 ++++++++
tests/libxlxml2domconfigtest.c | 208 +++++++++++++++++++++++++
tests/virmocklibxl.c | 87 +++++++++++
12 files changed, 723 insertions(+), 39 deletions(-)
create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.json
create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.xml
create mode 100644 tests/libxlxml2domconfigdata/basic-pv.json
create mode 100644 tests/libxlxml2domconfigdata/basic-pv.xml
create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.json
create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.xml
create mode 100644 tests/libxlxml2domconfigtest.c
create mode 100644 tests/virmocklibxl.c
--
2.11.0
7 years, 4 months
[libvirt] [PATCH v3 00/16] virObject adjustments for common object
by John Ferlan
v2: https://www.redhat.com/archives/libvir-list/2017-June/msg00070.html
Pushed the first two patches from v2 since they were ACK'd
Changes in this series...
Fixed a couple of nits from former patch 3 & 4, but since they weren't ACK'd
they're here again, but now as patch 1 & 2.
Patch 3 & 4 are an adjusted version of the former patches 5 & 6. Instead
of going with generic @primaryKey and @secondaryKey names, this patch will
use @uuid and @name for the field names. Additionally instead of using
PoolableHashElement as a name, go with a much shorter LookupKeys. So
far the LookupKeys{UUID|Name} API's (patch 4) aren't used and could be
dropped if it's felt no future API would need them.
Former patches 7 & 8 dealing with the generic @def and @newDef object
were tossed away and the rest of the logic I'd be changing for virObject is
presented as the remaining (new to reviewers) patches 5 -> 16.
The object is named using LookupHash which is a follow-on of the LookupKeys.
If someone has better suggestion for names, then please provide suggestions
rather than just saying I hate the name! It's not my favorite name, but it
does convey what it is and IMO is better than just Element.
The patches also include the Interface object changes to illustrate that the
changes do work. I've run them through the various "interface" tests from the
Avocado VT test suite. I also did something similar for the Secret object in
my private branch, but did not include that since there are 8 patches on list
waiting to be reviewed first.
John Ferlan (16):
util: Generate a common internal only error print
util: Add safety net of checks to ensure valid object
util: Introduce virObjectLookupKeys
util: Introduce virObjectLookupKeysGet{UUID|Name}
interface: Use virObjectLookupKeys
util: Introduce virObjectLookupKeys*Active API's
interface: Use virObjectLookupKeys*Active
util: Introduce virObjectLookupHash
util: Introduce virObjectLoookupHashGet{UUID|Name}
util: Introduce virObjectLookupHash{Add|Remove}
util: Introduce virObjectLookupHashFind
util: Introduce virObjectLookupHashForEach
util: Introduce virObjectLookupHashSearch
util: Introduce virObjectLookupHashClone
interface: Use virObjectLookupHash
test: Clean up test driver Interface interactions
src/conf/virinterfaceobj.c | 332 ++++++++++++++----------
src/libvirt_private.syms | 16 ++
src/test/test_driver.c | 55 +---
src/util/virobject.c | 613 ++++++++++++++++++++++++++++++++++++++++++++-
src/util/virobject.h | 111 ++++++++
5 files changed, 938 insertions(+), 189 deletions(-)
--
2.9.4
7 years, 4 months
[libvirt] [PATCH 00/16] Make the virNetworkObjPtr private
by John Ferlan
All part of the effort I have to have a common object model. This series
is network test, driver, and virnetworkobj related to work towards that
goal. By the last patch, the object is now private to virnetworkobj.c
John Ferlan (16):
test: Fix up formatting in network test API's
test: Use consistent variable names for network test driver APIs
network: Perform some formatting cleanup in bridge_driver
network: Use consistent naming in bridge_driver for virNetwork objects
network: Move macmap mgmt from bridge_driver to virnetworkobj
network: Add virNetworkObj Get/Set API's for @dnsmasqPid and @radvdPid
network: Alter virNetworkObj @class_id to be @classIdMap
network: Add virNetworkObj Get/Set API's for @floor_sum
network: Add virNetworkObj Get API's for @def and @newDef
network: Introduce virNetworkObj{Get|Set}Autostart
network: Introduce virNetworkObj{Is|Set}Active
network: Introduce virNetworkObjIsPersistent
network: Consistent use of @obj for virnetworkobj
network: Adjust virNetworkObjNew call and return
network: Modify naming for virNetworkObjList* fetching APIs
network: Privatize virNetworkObj
src/conf/virnetworkobj.c | 679 +++++++++++++++------
src/conf/virnetworkobj.h | 107 +++-
src/libvirt_private.syms | 20 +
src/network/bridge_driver.c | 1415 +++++++++++++++++++++++--------------------
src/network/bridge_driver.h | 50 +-
src/test/test_driver.c | 279 +++++----
tests/networkxml2conftest.c | 13 +-
7 files changed, 1538 insertions(+), 1025 deletions(-)
--
2.9.3
7 years, 4 months
[libvirt] [PATCH RESEND] qemu: Remove inactive vm when failed to start it
by Yi Wang
Libvirt forgets to remove inactive vm when failed to start a defined vm.
That may result in residual domain in driver->domains on such condition:
during the process of starting a vm, undefine it, and qemu exit because
of some exception. As we undefined the vm successfully, the vm->persistent
was set to 0, we will always fail to undefine it until restart libvirtd.
Signed-off-by: Yi Wang <wang.yi59(a)zte.com.cn>
---
src/qemu/qemu_driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cdb727b..af8afab 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7185,6 +7185,8 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
endjob:
qemuProcessEndJob(driver, vm);
+ if (ret < 0)
+ qemuDomainRemoveInactive(driver, vm);
cleanup:
virDomainObjEndAPI(&vm);
--
1.8.3.1
7 years, 5 months
[libvirt] [PATCH v2] qemu: Remove duplicated code in qemuBuildSerialChrDeviceStr()
by Andrea Bolognani
The call to qemuBuildDeviceAddressStr() happens no matter
what, so we can move it to the outer possible scope inside
the function.
We can also move the call to virBufferAsprintf() after all
the checks have been performed, where it makes more sense.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_command.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c53ab97..5118541 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10292,14 +10292,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
serial->info.alias);
- if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
- goto error;
}
} else {
- virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
- virDomainChrSerialTargetTypeToString(serial->targetType),
- serial->info.alias, serial->info.alias);
-
switch (serial->targetType) {
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) {
@@ -10314,9 +10308,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
_("usb-serial requires address of usb type"));
goto error;
}
-
- if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
- goto error;
break;
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
@@ -10326,9 +10317,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
_("isa-serial requires address of isa type"));
goto error;
}
-
- if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
- goto error;
break;
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
@@ -10344,13 +10332,17 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
_("pci-serial requires address of pci type"));
goto error;
}
-
- if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
- goto error;
break;
}
+
+ virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
+ virDomainChrSerialTargetTypeToString(serial->targetType),
+ serial->info.alias, serial->info.alias);
}
+ if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
+ goto error;
+
if (virBufferCheckError(&cmd) < 0)
goto error;
--
2.7.5
7 years, 5 months
[libvirt] [PATCH 00/19] Start altering storage code to privatize of the object
by John Ferlan
Begin the process of making adjustments to the storage pool and volume code
in order to privatize the virStoragePoolObj and virStoragePoolObjList
Didn't want to post 40+ patches at one time... This is the first storage
pile including some test driver cleanups w/r/t storage code.
John Ferlan (19):
test: Fix up formatting in storage test API's
test: Use consistent variable names for storage test driver APIs
test: Cleanup exit/failure paths of some storage pool APIs
test: Add helpers to fetch active/inactive storage pool by name
test: Add testStorageVolDefFindByName for storage volume tests
storage: Fix return value checks for virAsprintf
storage: Use consistent variable names in virstorageobj
storage: Use consistent variable names for driver
storage: Alter volume num, name, and export API's to just take obj
storage: Create accessor API's for virStoragePoolObj
storage: Introduce virStoragePoolObjNew
storage: Introduce virStoragePoolObj{Get|Set}Autostart
storage: Move autostartLink deletion to virstorageobj
storage: Introduce storage volume add, delete, count APIs
storage: Introduce virStoragePoolObjForEachVolume
storage: Use virStoragePoolObj accessors for driver
storage: Use virStoragePoolObj accessors for storage test API's
storage: Use virStoragePoolObj accessors for storage_util
storage: Change storage_util to use obj instead of pool
src/conf/virstorageobj.c | 568 +++++++++-----
src/conf/virstorageobj.h | 84 +-
src/libvirt_private.syms | 16 +
src/storage/storage_backend_disk.c | 31 +-
src/storage/storage_backend_gluster.c | 3 +-
src/storage/storage_backend_logical.c | 5 +-
src/storage/storage_backend_mpath.c | 3 +-
src/storage/storage_backend_rbd.c | 12 +-
src/storage/storage_backend_sheepdog.c | 8 +-
src/storage/storage_backend_zfs.c | 9 +-
src/storage/storage_driver.c | 1308 ++++++++++++++++----------------
src/storage/storage_driver.h | 4 +-
src/storage/storage_util.c | 200 ++---
src/storage/storage_util.h | 30 +-
src/test/test_driver.c | 780 +++++++++----------
15 files changed, 1614 insertions(+), 1447 deletions(-)
--
2.9.3
7 years, 5 months