Re: [libvirt] [ 0/5] netdev ethernet allow to set ip, route and peer address
2016-04-07 20:38 GMT+03:00 Daniel P. Berrange: > I fixed the few problems with this and pushed it to git. Thank you for help! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Unsupported network type ethernet
Thanks Daniel. I'm trying to run software Opencontrail on ARM arch which in turn usses libvirt with network type=ethernet.I cannot use type=bridge or type=network for connectivity of the guest LXC VMs. *Thanks Vasiliy*Please let me know once we are ready with the patches for ethernet support. Regards Sonia Verma On Thu, Apr 7, 2016 at 8:10 PM, Vasiliy Tolstovwrote: > 2016-04-07 17:25 GMT+03:00 Daniel P. Berrange : > > We don't currently have support for it for LXC - we recommend using > > type=bridge or type=network for connectivity. We would consider patches > > for type=ethernet though if someone wants to write them > > > > > > Regards, > > Daniel > > > I can take this after my ip route stuff been applied for qemu. > > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 01/10] virsh: report when vz driver is compiled
Signed-off-by: Maxim Nestratov--- tools/virsh.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virsh.c b/tools/virsh.c index fe33839..5a61189 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -580,6 +580,9 @@ virshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED) #ifdef WITH_OPENVZ vshPrint(ctl, " OpenVZ"); #endif +#ifdef WITH_VZ +vshPrint(ctl, " Virtuozzo"); +#endif #ifdef WITH_VMWARE vshPrint(ctl, " VMware"); #endif -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 07/10] vz: implement connectGetSysinfo hypervisor callback
Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 25 + src/vz/vz_utils.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index e9fe89f..dce7a87 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -177,6 +177,7 @@ static void vzDriverDispose(void * obj) virObjectUnref(conn->domains); virObjectUnref(conn->caps); virObjectUnref(conn->xmlopt); +virSysinfoDefFree(conn->hostsysinfo); virObjectEventStateFree(conn->domainEventState); } @@ -310,6 +311,7 @@ vzDriverObjNew(void) return NULL; } +conn->hostsysinfo = virSysinfoRead(); prlsdkLoadDomains(conn); return conn; } @@ -423,6 +425,28 @@ static char *vzConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED) return virGetHostname(); } +static char * +vzConnectGetSysinfo(virConnectPtr conn, unsigned int flags) +{ +vzConnPtr privconn = conn->privateData; +vzDriverPtr driver = privconn->driver; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virCheckFlags(0, NULL); + +if (!driver->hostsysinfo) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Host SMBIOS information is not available")); +return NULL; +} + +if (virSysinfoFormat(, driver->hostsysinfo) < 0) +return NULL; +if (virBufferCheckError() < 0) +return NULL; + +return virBufferContentAndReset(); +} static int vzConnectListDomains(virConnectPtr conn, int *ids, int maxids) @@ -1559,6 +1583,7 @@ static virHypervisorDriver vzHypervisorDriver = { .connectClose = vzConnectClose, /* 0.10.0 */ .connectGetVersion = vzConnectGetVersion, /* 0.10.0 */ .connectGetHostname = vzConnectGetHostname, /* 0.10.0 */ +.connectGetSysinfo = vzConnectGetSysinfo, /* 1.3.4 */ .connectGetMaxVcpus = vzConnectGetMaxVcpus, /* 1.2.21 */ .nodeGetInfo = vzNodeGetInfo, /* 0.10.0 */ .nodeGetCPUStats = vzNodeGetCPUStats, /* 1.2.21 */ diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index ce2fd92..01a680c 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -72,6 +72,7 @@ struct _vzDriver { virObjectEventStatePtr domainEventState; /* Immutable pointer, self-locking APIs */ virConnectCloseCallbackDataPtr closeCallback; +virSysinfoDefPtr hostsysinfo; unsigned long vzVersion; vzCapabilities vzCaps; }; -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 03/10] vz: remove drivername field from vzConn structure
No need to remember connection name and have corresponding domain type to keep backward compatibility with former 'parallels' driver. It is enough to be able to accept 'parallels' uri and domain types. Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 2 -- src/vz/vz_utils.c | 5 + src/vz/vz_utils.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 47a5060..9de88cd 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -228,8 +228,6 @@ vzOpenDefault(virConnectPtr conn) goto err_free; } -privconn->drivername = conn->driver->name; - if (prlsdkInit()) { VIR_DEBUG("%s", _("Can't initialize Parallels SDK")); goto err_free; diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index fed48a5..64e469c 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -178,10 +178,7 @@ vzNewDomain(vzConnPtr privconn, char *name, const unsigned char *uuid) pdom->cache.stats = PRL_INVALID_HANDLE; pdom->cache.count = -1; -if (STREQ(privconn->drivername, "vz")) -def->virtType = VIR_DOMAIN_VIRT_VZ; -else -def->virtType = VIR_DOMAIN_VIRT_PARALLELS; +def->virtType = VIR_DOMAIN_VIRT_VZ; if (!(dom = virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index f373850..b415b0f 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -70,7 +70,6 @@ struct _vzConn { virCapsPtr caps; virDomainXMLOptionPtr xmlopt; virObjectEventStatePtr domainEventState; -const char *drivername; /* Immutable pointer, self-locking APIs */ virConnectCloseCallbackDataPtr closeCallback; unsigned long vzVersion; -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 09/10] vz: minor cleanup
remove unnecessary vzConnectClose prototype and make local structure vzDomainDefParserConfig be static Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 50da2fe..b3ce404 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -62,7 +62,6 @@ VIR_LOG_INIT("parallels.parallels_driver"); #define PRLCTL "prlctl" -static int vzConnectClose(virConnectPtr conn); static virClassPtr vzDriverConnClass; static virMutex vz_driver_lock; @@ -266,7 +265,7 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, } -virDomainDefParserConfig vzDomainDefParserConfig = { +static virDomainDefParserConfig vzDomainDefParserConfig = { .macPrefix = {0x42, 0x1C, 0x00}, .devicesPostParseCallback = vzDomainDeviceDefPostParse, .domainPostParseCallback = vzDomainDefPostParse, -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 00/10] vz: change vz driver to be stateful driver and other enhancements
There is no benefit in providing two ways of connecting to vz driver: by connecting via daemon and directly from client. Both ways finally come to a host where vz daemon sits. Always connecting via daemon allows us to have a single list of domains and share it among all connections. Since v1: removed patch "z: remove close callback implementations" building fixed close callback functions are added to libvirt_private.syms reworked not to lose event subscribers when connections drop Maxim Nestratov (10): virsh: report when vz driver is compiled vz: change the order of capabilities reported vz: remove drivername field from vzConn structure vz: add Hypervisor prefix to vz and parallels Driver structures vz: build driver as module and don't register it on client's side vz: introduce new vzDriver lockable structure and use it vz: implement connectGetSysinfo hypervisor callback vz: remove vzDriverLock/Unlock function vz: minor cleanup vz: change vzConnectIsAlive behavior daemon/Makefile.am | 4 + daemon/libvirtd.c| 9 ++ src/Makefile.am | 20 ++- src/libvirt.c| 7 - src/libvirt_private.syms | 6 + src/vz/vz_driver.c | 414 +-- src/vz/vz_sdk.c | 211 src/vz/vz_sdk.h | 30 ++-- src/vz/vz_utils.c| 32 ++-- src/vz/vz_utils.h| 33 +++- tools/virsh.c| 3 + 11 files changed, 452 insertions(+), 317 deletions(-) -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 04/10] vz: add Hypervisor prefix to vz and parallels Driver structures
--- src/vz/vz_driver.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 9de88cd..f2bbf1e 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1491,7 +1491,7 @@ vzConnectUnregisterCloseCallback(virConnectPtr conn, virConnectCloseFunc cb) return ret; } -static virHypervisorDriver vzDriver = { +static virHypervisorDriver vzHypervisorDriver = { .name = "vz", .connectOpen = vzConnectOpen,/* 0.10.0 */ .connectClose = vzConnectClose, /* 0.10.0 */ @@ -1558,11 +1558,11 @@ static virHypervisorDriver vzDriver = { }; static virConnectDriver vzConnectDriver = { -.hypervisorDriver = , +.hypervisorDriver = , }; /* Parallels domain type backward compatibility*/ -static virHypervisorDriver parallelsDriver; +static virHypervisorDriver parallelsHypervisorDriver; static virConnectDriver parallelsConnectDriver; /** @@ -1584,10 +1584,10 @@ vzRegister(void) VIR_FREE(prlctl_path); /* Backward compatibility with Parallels domain type */ -parallelsDriver = vzDriver; -parallelsDriver.name = "Parallels"; +parallelsHypervisorDriver = vzHypervisorDriver; +parallelsHypervisorDriver.name = "Parallels"; parallelsConnectDriver = vzConnectDriver; -parallelsConnectDriver.hypervisorDriver = +parallelsConnectDriver.hypervisorDriver = if (virRegisterConnectDriver(, false) < 0) return -1; -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 08/10] vz: remove vzDriverLock/Unlock function
We don't need them anymore as all pointers within vzDriver structure are not changed during the time it exists. Where we still need to synchronize we use virObjectLock/Unlock as far as vzDriver is lockable object. Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 35 --- src/vz/vz_utils.h | 2 -- 2 files changed, 37 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index dce7a87..50da2fe 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -65,17 +65,6 @@ VIR_LOG_INIT("parallels.parallels_driver"); static int vzConnectClose(virConnectPtr conn); static virClassPtr vzDriverConnClass; -void -vzDriverLock(vzConnPtr privconn) -{ -virObjectLock(privconn->driver); -} - -void -vzDriverUnlock(vzConnPtr privconn) -{ -virObjectUnlock(privconn->driver); -} static virMutex vz_driver_lock; static vzDriverPtr vz_driver; static vzConnPtr vz_conn_list; @@ -235,9 +224,7 @@ vzConnectGetCapabilities(virConnectPtr conn) vzConnPtr privconn = conn->privateData; char *xml; -vzDriverLock(privconn); xml = virCapabilitiesFormatXML(privconn->driver->caps); -vzDriverUnlock(privconn); return xml; } @@ -454,10 +441,8 @@ vzConnectListDomains(virConnectPtr conn, int *ids, int maxids) vzConnPtr privconn = conn->privateData; int n; -vzDriverLock(privconn); n = virDomainObjListGetActiveIDs(privconn->driver->domains, ids, maxids, NULL, NULL); -vzDriverUnlock(privconn); return n; } @@ -468,10 +453,8 @@ vzConnectNumOfDomains(virConnectPtr conn) vzConnPtr privconn = conn->privateData; int count; -vzDriverLock(privconn); count = virDomainObjListNumOfDomains(privconn->driver->domains, true, NULL, NULL); -vzDriverUnlock(privconn); return count; } @@ -484,11 +467,9 @@ vzConnectListDefinedDomains(virConnectPtr conn, vzConnPtr privconn = conn->privateData; int n; -vzDriverLock(privconn); memset(names, 0, sizeof(*names) * maxnames); n = virDomainObjListGetInactiveNames(privconn->driver->domains, names, maxnames, NULL, NULL); -vzDriverUnlock(privconn); return n; } @@ -499,11 +480,8 @@ vzConnectNumOfDefinedDomains(virConnectPtr conn) vzConnPtr privconn = conn->privateData; int count; -vzDriverLock(privconn); count = virDomainObjListNumOfDomains(privconn->driver->domains, false, NULL, NULL); -vzDriverUnlock(privconn); - return count; } @@ -516,10 +494,8 @@ vzConnectListAllDomains(virConnectPtr conn, int ret = -1; virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1); -vzDriverLock(privconn); ret = virDomainObjListExport(privconn->driver->domains, conn, domains, NULL, flags); -vzDriverUnlock(privconn); return ret; } @@ -531,9 +507,7 @@ vzDomainLookupByID(virConnectPtr conn, int id) virDomainPtr ret = NULL; virDomainObjPtr dom; -vzDriverLock(privconn); dom = virDomainObjListFindByID(privconn->driver->domains, id); -vzDriverUnlock(privconn); if (dom == NULL) { virReportError(VIR_ERR_NO_DOMAIN, NULL); @@ -557,10 +531,7 @@ vzDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virDomainPtr ret = NULL; virDomainObjPtr dom; -vzDriverLock(privconn); - dom = virDomainObjListFindByUUID(privconn->driver->domains, uuid); -vzDriverUnlock(privconn); if (dom == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -587,9 +558,7 @@ vzDomainLookupByName(virConnectPtr conn, const char *name) virDomainPtr ret = NULL; virDomainObjPtr dom; -vzDriverLock(privconn); dom = virDomainObjListFindByName(privconn->driver->domains, name); -vzDriverUnlock(privconn); if (dom == NULL) { virReportError(VIR_ERR_NO_DOMAIN, @@ -1537,7 +1506,6 @@ vzConnectRegisterCloseCallback(virConnectPtr conn, vzConnPtr privconn = conn->privateData; int ret = -1; -vzDriverLock(privconn); if (virConnectCloseCallbackDataGetCallback(privconn->closeCallback) != NULL) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("A close callback is already registered")); @@ -1549,7 +1517,6 @@ vzConnectRegisterCloseCallback(virConnectPtr conn, ret = 0; cleanup: -vzDriverUnlock(privconn); return ret; } @@ -1560,7 +1527,6 @@ vzConnectUnregisterCloseCallback(virConnectPtr conn, virConnectCloseFunc cb) vzConnPtr privconn = conn->privateData; int ret = -1; -vzDriverLock(privconn); if (virConnectCloseCallbackDataGetCallback(privconn->closeCallback) != cb) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1572,7 +1538,6 @@ vzConnectUnregisterCloseCallback(virConnectPtr conn,
[libvirt] [PATCH v2 02/10] vz: change the order of capabilities reported
'vz' goes first now to make clients like virt-manager choose 'vz' instead of 'parallels' Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index e12a95a..47a5060 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -109,10 +109,10 @@ vzBuildCapabilities(void) VIR_DOMAIN_OSTYPE_EXE }; virArch archs[] = { VIR_ARCH_I686, VIR_ARCH_X86_64 }; -const char *const emulators[] = { "parallels", "vz" }; +const char *const emulators[] = { "vz", "parallels"}; virDomainVirtType virt_types[] = { -VIR_DOMAIN_VIRT_PARALLELS, -VIR_DOMAIN_VIRT_VZ +VIR_DOMAIN_VIRT_VZ, +VIR_DOMAIN_VIRT_PARALLELS }; size_t i, j, k; -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 05/10] vz: build driver as module and don't register it on client's side
Make it possible to build vz driver as a module and don't link it with libvirt.so statically. Remove registering it on client's side as far as we start relying on daemon Signed-off-by: Maxim Nestratov--- daemon/Makefile.am | 4 daemon/libvirtd.c| 9 + src/Makefile.am | 20 +++- src/libvirt.c| 7 --- src/libvirt_private.syms | 6 ++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 2dbe81b..78d7d21 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -233,6 +233,10 @@ if WITH_VBOX libvirtd_LDADD += ../src/libvirt_driver_vbox.la endif WITH_VBOX +if WITH_VZ +libvirtd_LDADD += ../src/libvirt_driver_vz.la +endif WITH_VZ + if WITH_STORAGE libvirtd_LDADD += ../src/libvirt_driver_storage.la endif WITH_STORAGE diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 3d38a46..92b4080 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -102,6 +102,9 @@ # include "nwfilter/nwfilter_driver.h" # endif #endif +#ifdef WITH_VZ +# include "vz/vz_driver.h" +#endif #include "configmake.h" @@ -390,6 +393,9 @@ static void daemonInitialize(void) # ifdef WITH_BHYVE virDriverLoadModule("bhyve"); # endif +# ifdef WITH_VZ +virDriverLoadModule("vz"); +# endif #else # ifdef WITH_NETWORK networkRegister(); @@ -430,6 +436,9 @@ static void daemonInitialize(void) # ifdef WITH_BHYVE bhyveRegister(); # endif +# ifdef WITH_VZ +vzRegister(); +# endif #endif } diff --git a/src/Makefile.am b/src/Makefile.am index eda0365..26a992b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -630,6 +630,7 @@ DRIVER_SOURCE_FILES = \ $(NULL) STATEFUL_DRIVER_SOURCE_FILES = \ + $(VZ_DRIVER_SOURCES) \ $(BHYVE_DRIVER_SOURCES) \ $(INTERFACE_DRIVER_SOURCES) \ $(LIBXL_DRIVER_SOURCES) \ @@ -886,7 +887,8 @@ HYPERV_DRIVER_EXTRA_DIST = \ hyperv/hyperv_wmi_generator.py \ $(HYPERV_DRIVER_GENERATED) -VZ_DRIVER_SOURCES =\ +VZ_DRIVER_SOURCES =\ + util/vircommand.c \ vz/vz_driver.h \ vz/vz_driver.c \ vz/vz_utils.c \ @@ -1493,13 +1495,21 @@ libvirt_driver_hyperv_la_SOURCES = $(HYPERV_DRIVER_SOURCES) endif WITH_HYPERV if WITH_VZ +noinst_LTLIBRARIES += libvirt_driver_vz_impl.la +libvirt_driver_vz_la_SOURCES = +libvirt_driver_vz_la_LIBADD = libvirt_driver_vz_impl.la +if WITH_DRIVER_MODULES +mod_LTLIBRARIES += libvirt_driver_vz.la +libvirt_driver_vz_la_LIBADD += ../gnulib/lib/libgnu.la +libvirt_driver_vz_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_driver_vz.la -libvirt_la_BUILT_LIBADD += libvirt_driver_vz.la -libvirt_driver_vz_la_CFLAGS = \ +endif ! WITH_DRIVER_MODULES +libvirt_driver_vz_impl_la_CFLAGS = \ -I$(srcdir)/conf $(AM_CFLAGS) \ $(PARALLELS_SDK_CFLAGS) $(LIBNL_CFLAGS) -libvirt_driver_vz_la_LIBADD = $(PARALLELS_SDK_LIBS) $(LIBNL_LIBS) -libvirt_driver_vz_la_SOURCES = $(VZ_DRIVER_SOURCES) +libvirt_driver_vz_impl_la_SOURCES = $(VZ_DRIVER_SOURCES) +libvirt_driver_vz_impl_la_LIBADD = $(PARALLELS_SDK_LIBS) $(LIBNL_LIBS) endif WITH_VZ if WITH_BHYVE diff --git a/src/libvirt.c b/src/libvirt.c index dd58e9c..a21d00e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -92,9 +92,6 @@ #ifdef WITH_XENAPI # include "xenapi/xenapi_driver.h" #endif -#ifdef WITH_VZ -# include "vz/vz_driver.h" -#endif #ifdef WITH_BHYVE # include "bhyve/bhyve_driver.h" #endif @@ -433,10 +430,6 @@ virGlobalInit(void) if (xenapiRegister() == -1) goto error; # endif -# ifdef WITH_VZ -if (vzRegister() == -1) -goto error; -# endif #endif #ifdef WITH_REMOTE if (remoteRegister() == -1) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 068bc00..b61db2a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -931,6 +931,11 @@ virGetSecret; virGetStoragePool; virGetStorageVol; virGetStream; +virConnectCloseCallbackDataGetCallback; +virNewConnectCloseCallbackData; +virConnectCloseCallbackDataUnregister; +virConnectCloseCallbackDataRegister; +virConnectCloseCallbackDataCall; virInterfaceClass; virNetworkClass; virNodeDeviceClass; @@ -939,6 +944,7 @@ virSecretClass; virStoragePoolClass; virStorageVolClass; virStreamClass; +virConnectCloseCallbackDataClass; # fdstream.h -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 10/10] vz: change vzConnectIsAlive behavior
Now it detects if a connection to vz dispatcher is up or not by comparing current driver to connection stored pointer. Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index b3ce404..7d7cb17 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -824,8 +824,12 @@ static int vzConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) return 1; } -static int vzConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +static int vzConnectIsAlive(virConnectPtr conn) { +vzConnPtr privconn = conn->privateData; +if (privconn->driver != vz_driver) +return 0; + return 1; } -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 06/10] vz: introduce new vzDriver lockable structure and use it
This patch introduces a new 'vzDriver' lockable object and provides helper functions to allocate/destroy it and we pass it to prlsdkXxx functions instead of virConnectPtr. Now we store domain related objects such as domain list, capabitilies etc. within a single vz_driver vzDriver structure, which is shared by all driver connections. It is allocated during daemon initialization or in a lazy manner when a new connection to 'vz' driver is established. When a connection to vz daemon drops, vzDestroyConnection is called, which in turn relays disconnect event to all connection to 'vz' driver. Signed-off-by: Maxim Nestratov--- src/vz/vz_driver.c | 339 +++-- src/vz/vz_sdk.c| 211 - src/vz/vz_sdk.h| 30 ++--- src/vz/vz_utils.c | 27 +++-- src/vz/vz_utils.h | 29 - 5 files changed, 380 insertions(+), 256 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f2bbf1e..e9fe89f 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -63,18 +63,25 @@ VIR_LOG_INIT("parallels.parallels_driver"); #define PRLCTL "prlctl" static int vzConnectClose(virConnectPtr conn); +static virClassPtr vzDriverConnClass; void -vzDriverLock(vzConnPtr driver) +vzDriverLock(vzConnPtr privconn) { -virMutexLock(>lock); +virObjectLock(privconn->driver); } void -vzDriverUnlock(vzConnPtr driver) +vzDriverUnlock(vzConnPtr privconn) { -virMutexUnlock(>lock); +virObjectUnlock(privconn->driver); } +static virMutex vz_driver_lock; +static vzDriverPtr vz_driver; +static vzConnPtr vz_conn_list; + +static vzDriverPtr +vzDriverObjNew(void); static int vzCapsAddGuestDomain(virCapsPtr caps, @@ -158,6 +165,69 @@ vzBuildCapabilities(void) goto cleanup; } +static void vzDriverDispose(void * obj) +{ +vzDriverPtr conn = obj; + +if (conn->server) { +prlsdkUnsubscribeFromPCSEvents(conn); +prlsdkDisconnect(conn); +} + +virObjectUnref(conn->domains); +virObjectUnref(conn->caps); +virObjectUnref(conn->xmlopt); +virObjectEventStateFree(conn->domainEventState); +} + +static int vzDriverOnceInit(void) +{ +if (!(vzDriverConnClass = virClassNew(virClassForObjectLockable(), +"vzDriver", +sizeof(vzDriver), +vzDriverDispose))) +return -1; + +return 0; +} +VIR_ONCE_GLOBAL_INIT(vzDriver) + +vzDriverPtr +vzGetDriverConnection(void) +{ +virMutexLock(_driver_lock); +if (!vz_driver) +vz_driver = vzDriverObjNew(); +virObjectRef(vz_driver); +virMutexUnlock(_driver_lock); +return vz_driver; +} + +void +vzDestroyDriverConnection(void) +{ + +vzDriverPtr driver; +vzConnPtr privconn_list; + +virMutexLock(_driver_lock); +driver = vz_driver; +vz_driver = NULL; + +privconn_list = vz_conn_list; +vz_conn_list = NULL; + +virMutexUnlock(_driver_lock); + +while (privconn_list) { +vzConnPtr privconn = privconn_list; +privconn_list = privconn->next; +virConnectCloseCallbackDataCall(privconn->closeCallback, +VIR_CONNECT_CLOSE_REASON_EOF); +} +virObjectUnref(driver); +} + static char * vzConnectGetCapabilities(virConnectPtr conn) { @@ -165,7 +235,7 @@ vzConnectGetCapabilities(virConnectPtr conn) char *xml; vzDriverLock(privconn); -xml = virCapabilitiesFormatXML(privconn->caps); +xml = virCapabilitiesFormatXML(privconn->driver->caps); vzDriverUnlock(privconn); return xml; } @@ -214,70 +284,34 @@ virDomainDefParserConfig vzDomainDefParserConfig = { .domainPostParseCallback = vzDomainDefPostParse, }; - -static int -vzOpenDefault(virConnectPtr conn) +static vzDriverPtr +vzDriverObjNew(void) { -vzConnPtr privconn; - -if (VIR_ALLOC(privconn) < 0) -return VIR_DRV_OPEN_ERROR; -if (virMutexInit(>lock) < 0) { -virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize mutex")); -goto err_free; -} +vzDriverPtr conn; -if (prlsdkInit()) { -VIR_DEBUG("%s", _("Can't initialize Parallels SDK")); -goto err_free; -} - -if (prlsdkConnect(privconn) < 0) -goto err_free; - -if (vzInitVersion(privconn) < 0) -goto error; - -if (!(privconn->caps = vzBuildCapabilities())) -goto error; - -vzDomainDefParserConfig.priv = >vzCaps; -if (!(privconn->xmlopt = virDomainXMLOptionNew(, - NULL, NULL))) -goto error; - -if (!(privconn->domains = virDomainObjListNew())) -goto error; - -if (!(privconn->domainEventState = virObjectEventStateNew())) -goto error; - -if (prlsdkSubscribeToPCSEvents(privconn)) -goto error; - -if (!(privconn->closeCallback =
Re: [libvirt] [PATCH] libxl: libxl_domain_create_restore has an extra argument
On Thu, Apr 07, 2016 at 05:35:33PM +0100, Daniel P. Berrange wrote: > On Wed, Apr 06, 2016 at 04:43:07PM -0500, Doug Goldstein wrote: > > On 4/5/16 9:20 AM, Wei Liu wrote: > > > In the latest libxenlight code, libxl_domain_create_restore accepts a > > > new argument. Update libvirt's libxl driver for that. Use the macro > > > provided by libxenlight to detect which version should be used. > > > > > > The new parameter (send_back_fd) is set to -1 because libvirt provides > > > no such fd. > > > > > > Signed-off-by: Wei Liu> > > --- > > > Build test with Xen 4.6.1 (old API) and Xen unstable (new API). > > > --- > > > src/libxl/libxl_domain.c | 7 ++- > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c > > > index 04962a0..aed904b 100644 > > > --- a/src/libxl/libxl_domain.c > > > +++ b/src/libxl/libxl_domain.c > > > @@ -1070,7 +1070,12 @@ libxlDomainStart(libxlDriverPrivatePtr driver, > > > virDomainObjPtr vm, > > > ret = libxl_domain_create_new(cfg->ctx, _config, > > >, NULL, _console_how); > > > } else { > > > -#ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS > > > +#if defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD) > > > +params.checkpointed_stream = 0; > > > +ret = libxl_domain_create_restore(cfg->ctx, _config, , > > > + restore_fd, -1, , NULL, > > > + _console_how); > > > +#elif defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS) > > > params.checkpointed_stream = 0; > > > ret = libxl_domain_create_restore(cfg->ctx, _config, , > > >restore_fd, , NULL, > > > > > > > ACK > > > > This fixes integration testing that Xen Project does with libvirt and > > Xen so it would be nice to get in for 1.3.3. > > It missed the boat for 1.3.3, but I've pushed it now > Thank you very much for pushing this! Wei. > > > Regards, > Daniel > -- > |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| > |: http://libvirt.org -o- http://virt-manager.org :| > |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| > |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 5/5] qemu domain allow to set ip address, peer address and route
On Mon, Apr 04, 2016 at 09:00:06PM +, Vasiliy Tolstov wrote: > Signed-off-by: Vasiliy Tolstov> --- > src/qemu/qemu_interface.c | 39 +++ > 1 file changed, 39 insertions(+) > > diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c > index 13a513152876..5729325fadb9 100644 > --- a/src/qemu/qemu_interface.c > +++ b/src/qemu/qemu_interface.c > @@ -474,6 +474,45 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, > if (virNetDevSetMAC(net->ifname, ) < 0) > goto cleanup; > > +for (j = 0; j < net->nips; j++) { > +virDomainNetIpDefPtr ip = net->ips[j]; > +unsigned int prefix = (ip->prefix > 0) ? ip->prefix : > +VIR_SOCKET_ADDR_DEFAULT_PREFIX; > +char *ipStr = virSocketAddrFormat(>address); > + > +VIR_DEBUG("Adding IP address '%s/%u' to '%s'", > + ipStr, ip->prefix, net->ifname); > + > +if (virNetDevSetIPAddress(net->ifname, >address, >peer, > prefix) < 0) { > +virReportError(VIR_ERR_SYSTEM_ERROR, > + _("Failed to set IP address '%s' on %s"), > + ipStr, net->ifname); > +VIR_FREE(ipStr); > +goto cleanup; > +} > +VIR_FREE(ipStr); > +} > + > +if (net->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP || > +net->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT) { > +if (virNetDevSetOnline(net->ifname, true) < 0) > +goto cleanup; With this call added, we break the unit tests, but that's easy to fix by adding a stub to the qemuxml2argvmock.c file, so I've made that change ACK Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 0/5] netdev ethernet allow to set ip, route and peer address
On Thu, Apr 07, 2016 at 06:35:43PM +0100, Daniel P. Berrange wrote: > On Mon, Apr 04, 2016 at 09:00:01PM +, Vasiliy Tolstov wrote: > > Some minor improvements and patch split as suggested by Laine Stump > > FYI, make sure you include the word PATCH in mails, so they get > picked up by out patch tracking too, otherwise they could get > left without being noticed. I fixed the few problems with this and pushed it to git. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 3/5] lxc domain allow to set peer address
On Mon, Apr 04, 2016 at 09:00:04PM +, Vasiliy Tolstov wrote: > Signed-off-by: Vasiliy Tolstov> --- > src/lxc/lxc_container.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c > index 348bbfbc01fc..a1deb0c00d4c 100644 > --- a/src/lxc/lxc_container.c > +++ b/src/lxc/lxc_container.c > @@ -520,7 +520,7 @@ static int > lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef, > > VIR_DEBUG("Adding IP address '%s/%u' to '%s'", >ipStr, ip->prefix, newname); > -if (virNetDevSetIPAddress(newname, >address, prefix) < 0) { > +if (virNetDevSetIPAddress(newname, >address, >peer, > prefix) < 0) { > virReportError(VIR_ERR_SYSTEM_ERROR, > _("Failed to set IP address '%s' on %s"), > ipStr, newname); ACK Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 2/5] libvirt domain xml allow to set peer address
On Mon, Apr 04, 2016 at 09:00:03PM +, Vasiliy Tolstov wrote: > Signed-off-by: Vasiliy Tolstov> --- > docs/formatdomain.html.in | 12 +++- > docs/schemas/domaincommon.rng | 5 + > src/conf/domain_conf.c| 14 +- > src/conf/domain_conf.h| 1 + > 4 files changed, 30 insertions(+), 2 deletions(-) ACK Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 4/5] bridge network ignore peer address
On Mon, Apr 04, 2016 at 09:00:05PM +, Vasiliy Tolstov wrote: > Signed-off-by: Vasiliy Tolstov> --- > src/network/bridge_driver.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c > index 0d14e3a3..73236ffe1cd9 100644 > --- a/src/network/bridge_driver.c > +++ b/src/network/bridge_driver.c > @@ -1971,7 +1971,7 @@ networkAddAddrToBridge(virNetworkObjPtr network, > } > > if (virNetDevSetIPAddress(network->def->bridge, > - >address, prefix) < 0) > + >address, NULL, prefix) < 0) > return -1; This just gets squashed into the first patch Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 1/5] virnetdev allow to set peer address
On Mon, Apr 04, 2016 at 09:00:02PM +, Vasiliy Tolstov wrote: > Signed-off-by: Vasiliy Tolstov> --- > src/util/virnetdev.c | 54 > > src/util/virnetdev.h | 1 + > 2 files changed, 39 insertions(+), 16 deletions(-) > diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h > index e7719d58a410..240fff774d30 100644 > --- a/src/util/virnetdev.h > +++ b/src/util/virnetdev.h > @@ -90,6 +90,7 @@ int virNetDevGetOnline(const char *ifname, > > int virNetDevSetIPAddress(const char *ifname, >virSocketAddr *addr, > + virSocketAddr *peer, >unsigned int prefix) > ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; > int virNetDevAddRoute(const char *ifname, Since you've added a new parameter to this method, this patch ought to also add 'NULL' to each place in the code which currently uses this API, otherwise the build breaks after applying just this patch. ACK, I'll fix that when pushing. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [ 0/5] netdev ethernet allow to set ip, route and peer address
On Mon, Apr 04, 2016 at 09:00:01PM +, Vasiliy Tolstov wrote: > Some minor improvements and patch split as suggested by Laine Stump FYI, make sure you include the word PATCH in mails, so they get picked up by out patch tracking too, otherwise they could get left without being noticed. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] 200ms delay waiting for qemu monitor
On Thu, Apr 07, 2016 at 09:08:38AM +0200, Michal Privoznik wrote: > On 06.04.2016 21:45, Richard W.M. Jones wrote: > > [Thanks to Dan Berrangé for doing the analysis of this one] > > > > I was investigating a 200+ millisecond delay when libvirt starts a > > qemu guest. You can see the traces here: > > > > http://oirase.annexia.org/tmp/libvirt.log > > http://oirase.annexia.org/tmp/libvirtd.log > > > > The delay happens at around 16:52:57.327-6:52:57.528 in the libvirtd log. > > As you can see the delay is almost precisely 200ms. > > > > Dan found the cause which seems to be this code: > > > > https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor.c;h=10a6713c06ad36e2055f8144fba00b78630971e5;hb=HEAD#l365 > > > > (There are other examples of the same anti-pattern in src/fdstream.c > > and src/qemu/qemu_agent.c, but it's the particular code above which > > seems to be causing the delay). > > > > To give you some sense why I regard this as a problem, the TOTAL time > > taken to launch and shutdown the libguestfs appliance (that includes > > qemu, BIOS, guest kernel, probing and mouting disks, running the > > guestfs daemon, and the shutdown process in reverse), without libvirt, > > is now 900ms. Libvirt adds about 220ms on top of this. > > > > What can we do about this? Obviously we could simply reduce the > > delay, but even if it was set to 20ms, that would be too much (aim is > > to reduce the whole process from 900ms down to 150ms), and it would > > also mean that libvirt was essentially polling. > > > > Can we use inotify to detect if the socket has been created? Seems to > > create portability problems. We could do both. ie, we should drop the sleep down to 20ms and poll for correspondingly larger number of iterations. Then also use inotify where it is available to avoid having todo the sleep at all on Linux. The combination of the two get reasonable speed in platform agnostic case, and perfect speed in the linux case. This would address the immediate need for libguestfs with existing QEMU versions. We should none the less work on FD passing for the long term solution. > > > > Dan suggested: > > > > Can we create the socket in libvirtd and pass it to qemu? > > > > Can we pass a file descriptor to qemu? > > Right. This is the goal that we try to reach. Well, not that anybody I > know of is working on it actively. But the idea would be that libvirt > would open all the files for qemu and then just pass the FDs. > As for the monitor - I think qemu counterpart should be fairly easy, but > we rather confirm with qemu guys. I'm definitely in! QEMU chardevs have the ability to have a FD passed in, but that only works by accident and only for file based backend. You can't currently pass in a FD associated with a UNIX socket. It should be pretty trivial to enhance QEMU to allow this to be done though. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] libxl: libxl_domain_create_restore has an extra argument
On Wed, Apr 06, 2016 at 04:43:07PM -0500, Doug Goldstein wrote: > On 4/5/16 9:20 AM, Wei Liu wrote: > > In the latest libxenlight code, libxl_domain_create_restore accepts a > > new argument. Update libvirt's libxl driver for that. Use the macro > > provided by libxenlight to detect which version should be used. > > > > The new parameter (send_back_fd) is set to -1 because libvirt provides > > no such fd. > > > > Signed-off-by: Wei Liu> > --- > > Build test with Xen 4.6.1 (old API) and Xen unstable (new API). > > --- > > src/libxl/libxl_domain.c | 7 ++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c > > index 04962a0..aed904b 100644 > > --- a/src/libxl/libxl_domain.c > > +++ b/src/libxl/libxl_domain.c > > @@ -1070,7 +1070,12 @@ libxlDomainStart(libxlDriverPrivatePtr driver, > > virDomainObjPtr vm, > > ret = libxl_domain_create_new(cfg->ctx, _config, > >, NULL, _console_how); > > } else { > > -#ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS > > +#if defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD) > > +params.checkpointed_stream = 0; > > +ret = libxl_domain_create_restore(cfg->ctx, _config, , > > + restore_fd, -1, , NULL, > > + _console_how); > > +#elif defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS) > > params.checkpointed_stream = 0; > > ret = libxl_domain_create_restore(cfg->ctx, _config, , > >restore_fd, , NULL, > > > > ACK > > This fixes integration testing that Xen Project does with libvirt and > Xen so it would be nice to get in for 1.3.3. It missed the boat for 1.3.3, but I've pushed it now Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] add func to set shared drivers after libvirtd init
19.11.2015 15:22, Mikhail Feoktistov пишет: Diff from v1: Remove vz prefix from the title of this letter. Because this is the common case for all drivers in libvirt. Description: Built-in drivers in libvirt are initialized before libvirtd initialization. Libvirt loads shared drivers on libvirtd initialization step. For built-in drivers we can't set shared drivers, because they are not initialized yet. This patch adds function to set shared drivers after libvirtd init. --- daemon/libvirtd.c| 4 src/libvirt.c| 41 + src/libvirt_internal.h | 1 + src/libvirt_private.syms | 1 + 4 files changed, 47 insertions(+) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 250094b..aac1826 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -431,6 +431,10 @@ static void daemonInitialize(void) bhyveRegister(); # endif #endif +# ifdef WITH_VZ +virAssignSharedDrivers("vz"); +virAssignSharedDrivers("Parallels"); +# endif } diff --git a/src/libvirt.c b/src/libvirt.c index 25a0040..1763be7 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1433,3 +1433,44 @@ virTypedParameterValidateSet(virConnectPtr conn, } return 0; } + +/** + * virAssignSharedDrivers: + * @name: name of connection driver + * + * This function fills in any empty pointers for shared drivers + * in connect driver structure + * + * Returns 0 in case of success, -1 in case of error +*/ +int +virAssignSharedDrivers(const char *name) +{ +size_t i; + +if (name == NULL) { +virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Driver name must be specified")); +return -1; +} + +for (i = 0; i < virConnectDriverTabCount; i++) { +if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, name)) { +if (virConnectDriverTab[i]->interfaceDriver == NULL) +virConnectDriverTab[i]->interfaceDriver = virSharedInterfaceDriver; +if (virConnectDriverTab[i]->networkDriver == NULL) +virConnectDriverTab[i]->networkDriver = virSharedNetworkDriver; +if (virConnectDriverTab[i]->nodeDeviceDriver == NULL) +virConnectDriverTab[i]->nodeDeviceDriver = virSharedNodeDeviceDriver; +if (virConnectDriverTab[i]->nwfilterDriver == NULL) +virConnectDriverTab[i]->nwfilterDriver = virSharedNWFilterDriver; +if (virConnectDriverTab[i]->secretDriver == NULL) +virConnectDriverTab[i]->secretDriver = virSharedSecretDriver; +if (virConnectDriverTab[i]->storageDriver == NULL) +virConnectDriverTab[i]->storageDriver = virSharedStorageDriver; +break; + } +} + +return 0; +} diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 1313b58..2a7227b 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -289,4 +289,5 @@ virTypedParameterValidateSet(virConnectPtr conn, virTypedParameterPtr params, int nparams); +int virAssignSharedDrivers(const char *name); #endif diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a835f18..a0fcdf5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -943,6 +943,7 @@ virFDStreamSetInternalCloseCb; # libvirt_internal.h +virAssignSharedDrivers; virConnectSupportsFeature; virDomainMigrateBegin3; virDomainMigrateBegin3Params; It looks like this patch is not necessary anymore as far as changes proposed in the series [1] seem to be the better way to use shared drivers. Maxim [1] https://www.redhat.com/archives/libvir-list/2016-March/msg01357.html -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/3] qemu: Explicitly check for gnutls_rnd()
On Thu, 2016-04-07 at 11:46 -0400, John Ferlan wrote: > > configure: Restore CFLAGS properly after GnuTLS checks > > configure: Always use old_CFLAGS and old_LIBS > > qemu: Explicitly check for gnutls_rnd() > > > > configure.ac | 31 +++ > > src/qemu/qemu_domain.c | 6 +++--- > > 2 files changed, 22 insertions(+), 15 deletions(-) > > This does work for me.. Not sure I see the need for 1/3 since 2/3 > essentially uses the old_CFLAGS to save and causes you to just undo what > you did. I don't object to having both, just not sure it's necessary. Separate commits for separate changes. Squashing them together would yield the same end result, but the bug fix would be sort of lost among the noise generated by the cleanup. > ACK series though (and thanks for digging into this), Pushed, let's see if that makes the CI happy :) Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] host-validate: Improve CPU flags processing
On Tue, 2016-04-05 at 12:35 +0200, Ján Tomko wrote: > > +/* Split the line using " " as a delimiter. The first token > > + * will always be ":", but that's okay */ > > +if (!(tokens = virStringSplitCount(start, " ", 0, ))) > > +continue; > > + > > +/* Go through all flags and check whether one of those we > > + * might want to check for later on is present; if that's > > + * the case, set the relevant bit in the bitmap */ > > +for (i = 0; i < ntokens; i++) { > > +int value; > > + > > +if ((value = virHostValidateCPUFlagTypeFromString(tokens[i])) > > >= 0) > > +ignore_value(virBitmapSetBit(flags, value)); > > } > > + > > +virStringFreeListCount(tokens, ntokens); > > } while (1); > > We have already found the first 'flags' or 'Features' and parsed all the > features. I doubt different processors on the system would have > different features so I'd just use while (0) here. Yeah, if different CPUs had different features we'd probably be in for a word of pain anyway. Turns out that gcc is smart enough to figure out that a 'do {} while (0);' loop is going to be executed only once, and optimizes it accordingly. Side effect: the 'continue' instructions behave the same as the 'break' instructions, and everything stops working :( I've pushed the patch as-is. Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/3] qemu: Explicitly check for gnutls_rnd()
On 04/07/2016 09:29 AM, Andrea Bolognani wrote: > Patch 1 fixes a bug in configure. > > Patch 2 performs a minor cleanup. > > Patch 3 is the fix for the build issues currently experienced > on CentOS 6 (see [1]). > > Changes from v1: > > * update CFLAGS and LIBS before performing the check, so > that the compiler can actually find the function > > Cheers. > > > [1] > https://ci.centos.org/view/libvirt-project/job/libvirt-daemon-build/systems=libvirt-centos-6/1120/ > > Andrea Bolognani (3): > configure: Restore CFLAGS properly after GnuTLS checks > configure: Always use old_CFLAGS and old_LIBS > qemu: Explicitly check for gnutls_rnd() > > configure.ac | 31 +++ > src/qemu/qemu_domain.c | 6 +++--- > 2 files changed, 22 insertions(+), 15 deletions(-) > This does work for me.. Not sure I see the need for 1/3 since 2/3 essentially uses the old_CFLAGS to save and causes you to just undo what you did. I don't object to having both, just not sure it's necessary. ACK series though (and thanks for digging into this), John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Unsupported network type ethernet
2016-04-07 17:25 GMT+03:00 Daniel P. Berrange: > We don't currently have support for it for LXC - we recommend using > type=bridge or type=network for connectivity. We would consider patches > for type=ethernet though if someone wants to write them > > > Regards, > Daniel I can take this after my ip route stuff been applied for qemu. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Unsupported network type ethernet
On Thu, Apr 07, 2016 at 07:45:34PM +0530, sonia verma wrote: > Hi Team > > I need to launch LXC VM using ethernet network type using libvirt.While > trying the same, I'm getting below errors .. > > *error: internal error: Unsupported network type ethernet* > > Is there any patch available to add ethernet support to Libvirt with LXC VM > ? We don't currently have support for it for LXC - we recommend using type=bridge or type=network for connectivity. We would consider patches for type=ethernet though if someone wants to write them Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Unsupported network type ethernet
Hi Team I need to launch LXC VM using ethernet network type using libvirt.While trying the same, I'm getting below errors .. *error: internal error: Unsupported network type ethernet* Is there any patch available to add ethernet support to Libvirt with LXC VM ? Please let me know regarding this. Thanks Sonia Verma -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 0/3] qemu: Explicitly check for gnutls_rnd()
Patch 1 fixes a bug in configure. Patch 2 performs a minor cleanup. Patch 3 is the fix for the build issues currently experienced on CentOS 6 (see [1]). Changes from v1: * update CFLAGS and LIBS before performing the check, so that the compiler can actually find the function Cheers. [1] https://ci.centos.org/view/libvirt-project/job/libvirt-daemon-build/systems=libvirt-centos-6/1120/ Andrea Bolognani (3): configure: Restore CFLAGS properly after GnuTLS checks configure: Always use old_CFLAGS and old_LIBS qemu: Explicitly check for gnutls_rnd() configure.ac | 31 +++ src/qemu/qemu_domain.c | 6 +++--- 2 files changed, 22 insertions(+), 15 deletions(-) -- 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/3] configure: Restore CFLAGS properly after GnuTLS checks
The previous value of CFLAGS was saved as old_cflags but later restored from old_CFLAGS, which is clearly not correct. Restore CFLAGS from the right variable. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 85fc6e1..6088f77 100644 --- a/configure.ac +++ b/configure.ac @@ -1289,8 +1289,8 @@ if test "x$with_gnutls" != "xno"; then with_gnutls=yes fi + CFLAGS="$old_cflags" LIBS="$old_libs" - CFLAGS="$old_CFLAGS" fi if test "x$with_gnutls" = "xyes" ; then -- 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 2/3] configure: Always use old_CFLAGS and old_LIBS
The variables used for storing CFLAGS and LIBS before temporarily modifying them was consistent when it comes to the name, but not when it comes to the case. Make sure names are completely consistent. --- configure.ac | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 6088f77..6442674 100644 --- a/configure.ac +++ b/configure.ac @@ -321,7 +321,7 @@ if test "x$lv_cv_pthread_sigmask_works" != xyes; then AC_DEFINE([FUNC_PTHREAD_SIGMASK_BROKEN], [1], [Define to 1 if pthread_sigmask is not a real function]) fi -LIBS=$old_libs +LIBS=$old_LIBS dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h regex.h sys/un.h \ @@ -1198,15 +1198,15 @@ AC_SUBST([LIBXML_CFLAGS]) AC_SUBST([LIBXML_LIBS]) dnl xmlURI structure has query_raw? -old_cflags="$CFLAGS" -old_libs="$LIBS" +old_CFLAGS="$CFLAGS" +old_LIBS="$LIBS" CFLAGS="$CFLAGS $LIBXML_CFLAGS" LIBS="$LIBS $LIBXML_LIBS" AC_CHECK_MEMBER([struct _xmlURI.query_raw], [AC_DEFINE([HAVE_XMLURI_QUERY_RAW], [], [Have query_raw field in libxml2 xmlURI structure])],, [#include ]) -CFLAGS="$old_cflags" -LIBS="$old_libs" +CFLAGS="$old_CFLAGS" +LIBS="$old_LIBS" dnl GnuTLS library AC_ARG_WITH([gnutls], @@ -1222,8 +1222,8 @@ if test "x$with_gnutls" != "xno"; then GNUTLS_LIBS="-L$with_gnutls/lib" fi fail=0 - old_cflags="$CFLAGS" - old_libs="$LIBS" + old_CFLAGS="$CFLAGS" + old_LIBS="$LIBS" CFLAGS="$CFLAGS $GNUTLS_CFLAGS" LIBS="$LIBS $GNUTLS_LIBS" @@ -1289,8 +1289,8 @@ if test "x$with_gnutls" != "xno"; then with_gnutls=yes fi - CFLAGS="$old_cflags" - LIBS="$old_libs" + CFLAGS="$old_CFLAGS" + LIBS="$old_LIBS" fi if test "x$with_gnutls" = "xyes" ; then @@ -1431,8 +1431,8 @@ if test "$with_selinux" != "yes" ; then AC_MSG_ERROR([You must install the libselinux development package and enable SELinux with the --with-selinux=yes in order to compile libvirt --with-secdriver-selinux=yes]) fi elif test "$with_secdriver_selinux" != "no"; then - old_cflags="$CFLAGS" - old_libs="$LIBS" + old_CFLAGS="$CFLAGS" + old_LIBS="$LIBS" CFLAGS="$CFLAGS $SELINUX_CFLAGS" LIBS="$CFLAGS $SELINUX_LIBS" @@ -1440,8 +1440,8 @@ elif test "$with_secdriver_selinux" != "no"; then AC_CHECK_FUNC([selinux_virtual_domain_context_path], [], [fail=1]) AC_CHECK_FUNC([selinux_virtual_image_context_path], [], [fail=1]) AC_CHECK_FUNCS([selinux_lxc_contexts_path]) - CFLAGS="$old_cflags" - LIBS="$old_libs" + CFLAGS="$old_CFLAGS" + LIBS="$old_LIBS" if test "$fail" = "1" ; then if test "$with_secdriver_selinux" = "check" ; then -- 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 3/3] qemu: Explicitly check for gnutls_rnd()
Our use of gnutls_rnd(), introduced with commit ad7520e8, is conditional to the availability of the header file. Such check, however, turns out not to be strict enough, as there are some versions of GnuTLS (eg. 2.8.5 from CentOS 6) that provide the header file, but not the function itself, which was introduced only in GnuTLS 2.12.0. Introduce an explicit check for the function. --- configure.ac | 7 +++ src/qemu/qemu_domain.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 6442674..c8c2895 100644 --- a/configure.ac +++ b/configure.ac @@ -1289,6 +1289,13 @@ if test "x$with_gnutls" != "xno"; then with_gnutls=yes fi + dnl GNUTLS_CFLAGS and GNUTLS_LIBS have probably been updated above, + dnl and we need the final values for function probing to work + CFLAGS="$old_CFLAGS $GNUTLS_CFLAGS" + LIBS="$old_LIBS $GNUTLS_LIBS" + + AC_CHECK_FUNCS([gnutls_rnd]) + CFLAGS="$old_CFLAGS" LIBS="$old_LIBS" fi diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fa7cfc9..55dcba8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -635,8 +635,8 @@ qemuDomainGenerateRandomKey(size_t nbytes) if (VIR_ALLOC_N(key, nbytes) < 0) return NULL; -#if HAVE_GNUTLS_CRYPTO_H -/* Generate a master key using gnutls if possible */ +#if HAVE_GNUTLS_RND +/* Generate a master key using gnutls_rnd() if possible */ if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to generate master key, ret=%d"), ret); @@ -644,7 +644,7 @@ qemuDomainGenerateRandomKey(size_t nbytes) return NULL; } #else -/* If we don't have gnutls, we will generate a less cryptographically +/* If we don't have gnutls_rnd(), we will generate a less cryptographically * strong master key from /dev/urandom. */ if ((ret = virRandomBytes(key, nbytes)) < 0) { -- 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Check for gnutls_rnd() explicitly
On Thu, 2016-04-07 at 13:57 +0200, Andrea Bolognani wrote: > Our use of gnutls_rnd() is conditional to the availability of > the header file. > > Such check, however, turns out not to be strict enough as there > are some versions of gnutls (eg. 2.8.5 as available in CentOS 6) > that provide the header file, but not the function itself, which > was introduced in 2.12.0. > > Introduce an explicit check for the function itself. > --- > Would qualify as a build breaker (see [1]) but I'd rather have > some feedback before pushing it. > > [1] > https://ci.centos.org/view/libvirt-project/job/libvirt-daemon-build/systems=libvirt-centos-6/1120/ SNACK John pointed out that HAVE_GNUTLS_RND is never defined, so while this technically still fixes the build breakage, it's not really the patch we're looking for :) I'll try to figure out how to make it work properly. Suggestions are always welcome. Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: Check for gnutls_rnd() explicitly
Our use of gnutls_rnd() is conditional to the availability of the header file. Such check, however, turns out not to be strict enough as there are some versions of gnutls (eg. 2.8.5 as available in CentOS 6) that provide the header file, but not the function itself, which was introduced in 2.12.0. Introduce an explicit check for the function itself. --- Would qualify as a build breaker (see [1]) but I'd rather have some feedback before pushing it. [1] https://ci.centos.org/view/libvirt-project/job/libvirt-daemon-build/systems=libvirt-centos-6/1120/ configure.ac | 4 src/qemu/qemu_domain.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 85fc6e1..360674f 100644 --- a/configure.ac +++ b/configure.ac @@ -1286,6 +1286,10 @@ if test "x$with_gnutls" != "xno"; then #include ]]) +dnl gnutls_rnd() was introduced in 2.12, so just checking for the +dnl corresponding header is not enough: we have to check for it explicitly +AC_CHECK_FUNCS([gnutls_rnd]) + with_gnutls=yes fi diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fa7cfc9..55dcba8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -635,8 +635,8 @@ qemuDomainGenerateRandomKey(size_t nbytes) if (VIR_ALLOC_N(key, nbytes) < 0) return NULL; -#if HAVE_GNUTLS_CRYPTO_H -/* Generate a master key using gnutls if possible */ +#if HAVE_GNUTLS_RND +/* Generate a master key using gnutls_rnd() if possible */ if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to generate master key, ret=%d"), ret); @@ -644,7 +644,7 @@ qemuDomainGenerateRandomKey(size_t nbytes) return NULL; } #else -/* If we don't have gnutls, we will generate a less cryptographically +/* If we don't have gnutls_rnd(), we will generate a less cryptographically * strong master key from /dev/urandom. */ if ((ret = virRandomBytes(key, nbytes)) < 0) { -- 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: perf: Fix crash/memory corruption on failed VM start
On Thu, Apr 07, 2016 at 13:18:42 +0200, Ján Tomko wrote: > On Thu, Apr 07, 2016 at 12:52:19PM +0200, Peter Krempa wrote: > > The new perf code didn't bother to clear a pointer in 'priv' causing a > > double free or other memory corruption goodness if a VM failed to start. > > > > Clear the pointer after freeing the memory. > > > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324757 > > --- > > src/qemu/qemu_process.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > ACK Pushed; Thanks. Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: perf: Fix crash/memory corruption on failed VM start
On Thu, Apr 07, 2016 at 12:52:19PM +0200, Peter Krempa wrote: > The new perf code didn't bother to clear a pointer in 'priv' causing a > double free or other memory corruption goodness if a VM failed to start. > > Clear the pointer after freeing the memory. > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324757 > --- > src/qemu/qemu_process.c | 2 ++ > 1 file changed, 2 insertions(+) > ACK Jan > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index 2b600c1..6c870f5 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c > @@ -3444,6 +3444,7 @@ qemuDomainPerfRestart(virDomainObjPtr vm) > > cleanup: > virPerfFree(priv->perf); > +priv->perf = NULL; > return -1; > } > > @@ -5970,6 +5971,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, > virCgroupFree(>cgroup); > > virPerfFree(priv->perf); > +priv->perf = NULL; > > qemuProcessRemoveDomainStatus(driver, vm); > > -- > 2.8.0 > > -- > libvir-list mailing list > libvir-list@redhat.com > https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: perf: Fix crash/memory corruption on failed VM start
The new perf code didn't bother to clear a pointer in 'priv' causing a double free or other memory corruption goodness if a VM failed to start. Clear the pointer after freeing the memory. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324757 --- src/qemu/qemu_process.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2b600c1..6c870f5 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3444,6 +3444,7 @@ qemuDomainPerfRestart(virDomainObjPtr vm) cleanup: virPerfFree(priv->perf); +priv->perf = NULL; return -1; } @@ -5970,6 +5971,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, virCgroupFree(>cgroup); virPerfFree(priv->perf); +priv->perf = NULL; qemuProcessRemoveDomainStatus(driver, vm); -- 2.8.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] vz: add boot order support
On 07.04.2016 12:56, Maxim Nestratov wrote: > 22.03.2016 16:56, Nikolay Shirokovskiy пишет: >> Let's add support for old school boot order via xml os section. >> >> Nikolay Shirokovskiy (3): >>vz: support boot order specification on define domain >>vz: fix disk order on load domain >>vz: support boot order in domain xml dump >> >> src/vz/vz_sdk.c | 390 >> +--- >> 1 file changed, 341 insertions(+), 49 deletions(-) >> > > ACK with comments inline. > If you don't mind I can fix myself and push. OK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] vz: support boot order in domain xml dump
On 07.04.2016 12:54, Maxim Nestratov wrote: > 22.03.2016 16:56, Nikolay Shirokovskiy пишет: >> As usual we try to deal correctly with vz domains that were >> created by other means and thus can have all range of SDK domain >> parameters. If vz domain boot order can't be represented >> in libvirt os boot section let's give warning and make os boot section >> represent SDK to some extent. >> >> 1. Os boot section supports up to 4 boot devices. Here we just >> cut SDK boot order up to this limit. Not too bad. >> >> 2. If there is a floppy in boot order let's just skip it. >> Anyway we don't show it in the xml. Not too bad too. >> >> 3. SDK boot order with unsupported disks order. Say we have "hdb, hda" in >> SDK. We can not present this thru os boot order. Well let's just >> give warning but leave double in xml. It's >> kind of misleading but we warn you! >> >> SDK boot order have an extra parameters 'inUse' and 'sequenceIndex' >> which makes our task more complicated. In realitly however 'inUse' >> is always on and 'sequenceIndex == boot position index + 1' which >> simplifies out task back again! To be on a safe side let's explicitly >> check for this conditions! >> >> We have another exercise here. We want to check for unrepresentable >> condition 3 (see above). The tricky part is that in contrast to >> domains defined thru this driver 3-rd party defined domains can >> have device ordering different from default. Thus we need >> some id to check that N-th boot disk of os boot section is same as >> N-th boot disk of SDK boot. This is what prlsdkBootOrderCheck >> for. It uses disks sources paths as id for disks and iface names >> for network devices. >> >> Signed-off-by: Nikolay Shirokovskiy>> --- >> src/vz/vz_sdk.c | 238 >> >> 1 file changed, 238 insertions(+) >> >> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c >> index f059a8e..6cecb93 100644 >> --- a/src/vz/vz_sdk.c >> +++ b/src/vz/vz_sdk.c .. >> +static int >> +prlsdkConvertBootOrder(PRL_HANDLE sdkdom, virDomainDefPtr def) >> +{ >> +int ret = -1; >> +PRL_RESULT pret; >> +PRL_UINT32 bootNum; >> +PRL_HANDLE bootDev = PRL_INVALID_HANDLE; >> +PRL_BOOL inUse; >> +PRL_DEVICE_TYPE sdkType; >> +virDomainBootOrder type; >> +PRL_UINT32 bootIndex, sdkIndex; >> +int bootUsage[VIR_DOMAIN_BOOT_LAST] = { 0 }; >> +size_t i; >> + >> +pret = PrlVmCfg_GetBootDevCount(sdkdom, ); >> +prlsdkCheckRetExit(pret, -1); >> + >> +def->os.nBootDevs = 0; >> + >> +if (bootNum > VIR_DOMAIN_MAX_BOOT_DEVS) { >> +bootNum = VIR_DOMAIN_MAX_BOOT_DEVS; >> +VIR_WARN("Too many boot devices"); >> +} >> + >> +for (i = 0; i < bootNum; ++i) { >> +pret = PrlVmCfg_GetBootDev(sdkdom, i, ); >> +prlsdkCheckRetGoto(pret, cleanup); >> + >> +pret = PrlBootDev_IsInUse(bootDev, ); >> +prlsdkCheckRetGoto(pret, cleanup); >> + >> +if (!inUse) { >> +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", >> + _("Boot ordering with disabled items is not >> supported")); >> +goto cleanup; >> +} >> + >> +pret = PrlBootDev_GetSequenceIndex(bootDev, ); >> +prlsdkCheckRetGoto(pret, cleanup); >> + >> +/* bootIndex is started from 1 */ >> +if (bootIndex != i + 1) { >> +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", >> + _("Unsupported boot order configuration")); >> +goto cleanup; >> +} >> + > > This check doesn't work because boot indexes are not necessarily continuous. > The only condition we should check here is that they should be growing. > > I added the following chunk to your code and if you don't mind I can squash > it to your patch and push. > > @@ -1432,7 +1432,7 @@ prlsdkConvertBootOrder(PRL_HANDLE sdkdom, > virDomainDefPtr def) > PRL_BOOL inUse; > PRL_DEVICE_TYPE sdkType; > virDomainBootOrder type; > -PRL_UINT32 bootIndex, sdkIndex; > +PRL_UINT32 prevBootIndex = 0, bootIndex, sdkIndex; > int bootUsage[VIR_DOMAIN_BOOT_LAST] = { 0 }; > size_t i; > > @@ -1463,11 +1463,12 @@ prlsdkConvertBootOrder(PRL_HANDLE sdkdom, > virDomainDefPtr def) > prlsdkCheckRetGoto(pret, cleanup); > > /* bootIndex is started from 1 */ > -if (bootIndex != i + 1) { > +if (bootIndex <= prevBootIndex) { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > _("Unsupported boot order configuration")); > goto cleanup; > } > +prevBootIndex = bootIndex; > > pret = PrlBootDev_GetType(bootDev, ); > prlsdkCheckRetGoto(pret, cleanup); > ok, but don't forget to update commit message and comment too -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH V5] libxl: support creating domain with VF assignment from a pool
Add codes to support creating domain with network defition of assigning SRIOV VF from a pool. Signed-off-by: Chunyan LiuSigned-off-by: Jim Fehlig --- Rebase and send a new version. src/libxl/libxl_domain.c | 48 tests/Makefile.am| 3 +++ 2 files changed, 51 insertions(+) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 04962a0..bd5deaa 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -36,6 +36,7 @@ #include "virtime.h" #include "locking/domain_lock.h" #include "xen_common.h" +#include "network/bridge_driver.h" #define VIR_FROM_THIS VIR_FROM_LIBXL @@ -764,6 +765,10 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, if (net->ifname && STRPREFIX(net->ifname, LIBXL_GENERATED_PREFIX_XEN)) VIR_FREE(net->ifname); + +/* cleanup actual device */ +virDomainNetRemoveHostdev(vm->def, net); +networkReleaseActualDevice(vm->def, net); } } @@ -900,6 +905,46 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config) return -1; } +static int +libxlNetworkPrepareDevices(virDomainDefPtr def) +{ +size_t i; + +for (i = 0; i < def->nnets; i++) { +virDomainNetDefPtr net = def->nets[i]; +int actualType; + +/* If appropriate, grab a physical device from the configured + * network's pool of devices, or resolve bridge device name + * to the one defined in the network definition. + */ +if (networkAllocateActualDevice(def, net) < 0) +return -1; + +actualType = virDomainNetGetActualType(net); +if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV && +net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { +/* Each type='hostdev' network device must also have a + * corresponding entry in the hostdevs array. For netdevs + * that are hardcoded as type='hostdev', this is already + * done by the parser, but for those allocated from a + * network / determined at runtime, we need to do it + * separately. + */ +virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net); +virDomainHostdevSubsysPCIPtr pcisrc = >source.subsys.u.pci; + +if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && +hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) +pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN; + +if (virDomainHostdevInsert(def, hostdev) < 0) +return -1; +} +} +return 0; +} + static void libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback) { @@ -1050,6 +1095,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm, goto cleanup; VIR_FREE(priv->lockState); +if (libxlNetworkPrepareDevices(vm->def) < 0) +goto cleanup_dom; + if (libxlBuildDomainConfig(driver->reservedGraphicsPorts, vm->def, cfg->ctx, _config) < 0) goto cleanup_dom; diff --git a/tests/Makefile.am b/tests/Makefile.am index b3f1144..db4f88b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -534,6 +534,9 @@ endif ! WITH_XEN if WITH_LIBXL libxl_LDADDS = ../src/libvirt_driver_libxl_impl.la +if WITH_NETWORK +libxl_LDADDS += ../src/libvirt_driver_network_impl.la +endif WITH_NETWORK libxl_LDADDS += $(LDADDS) xlconfigtest_SOURCES = \ -- 1.8.5.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] vz: add boot order support
22.03.2016 16:56, Nikolay Shirokovskiy пишет: Let's add support for old school boot order via xml os section. Nikolay Shirokovskiy (3): vz: support boot order specification on define domain vz: fix disk order on load domain vz: support boot order in domain xml dump src/vz/vz_sdk.c | 390 +--- 1 file changed, 341 insertions(+), 49 deletions(-) ACK with comments inline. If you don't mind I can fix myself and push. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] vz: support boot order in domain xml dump
22.03.2016 16:56, Nikolay Shirokovskiy пишет: As usual we try to deal correctly with vz domains that were created by other means and thus can have all range of SDK domain parameters. If vz domain boot order can't be represented in libvirt os boot section let's give warning and make os boot section represent SDK to some extent. 1. Os boot section supports up to 4 boot devices. Here we just cut SDK boot order up to this limit. Not too bad. 2. If there is a floppy in boot order let's just skip it. Anyway we don't show it in the xml. Not too bad too. 3. SDK boot order with unsupported disks order. Say we have "hdb, hda" in SDK. We can not present this thru os boot order. Well let's just give warning but leave double in xml. It's kind of misleading but we warn you! SDK boot order have an extra parameters 'inUse' and 'sequenceIndex' which makes our task more complicated. In realitly however 'inUse' is always on and 'sequenceIndex == boot position index + 1' which simplifies out task back again! To be on a safe side let's explicitly check for this conditions! We have another exercise here. We want to check for unrepresentable condition 3 (see above). The tricky part is that in contrast to domains defined thru this driver 3-rd party defined domains can have device ordering different from default. Thus we need some id to check that N-th boot disk of os boot section is same as N-th boot disk of SDK boot. This is what prlsdkBootOrderCheck for. It uses disks sources paths as id for disks and iface names for network devices. Signed-off-by: Nikolay Shirokovskiy--- src/vz/vz_sdk.c | 238 1 file changed, 238 insertions(+) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f059a8e..6cecb93 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1273,6 +1273,240 @@ prlsdkNewDomainByHandle(vzConnPtr privconn, PRL_HANDLE sdkdom) return dom; } +static PRL_HANDLE +prlsdkGetDevByDevIndex(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE type, PRL_UINT32 devIndex) +{ +PRL_RESULT pret; +PRL_UINT32 index, num; +PRL_HANDLE dev = PRL_INVALID_HANDLE; +size_t i; + +pret = PrlVmCfg_GetDevsCountByType(sdkdom, type, ); +prlsdkCheckRetGoto(pret, error); + +for (i = 0; i < num; ++i) { +pret = PrlVmCfg_GetDevByType(sdkdom, type, i, ); +prlsdkCheckRetGoto(pret, error); + +pret = PrlVmDev_GetIndex(dev, ); +prlsdkCheckRetGoto(pret, error); + +if (index == devIndex) +break; + +PrlHandle_Free(dev); +dev = PRL_INVALID_HANDLE; +} + +return dev; + + error: +PrlHandle_Free(dev); +return PRL_INVALID_HANDLE; +} + +static virDomainDiskDefPtr +virFindDiskBootIndex(virDomainDefPtr def, virDomainDiskDevice type, int index) +{ +size_t i; +int c = 0; + +for (i = 0; i < def->ndisks; ++i) { +if (def->disks[i]->device != type) +continue; +if (c == index) +return def->disks[i]; +++c; +} + +return NULL; +} + +static int +prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex, + virDomainDefPtr def, int bootIndex) +{ +PRL_RESULT pret; +char *sdkName = NULL; +const char *bootName; +PRL_UINT32 buflen = 0; +PRL_HANDLE dev = PRL_INVALID_HANDLE; +virDomainDiskDefPtr disk; +virDomainDiskDevice device; +int ret = -1; + +dev = prlsdkGetDevByDevIndex(sdkdom, sdkType, sdkIndex); +if (dev == PRL_INVALID_HANDLE) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Can't find boot device of type: %d, device index: %d"), + sdkType, sdkIndex); +return -1; +} + +switch (sdkType) { +case PDE_OPTICAL_DISK: +case PDE_HARD_DISK: +pret = PrlVmDev_GetFriendlyName(dev, sdkName, ); +prlsdkCheckRetGoto(pret, cleanup); + +if (VIR_ALLOC_N(sdkName, buflen) < 0) +goto cleanup; + +pret = PrlVmDev_GetFriendlyName(dev, sdkName, ); +prlsdkCheckRetGoto(pret, cleanup); + +switch (sdkType) { +case PDE_OPTICAL_DISK: +device = VIR_DOMAIN_DISK_DEVICE_CDROM; +break; +case PDE_HARD_DISK: +device = VIR_DOMAIN_DISK_DEVICE_DISK; +break; +default: +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported disk type %d"), sdkType); +goto cleanup; +} + +if (!(disk = virFindDiskBootIndex(def, device, bootIndex))) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Can find boot device of type: %s, index: %d"), + virDomainDiskDeviceTypeToString(device), bootIndex); +goto cleanup; +} + +bootName = disk->src->path; + +break; +case PDE_GENERIC_NETWORK_ADAPTER: +pret =
Re: [libvirt] [PATCH 2/3] vz: fix disk order on load domain
22.03.2016 16:56, Nikolay Shirokovskiy пишет: We want to report boot order in dumpxml for vz domains. Thus we want disks devices to be sorted in output compatible with boot ordering specification. So let's just use virDomainDiskInsert which makes appropriate sorting. Signed-off-by: Nikolay Shirokovskiy--- src/vz/vz_sdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 528a253..f059a8e 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -663,7 +663,7 @@ prlsdkAddDomainHardDisksInfo(vzConnPtr privconn, PRL_HANDLE sdkdom, virDomainDef if (prlsdkGetDiskInfo(privconn, hdd, disk, false, IS_CT(def)) < 0) goto error; -if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) +if (virDomainDiskInsert(def, disk) < 0) goto error; disk = NULL; @@ -706,7 +706,7 @@ prlsdkAddDomainOpticalDisksInfo(vzConnPtr privconn, PRL_HANDLE sdkdom, virDomain PrlHandle_Free(cdrom); cdrom = PRL_INVALID_HANDLE; -if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) +if (virDomainDiskInsert(def, disk) < 0) goto error; } ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] vz: support boot order specification on define domain
22.03.2016 16:56, Nikolay Shirokovskiy пишет: The patch makes some refactoring of the existing code. Current boot order spec code makes very simple thing in somewhat obscure way. In case of VMs it sets the first hdd as the only bootable device. In case of CTs it doesn't touch the boot order at all if one of the filesystems is mounted to root. Otherwise like in case of VMs it sets the first hdd as the only bootable device and additionally sets this device mount point to root. Refactored code makes all this explicit. The actual boot order support is simple. Common libvirt domain xml parsing code makes the exact ordering of disks devices as described in docs for boot ordering (disks are sorted by bus order first, device target second. Bus order is the order of disk buses appearence in original xml. Device targets order is alphabetical). We add devices in the same order and SDK designates device indexes sequentially for each device type. Thus device index is equal to its boot index. For example N-th cdrom in boot specification refers to sdk cdrom with it's device index N. If there is no boot spec in xml the parsing code will add for HVMs automatically and we backward compatibly set fist hdd as bootable. Signed-off-by: Nikolay Shirokovskiy--- src/vz/vz_sdk.c | 148 ++-- 1 file changed, 101 insertions(+), 47 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c0fb4fb..528a253 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -87,6 +87,14 @@ logPrlErrorHelper(PRL_RESULT err, const char *filename, } \ } while (0) +#define prlsdkCheckRetExit(ret, code) \ +do { \ +if (PRL_FAILED(ret)) { \ +logPrlError(ret); \ +return code; \ +} \ +} while (0) + static PRL_RESULT logPrlEventErrorHelper(PRL_HANDLE event, const char *filename, const char *funcname, size_t linenr) @@ -1988,13 +1996,9 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def) } if (!IS_CT(def)) { -if (def->os.nBootDevs != 1 || -def->os.bootDevs[0] != VIR_DOMAIN_BOOT_DISK || -def->os.init != NULL || def->os.initargv != NULL) { - +if (def->os.init != NULL || def->os.initargv != NULL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("changing OS parameters is not supported " - "by vz driver")); + _("unsupported OS parameters")); return -1; } } else { @@ -2003,8 +2007,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def) (def->os.initargv != NULL && def->os.initargv[0] != NULL)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("changing OS parameters is not supported " - "by vz driver")); + _("unsupported OS parameters")); return -1; } } @@ -2991,9 +2994,7 @@ static int prlsdkDelDisk(PRL_HANDLE sdkdom, int idx) static int prlsdkAddDisk(vzConnPtr privconn, PRL_HANDLE sdkdom, - virDomainDiskDefPtr disk, - bool bootDisk, - bool isCt) + virDomainDiskDefPtr disk) { PRL_RESULT pret; PRL_HANDLE sdkdisk = PRL_INVALID_HANDLE; @@ -3002,7 +3003,6 @@ static int prlsdkAddDisk(vzConnPtr privconn, PRL_MASS_STORAGE_INTERFACE_TYPE sdkbus; int idx; virDomainDeviceDriveAddressPtr drive; -PRL_UINT32 devIndex; PRL_DEVICE_TYPE devType; PRL_CLUSTERED_DEVICE_SUBTYPE scsiModel; char *dst = NULL; @@ -3133,21 +3133,6 @@ static int prlsdkAddDisk(vzConnPtr privconn, goto cleanup; } -if (bootDisk) { -pret = PrlVmDev_GetIndex(sdkdisk, ); -prlsdkCheckRetGoto(pret, cleanup); - -if (prlsdkAddDeviceToBootList(sdkdom, devIndex, devType, 0) < 0) -goto cleanup; - -/* If we add physical device as a boot disk to container - * we have to specify mount point for it */ -if (isCt) { -pret = PrlVmDevHd_SetMountPoint(sdkdisk, "/"); -prlsdkCheckRetGoto(pret, cleanup); -} -} - return 0; cleanup: PrlHandle_Free(sdkdisk); @@ -3168,11 +3153,7 @@ prlsdkAttachVolume(vzConnPtr privconn, if (PRL_FAILED(waitJob(job))) goto cleanup; -ret = prlsdkAddDisk(privconn, -privdom->sdkdom, -disk, -false, -IS_CT(dom->def)); +
Re: [libvirt] [PATCH] util: move ENODATA redefine to virutil.h
On Thu, 2016-04-07 at 10:17 +0100, Daniel P. Berrange wrote: > > So I think you should rather move the definition from viruuid.c > > to virrandom.c instead of virutil.h. > > > > ACK with that changed. > > Actually for this kind of super generic portability fix I'd > strongly suggest we put it in internal.h, so no matter what > code we add in the future, it'll always have the ENODATA > compat defined Agreed, that's even better than my suggestion :) Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v4] Use-correct-pci-addresses-during-interface-detach
The virsh attach virsh detach interface command fails when both live and config are set and when the interface gets attached to different pci slots on live and config xml respectively. When we attach an interface with both --live and --config, the first time they get the same PCI slots, but the second time onwards it differs and hence the virsh detach-interface --live --config command fails. This patch makes sure that when both --live --config are set , qemuDomainDetachDeviceFlags is called twice, once with config xml and once with live xml. --- Change log: v4: * Code unchanged, updated with commit message,change log and steps to reproduce the issue.. v3: * Created function vshDomainDetachInterface and called it once/twice from cmdDetachInterface depending on number of flags set (live/config/both). Passed the correct xml(live/persistent) to it. v2: * Changes only in cmdDetachInterface to pass the right domain xml depending on the flag set (live/config/both). v1: * Changes only in qemuDomainDetachDeviceFlags to set the right value in dev and dev_copy. Steps to see the issue: virsh attach-interface --domain DomainName --type network --source default --mac 52:54:00:4b:76:5f --live --config virsh detach-interface --domain DomainName --type network --mac 52:54:00:4b:76:5f --live --config virsh attach-interface --domain DomainName --type network --source default --mac 52:54:00:4b:76:5f --live --config virsh detach-interface --domain DomainName --type network --mac 52:54:00:4b:76:5f --live --config tools/virsh-domain.c | 104 +++ 1 file changed, 64 insertions(+), 40 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 62acecb..a6abaf5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10801,40 +10801,21 @@ static const vshCmdOptDef opts_detach_interface[] = { {.name = NULL} }; -static bool -cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) +static bool +vshDomainDetachInterface(char *doc, unsigned int flags, virDomainPtr dom, vshControl *ctl, const vshCmd *cmd) { -virDomainPtr dom = NULL; xmlDocPtr xml = NULL; xmlXPathObjectPtr obj = NULL; xmlXPathContextPtr ctxt = NULL; xmlNodePtr cur = NULL, matchNode = NULL; -char *detach_xml = NULL; const char *mac = NULL, *type = NULL; -char *doc = NULL; +char *detach_xml = NULL; +bool current = vshCommandOptBool(cmd, "current"); char buf[64]; int diff_mac; size_t i; int ret; bool functionReturn = false; -unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; -bool current = vshCommandOptBool(cmd, "current"); -bool config = vshCommandOptBool(cmd, "config"); -bool live = vshCommandOptBool(cmd, "live"); -bool persistent = vshCommandOptBool(cmd, "persistent"); - -VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current); - -VSH_EXCLUSIVE_OPTIONS_VAR(current, live); -VSH_EXCLUSIVE_OPTIONS_VAR(current, config); - -if (config || persistent) -flags |= VIR_DOMAIN_AFFECT_CONFIG; -if (live) -flags |= VIR_DOMAIN_AFFECT_LIVE; - -if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) -return false; if (vshCommandOptStringReq(ctl, cmd, "type", ) < 0) goto cleanup; @@ -10842,15 +10823,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "mac", ) < 0) goto cleanup; -if (persistent && -virDomainIsActive(dom) == 1) -flags |= VIR_DOMAIN_AFFECT_LIVE; - -if (flags & VIR_DOMAIN_AFFECT_CONFIG) -doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE); -else -doc = virDomainGetXMLDesc(dom, 0); - if (!doc) goto cleanup; @@ -10918,23 +10890,75 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) else ret = virDomainDetachDevice(dom, detach_xml); -if (ret != 0) { -vshError(ctl, "%s", _("Failed to detach interface")); -} else { -vshPrint(ctl, "%s", _("Interface detached successfully\n")); +if (ret == 0) functionReturn = true; -} cleanup: -VIR_FREE(doc); VIR_FREE(detach_xml); -virDomainFree(dom); +xmlFreeDoc(xml); xmlXPathFreeObject(obj); xmlXPathFreeContext(ctxt); -xmlFreeDoc(xml); return functionReturn; } +static bool +cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom = NULL; +unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; +char *doc_live = NULL, *doc_config = NULL; +bool current = vshCommandOptBool(cmd, "current"); +bool config = vshCommandOptBool(cmd, "config"); +bool live = vshCommandOptBool(cmd, "live"); +bool persistent = vshCommandOptBool(cmd, "persistent"); +bool functionReturn = false; + +VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current); + +VSH_EXCLUSIVE_OPTIONS_VAR(current, live); +VSH_EXCLUSIVE_OPTIONS_VAR(current, config); + +if (config
Re: [libvirt] [PATCH] util: move ENODATA redefine to virutil.h
On Thu, Apr 07, 2016 at 11:13:00AM +0200, Andrea Bolognani wrote: > On Thu, 2016-04-07 at 09:53 +0300, Roman Bogorodskiy wrote: > > FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO. However, > > now we have virrandom.c that's using ENODATA also, so move this > > re-definition to a common place, virutil.h, so it could fix things for > > both consumers. > > --- > > src/util/virutil.h | 4 > > src/util/viruuid.c | 4 > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/src/util/virutil.h b/src/util/virutil.h > > index b121de0..36ed186 100644 > > --- a/src/util/virutil.h > > +++ b/src/util/virutil.h > > @@ -36,6 +36,10 @@ > > # define MAX(a, b) ((a) > (b) ? (a) : (b)) > > # endif > > > > +# ifndef ENODATA > > +# define ENODATA EIO > > +# endif > > + > > > > int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK; > > int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK; > > diff --git a/src/util/viruuid.c b/src/util/viruuid.c > > index 1fcc954..16e57db 100644 > > --- a/src/util/viruuid.c > > +++ b/src/util/viruuid.c > > @@ -46,10 +46,6 @@ > > > > VIR_LOG_INIT("util.uuid"); > > > > -#ifndef ENODATA > > -# define ENODATA EIO > > -#endif > > - > > static unsigned char host_uuid[VIR_UUID_BUFLEN]; > > > > static int > > These are the current occurrences of ENODATA: > > src/storage/storage_backend.c: > if (errno != ENODATA && errno != ENOTSUP) { > > tests/securityselinuxlabeltest.c: > if (errno == ENODATA) { > > src/util/viruuid.c: > #ifndef ENODATA > # define ENODATA EIO > > src/util/virrandom.c: > return n < 0 ? errno : ENODATA; > > The first is inside a '#if WITH_SELINUX' block, so FreeBSD is > not going to hit it. The second one is a SELinux-specific test, > and it's not compiled on FreeBSD. > > The third one is where ENODATA gets defined, as you mention in > your commit message, and the fourth one where it's used. > > Note that ENODATA is not being used in viruuid.c... I guess > the code that prompted the definition has since been removed. > > So I think you should rather move the definition from viruuid.c > to virrandom.c instead of virutil.h. > > ACK with that changed. Actually for this kind of super generic portability fix I'd strongly suggest we put it in internal.h, so no matter what code we add in the future, it'll always have the ENODATA compat defined Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: move ENODATA redefine to virutil.h
On Thu, 2016-04-07 at 09:53 +0300, Roman Bogorodskiy wrote: > FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO. However, > now we have virrandom.c that's using ENODATA also, so move this > re-definition to a common place, virutil.h, so it could fix things for > both consumers. > --- > src/util/virutil.h | 4 > src/util/viruuid.c | 4 > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/src/util/virutil.h b/src/util/virutil.h > index b121de0..36ed186 100644 > --- a/src/util/virutil.h > +++ b/src/util/virutil.h > @@ -36,6 +36,10 @@ > # define MAX(a, b) ((a) > (b) ? (a) : (b)) > # endif > > +# ifndef ENODATA > +# define ENODATA EIO > +# endif > + > > int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK; > int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK; > diff --git a/src/util/viruuid.c b/src/util/viruuid.c > index 1fcc954..16e57db 100644 > --- a/src/util/viruuid.c > +++ b/src/util/viruuid.c > @@ -46,10 +46,6 @@ > > VIR_LOG_INIT("util.uuid"); > > -#ifndef ENODATA > -# define ENODATA EIO > -#endif > - > static unsigned char host_uuid[VIR_UUID_BUFLEN]; > > static int These are the current occurrences of ENODATA: src/storage/storage_backend.c: if (errno != ENODATA && errno != ENOTSUP) { tests/securityselinuxlabeltest.c: if (errno == ENODATA) { src/util/viruuid.c: #ifndef ENODATA # define ENODATA EIO src/util/virrandom.c: return n < 0 ? errno : ENODATA; The first is inside a '#if WITH_SELINUX' block, so FreeBSD is not going to hit it. The second one is a SELinux-specific test, and it's not compiled on FreeBSD. The third one is where ENODATA gets defined, as you mention in your commit message, and the fourth one where it's used. Note that ENODATA is not being used in viruuid.c... I guess the code that prompted the definition has since been removed. So I think you should rather move the definition from viruuid.c to virrandom.c instead of virutil.h. ACK with that changed. Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] storage_scsi: Handle physical HBA when deleting vHBA vport.
HBA will get treated as vHBA if not returned after detecting vhba_parent format. Signed-off-by: Nitesh Konkar--- Before Patch: # virsh pool-destroy poolhba_name error: Failed to destroy pool poolhba_name error: internal error: Invalid adapter name 'pci_000x_0x_00_x' for SCSI pool # virsh nodedev-dumpxml scsi_host2 scsi_host2 pci_000x_0x_00_x 2 ... ... 255 0 After Patch: # virsh pool-destroy poolhba_name Pool poolhba_name destroyed src/storage/storage_backend_scsi.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index e6c8bb5..dd0343f 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -842,6 +842,11 @@ deleteVport(virConnectPtr conn, if (!(vhba_parent = virStoragePoolGetVhbaSCSIHostParent(conn, name))) goto cleanup; +if (STRPREFIX(vhba_parent, "pci")) { +ret = 0; +goto cleanup; +} + if (virGetSCSIHostNumber(vhba_parent, _host) < 0) goto cleanup; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] qemu: alias: Fix calculation of RNG device aliases
On Wed, Apr 06, 2016 at 18:14:22 +0200, Pavel Hrdina wrote: > On Wed, Apr 06, 2016 at 05:52:48PM +0200, Peter Krempa wrote: > > For device hotplug, the new alias ID needs to be checked in the list > > rather than using the count of devices. Unplugging a device that is not > > last in the array will make further hotplug impossible due to alias > > collision. > > > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551 > > --- .. > > ACK with that fixed. With the proposed change and removal of the @idx parameter which is always -1 the code could be simplified. I've pushed the patches. Thanks. Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nss: Simplify move_and_align
On Thu, Apr 07, 2016 at 09:31:06 +0200, Michal Privoznik wrote: > What this function does can be written much shorter. > > Signed-off-by: Michal Privoznik> --- > tools/nss/libvirt_nss.c | 8 +++- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c > index de34baf..587b171 100644 > --- a/tools/nss/libvirt_nss.c > +++ b/tools/nss/libvirt_nss.c > @@ -263,12 +263,10 @@ move_and_align(void *buf, size_t len, size_t *idx) > char *buffer = buf; > size_t move = LIBVIRT_ALIGN(len); > > -if (!idx) > -return buffer + move; > +if (idx) > +*idx += move; > > -*idx += move; > - > -return buffer + *idx; > +return buffer + move; > } But it doesn't seem to be equivalent... The !idx case remains the same, but in the idx case: old code: *idx += move; return buffer + *idx; new code: *idx += move; return buffer + move; I guess you need to do something like if (idx) { buffer += *idx; *idx += move; } return buffer + move; Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] nss: Simplify move_and_align
What this function does can be written much shorter. Signed-off-by: Michal Privoznik--- tools/nss/libvirt_nss.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index de34baf..587b171 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -263,12 +263,10 @@ move_and_align(void *buf, size_t len, size_t *idx) char *buffer = buf; size_t move = LIBVIRT_ALIGN(len); -if (!idx) -return buffer + move; +if (idx) +*idx += move; -*idx += move; - -return buffer + *idx; +return buffer + move; } enum nss_status -- 2.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] 200ms delay waiting for qemu monitor
On 06.04.2016 21:45, Richard W.M. Jones wrote: > [Thanks to Dan Berrangé for doing the analysis of this one] > > I was investigating a 200+ millisecond delay when libvirt starts a > qemu guest. You can see the traces here: > > http://oirase.annexia.org/tmp/libvirt.log > http://oirase.annexia.org/tmp/libvirtd.log > > The delay happens at around 16:52:57.327-6:52:57.528 in the libvirtd log. > As you can see the delay is almost precisely 200ms. > > Dan found the cause which seems to be this code: > > https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor.c;h=10a6713c06ad36e2055f8144fba00b78630971e5;hb=HEAD#l365 > > (There are other examples of the same anti-pattern in src/fdstream.c > and src/qemu/qemu_agent.c, but it's the particular code above which > seems to be causing the delay). > > To give you some sense why I regard this as a problem, the TOTAL time > taken to launch and shutdown the libguestfs appliance (that includes > qemu, BIOS, guest kernel, probing and mouting disks, running the > guestfs daemon, and the shutdown process in reverse), without libvirt, > is now 900ms. Libvirt adds about 220ms on top of this. > > What can we do about this? Obviously we could simply reduce the > delay, but even if it was set to 20ms, that would be too much (aim is > to reduce the whole process from 900ms down to 150ms), and it would > also mean that libvirt was essentially polling. > > Can we use inotify to detect if the socket has been created? Seems to > create portability problems. > > Dan suggested: > > Can we create the socket in libvirtd and pass it to qemu? > > Can we pass a file descriptor to qemu? Right. This is the goal that we try to reach. Well, not that anybody I know of is working on it actively. But the idea would be that libvirt would open all the files for qemu and then just pass the FDs. As for the monitor - I think qemu counterpart should be fairly easy, but we rather confirm with qemu guys. I'm definitely in! Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] util: move ENODATA redefine to virutil.h
FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO. However, now we have virrandom.c that's using ENODATA also, so move this re-definition to a common place, virutil.h, so it could fix things for both consumers. --- src/util/virutil.h | 4 src/util/viruuid.c | 4 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virutil.h b/src/util/virutil.h index b121de0..36ed186 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -36,6 +36,10 @@ # define MAX(a, b) ((a) > (b) ? (a) : (b)) # endif +# ifndef ENODATA +# define ENODATA EIO +# endif + int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK; int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK; diff --git a/src/util/viruuid.c b/src/util/viruuid.c index 1fcc954..16e57db 100644 --- a/src/util/viruuid.c +++ b/src/util/viruuid.c @@ -46,10 +46,6 @@ VIR_LOG_INIT("util.uuid"); -#ifndef ENODATA -# define ENODATA EIO -#endif - static unsigned char host_uuid[VIR_UUID_BUFLEN]; static int -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list