Re: [libvirt] [PATCH 2/3] virsh: prevent destroying a in-used network for net-destroy
On Tue, Feb 03, 2015 at 08:21:42PM -0500, Laine Stump wrote: On 02/02/2015 09:08 AM, Lin Ma wrote: * add --system flag for net-dumpxml to show information about the attached interfaces of the virtual network. I don't like this extra flag - I think it is unnecessary. If we're going to more info to the status, then we can just always add it to the status. As to how it can be provided in the status XML (getting back to patch 1/3 which was using the netcf API in a way that I didn't like), better data can be gathered into a list in the network object as guests are created - this would be done in networkAllocateActualDevice() (and networkNotifyActualDevice()) at the points where connections is incremented for the network, and removed from the list in networkReleaseActualDevice() where connections is decremented. You'll notice that those functions get both the virDomainDefPtr and the virDomainNetDefPtr, so they have enough information to store the name of the domain as well as the namne of the interface. I recall a long time ago considering adding this information to the network XML, but I was dissuaded for some reason; unfortunately I don't remember why... * call virNetworkGetXMLDesc in cmdNetworkDestroy to get the live state info to check whether the virtual network is in use. * add --force flag for net-destroy to forcibly destroy the virtual network even if it's in use. As Michal points out (and I pointed out when you sent your previous patchset), this does change behavior that some scripts may be dependent on. I too like the increased safety, but am concerned about breaking functionality. In cases like this, I always like to hear the learned advice of Dan Berrange - Daniel, what do you say about changing the default behavior of virsh net-destroy? Safe enough? I don't think it is acceptable to change the behaviour. The 'destroy' commands are unambiguous about the fact that they are a forceful operation that will always succeed. Note that for the 'virsh destroy' command we added a 'graceful' option, thus preserving default behaviour -=item Bnet-dumpxml Inetwork [I--inactive] +=item Bnet-dumpxml Inetwork [I--inactive] [I--system] Output the virtual network information as an XML dump to stdout. If I--inactive is specified, then physical functions are not expanded into their associated virtual functions. +If I--system is specified, then directly output the current +live state corresponding to this network from system. This description of the 'system' flag just makes it sound like it is the same as not specifying the --inactive flag. ie If the network is running, the XML we emit is always the live XML state 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] [RFC PATCH v2 02/12] domain_conf: introduce cpu def helpers
virDomainCPUDefFree - free memory allocated virDomainCPUDefParseXML - parse job type virDomainCPUDefFormat - output job type Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- docs/formatdomain.html.in | 28 +++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c| 82 +++ src/conf/domain_conf.h| 1 + src/libvirt_private.syms | 1 + 5 files changed, 115 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f8d5f89..10cbd29 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5830,6 +5830,34 @@ qemu-kvm -net nic,model=? /dev/null /dd /dl + h4a name=elementsCpuCPU device/a/h4 + p +CPU device allows to be hot added to the guest. +span class=sinceSince 1.2.12, QEMU and KVM only/span + /p + +pre + ... + lt;devicesgt; +lt;cpu match='exact'gt; + lt;model fallback='allow'gt;core2duolt;/modelgt; + lt;vendorgt;Intellt;/vendorgt; + lt;topology sockets='1' cores='2' threads='1'/gt; + lt;feature policy='disable' name='lahf_lm'/gt; +lt;/cpugt; + lt;devicesgt; + ... +/pre + dl +dtcodemodel/code/dt +dd + p +The attribute can be omitted and will default to a model +started up by the guest. + /p +/dd + /dl + h3a name=seclabelSecurity label/a/h3 p diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 9d6c1ee..1ceb811 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4003,6 +4003,9 @@ optional ref name=panic/ /optional +optional + ref name='cpu' +/optional /interleave /element /define diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0f4baaf..dfe0d65 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1913,6 +1913,18 @@ void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def) VIR_FREE(def); } +void virDomainCPUDefFree(virDomainCPUDefPtr def) +{ +if (!def) +return; + +virCPUDefFree(def-virCPU); + +virDomainDeviceInfoClear(def-info); + +VIR_FREE(def); +} + void virDomainDeviceDefFree(virDomainDeviceDefPtr def) { if (!def) @@ -1983,6 +1995,8 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) virDomainPanicDefFree(def-data.panic); break; case VIR_DOMAIN_DEVICE_CPU: +virDomainCPUDefFree(def-data.cpu); +break; case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: break; @@ -11052,6 +11066,44 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, return ret; } +static virDomainCPUDefPtr +virDomainCPUDefParseXML(xmlNodePtr node, +xmlXPathContextPtr ctxt, +const virDomainDef *def, +unsigned int flags) +{ +virDomainCPUDefPtr dev; + +if (VIR_ALLOC(dev) 0) +return NULL; + +dev-virCPU = virCPUDefParseXML(node, ctxt, VIR_CPU_TYPE_AUTO); +if (!dev-virCPU) +goto cleanup; + +if (!dev-virCPU-model) { +if (def-cpu-model) { +dev-virCPU-model = def-cpu-model; +} else if (def-os.arch == VIR_ARCH_I686) { +if (virAsprintf(dev-virCPU-model, qemu32) 0) +goto cleanup; +} else { +if (virAsprintf(dev-virCPU-model, qemu64) 0) +goto cleanup; +} +} + +if (virDomainDeviceInfoParseXML(node, NULL, dev-info, flags) 0) +goto cleanup; + +return dev; + + cleanup: +virDomainCPUDefFree(dev); +dev = NULL; +return dev; +} + virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, const virDomainDef *def, @@ -11187,6 +11239,9 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_CPU: +if (!(dev-data.cpu = virDomainCPUDefParseXML(node, ctxt, def, flags))) +goto error; +break; case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LAST: break; @@ -18145,6 +18200,27 @@ virDomainChrDefFormat(virBufferPtr buf, } static int +virDomainCPUDefFormat(virBufferPtr buf, + virDomainCPUDefPtr def, + unsigned int flags) +{ +if (virCPUDefFormatBufFull(buf, def-virCPU, false) 0) +return -1; + +virBufferTrim(buf, /cpu\n, -1); +virBufferTrim(buf, , 4); +virBufferAdjustIndent(buf, 2); + +if (virDomainDeviceInfoFormat(buf, def-info, flags) 0) +return -1; + +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /cpu\n); + +return 0; +} + +static int virDomainSmartcardDefFormat(virBufferPtr buf, virDomainSmartcardDefPtr def, unsigned int flags) @@ -20065,6 +20141,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
Re: [libvirt] [PATCH 1/3] bridge_driver: Return the live state info of a given virtual network
On Mon, Feb 02, 2015 at 10:08:21PM +0800, Lin Ma wrote: It constructs a temporary static config of the network, Obtains all of attached interfaces information through netcf, Then removes the config. Signed-off-by: Lin Ma l...@suse.com --- include/libvirt/libvirt-network.h| 1 + src/Makefile.am | 3 + src/network/bridge_driver.c | 141 ++- src/network/bridge_driver_platform.h | 7 ++ tests/Makefile.am| 4 + 5 files changed, 155 insertions(+), 1 deletion(-) So, IIUC, the point of this change is to display a list of all the TAP devices attached to a network. I'm not entirely convinced this is the right approach to take. Also do we want to limit this to reporting of devices inside bridges. It could be equally useful to see a list of macvtap devices associated with a physical NIC. Modifying the XML to include the list of VIFs is certainly one options, but I'm not sure it is necceessarily the best. As Laine points out this is a output only attribute - not something you can feed in with the XML when defining the network. Perhaps we want to have an actual API for this - a virNetworkListPorts which returns a list of associated devices (of any type) from guests. Or perhaps we should be reporting a list of virDomainPtr's that are attached to the network, or perhaps even both. 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] [RFC PATCH v2 05/12] qemu_command: introduce a func for cpu device alias assignment
This function used to set a alias name for cpu device. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_command.c | 32 src/qemu/qemu_command.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 100deed..6201e29 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -948,6 +948,34 @@ qemuAssignDeviceChrAlias(virDomainDefPtr def, } int +qemuAssignDeviceCPUAlias(virDomainDefPtr def, + virDomainCPUDefPtr cpu, + int idx) +{ +if (idx == -1) { +size_t i; +idx = 0; + +for (i = 0; i def-ncpus; i++) { +int thisidx; +if ((thisidx = qemuDomainDeviceAliasIndex(def-cpus[i]-info, cpu)) 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(unable to determine device index from CPU device)); +return -1; +} + +if (thisidx = idx) +idx = thisidx + 1; +} +} + +if (virAsprintf(cpu-info.alias, cpu%d, idx) 0) +return -1; + +return 0; +} + +int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { size_t i; @@ -1017,6 +1045,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) if (qemuAssignDeviceChrAlias(def, def-consoles[i], i) 0) return -1; } +for (i = 0; i def-ncpus; i++) { +if (qemuAssignDeviceCPUAlias(def, def-cpus[i], i) 0) +return -1; +} for (i = 0; i def-nhubs; i++) { if (virAsprintf(def-hubs[i]-info.alias, hub%zu, i) 0) return -1; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 8eaf1e4..c63fd30 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -265,6 +265,9 @@ int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr r int qemuAssignDeviceChrAlias(virDomainDefPtr def, virDomainChrDefPtr chr, ssize_t idx); +int qemuAssignDeviceCPUAlias(virDomainDefPtr def, + virDomainCPUDefPtr cpu, + int idx); int qemuParseKeywords(const char *str, -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] Prevent removing a in-used static bridge and destroying a in-used virtual network
On 02/03/2015 11:47 AM, Michal Privoznik wrote: On 02.02.2015 15:08, Lin Ma wrote: * Get the live state info of a virtual network through netcf in networkGetXMLDesc. * Add --system flag for net-dumpxml to show the live state info. * Check the live state info in net-destroy. * Add --force flag for net-destroy to forcibly destroy the virtual network. * Check the transient interfaces info in iface-unbridge. --- Lin Ma (3): bridge_driver: Return the live state info of a given virtual network virsh: prevent destroying a in-used network for net-destroy virsh: prevent removing a in-used bridge for iface-unbridge include/libvirt/libvirt-network.h| 1 + src/Makefile.am | 3 + src/network/bridge_driver.c | 141 ++- src/network/bridge_driver_platform.h | 7 ++ tests/Makefile.am| 4 + tools/virsh-interface.c | 25 ++- tools/virsh-network.c| 62 ++- tools/virsh.pod | 8 +- 8 files changed, 241 insertions(+), 10 deletions(-) So I've spent some time thinking about this. I don't really like the idea of producing completely different XML (it doesn't even have network/ as its root element!). But I see what you're trying to achieve. How about putting the bridged interfaces into the network definition (on request signalized by a flag, of course). I think that if we're going to add the list of connected guest devices to a network's status, that it should just always be there - adding a new flag for every little bit of different status sets a bad precedent and sets us up to have an infinitely increasing number of flags. Like I mentioned in my response to one of the patches, I think this information is better gathered and maintained by the bridge driver as guests connect to / disconnect from a network; this avoids the necessity of dragging netcf into the picture and allows much better information - the name of the domain using each interface can be included. I think we've come to a point where we need to introduce live and config XML (like we have for domains). We already have that to some extent, but not truly. I think the situation is more that we have live and config XML, but there may be a small problem here and there. As a matter of fact, a long time ago virsh wasn't using the live XML to edit a network, and this was causing problems (e.g. if you tried to edit a network twice without restarting it, the second time you would lose all the changes from the first edit). On the other hand, looking into virNetworkDefFormat(), there's this '@connections' attribute to the network/ element which is a nonzero integer if the network is in use. Won't that suffice for what you're trying to achieve? In my opinion, yes - that's exactly the type of thing it was intended for :-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] virsh: prevent removing a in-used bridge for iface-unbridge
On 02/03/2015 11:39 AM, Michal Privoznik wrote: On 02.02.2015 15:08, Lin Ma wrote: By checking transient interfaces, It obtains the live information of attached interfaces to see if the bridge is in use. Signed-off-by: Lin Ma l...@suse.com --- tools/virsh-interface.c | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) Technically, this is a v2 to a previous patch (I mildly recall seeing something like this in the past). It looks to be the same patch, just with reference to a private bug report removed, and preceded with the check for net-destroy (since I had said in my response to the original patch that the behavior of iface-unbridge was made to be similar to net-destroy, and that my opinion was that either neither should be changed, or both). diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 5f848b6..ff40be0 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -1040,11 +1040,11 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) const char *br_name; char *if_type = NULL, *if_name = NULL; bool nostart = false; -char *br_xml = NULL; +char *br_xml = NULL, *br_xml_transient_if = NULL; xmlChar *if_xml = NULL; int if_xml_size; -xmlDocPtr xml_doc = NULL; -xmlXPathContextPtr ctxt = NULL; +xmlDocPtr xml_doc = NULL, xml_doc_transient_if = NULL; +xmlXPathContextPtr ctxt = NULL, ctxt_transient_if = NULL; xmlNodePtr top_node, if_node, cur; /* Get a handle to the original device */ @@ -1103,6 +1103,22 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) goto cleanup; } +/* verify whether there is any transient interface attached to bridge. */ +if (!(br_xml_transient_if = virInterfaceGetXMLDesc(br_handle, 0))) +goto cleanup; + +if (!(xml_doc_transient_if = virXMLParseStringCtxt(br_xml_transient_if, + _((bridge interface definition)), + ctxt_transient_if))) { +vshError(ctl, _(Failed to parse configuration of %s), br_name); +goto cleanup; +} + +if (virXPathNode(./bridge/interface[2], ctxt_transient_if) != NULL) { +vshError(ctl, %s, _(The bridge is in use by transient interfaces)); +goto cleanup; +} + /* Change the type and name of the outer/master interface to * the type/name of the attached slave interface. */ @@ -1198,10 +1214,13 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) virInterfaceFree(br_handle); VIR_FREE(if_xml); VIR_FREE(br_xml); +VIR_FREE(br_xml_transient_if); VIR_FREE(if_type); VIR_FREE(if_name); xmlXPathFreeContext(ctxt); +xmlXPathFreeContext(ctxt_transient_if); xmlFreeDoc(xml_doc); +xmlFreeDoc(xml_doc_transient_if); return ret; } ACK. I'll merge this tomorrow (unless somebody beats me). Please don't push it as is. I think the behavior of iface-unbridge should match whatever is done to net-destroy (if anything). If the change is made, it should be made to both at the same time, and this one should also have a --force option to allow overriding the extra check, as patch 2/3 does for net-destroy. (BTW, I'm still curious about Suse's use of netcf, as there have been no updates to the Suse driver in netcf since the initial port was imported several years ago. Are there downstream changes that can be sent upstream?) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] virsh: prevent removing a in-used bridge for iface-unbridge
Laine Stump wrote: (BTW, I'm still curious about Suse's use of netcf, as there have been no updates to the Suse driver in netcf since the initial port was imported several years ago. Are there downstream changes that can be sent upstream?) SUSE doesn't use netcf. We were unable to find a volunteer from the networking team to maintain the initial port. Instead they provided a netcf interface on top of their technologies, which at least allows us to use the libvirt netcf backend. Regards, Jim -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] virsh: prevent removing a in-used bridge for iface-unbridge
On 02/04/2015 10:57 AM, Jim Fehlig wrote: Laine Stump wrote: (BTW, I'm still curious about Suse's use of netcf, as there have been no updates to the Suse driver in netcf since the initial port was imported several years ago. Are there downstream changes that can be sent upstream?) SUSE doesn't use netcf. We were unable to find a volunteer from the networking team to maintain the initial port. Instead they provided a netcf interface on top of their technologies, which at least allows us to use the libvirt netcf backend. Ah yes, I vaguely remember this. They basically made a copy of the APIs in netcf.h, then provided their own library under it. This worries me, because it means that the two are in danger of getting out of sync in some subtle (or not so subtle) way. For example, netcf recently added support for reporting the link state (operstate from sysfs) and speed in its status output. If this other library for SUSE had been implemented as a backend in netcf, Suse would have gotten that addition more or less for free (since it is linux-specific, but not distro-specific), but instead people will complain that this feature (already used/expected in the output of libvirt virsh iface-dumpxml) doesn't work on SUSE until someone adds it to the SUSE work-alike library. (Even worse would be if something was implemented in both libraries, but behaved slightly differently in one). You know, there is no hard requirement that the current SUSE backend in netcf be the one that stays there - that backend was written by a person for (I think) some embedded system that was using a SUSE-based self-built distro, and they have long since abandoned it. If you have any interest in putting in a backend based on the code your network people have already written for their own library (either replacing the current SUSE backend, or in addition to it), I'd be happy to help with it. It may turn out to be more trouble than it's worth, but it's at least worth considering. Can you point me at the package that is implementing the netcf API, so I can poke around a bit? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] Prevent removing a in-used static bridge and destroying a in-used virtual network
On 02/04/2015 09:58 AM, Daniel P. Berrange wrote: On Wed, Feb 04, 2015 at 02:21:18AM -0500, Laine Stump wrote: On 02/03/2015 11:47 AM, Michal Privoznik wrote: On 02.02.2015 15:08, Lin Ma wrote: * Get the live state info of a virtual network through netcf in networkGetXMLDesc. * Add --system flag for net-dumpxml to show the live state info. * Check the live state info in net-destroy. * Add --force flag for net-destroy to forcibly destroy the virtual network. * Check the transient interfaces info in iface-unbridge. --- Lin Ma (3): bridge_driver: Return the live state info of a given virtual network virsh: prevent destroying a in-used network for net-destroy virsh: prevent removing a in-used bridge for iface-unbridge include/libvirt/libvirt-network.h| 1 + src/Makefile.am | 3 + src/network/bridge_driver.c | 141 ++- src/network/bridge_driver_platform.h | 7 ++ tests/Makefile.am| 4 + tools/virsh-interface.c | 25 ++- tools/virsh-network.c| 62 ++- tools/virsh.pod | 8 +- 8 files changed, 241 insertions(+), 10 deletions(-) So I've spent some time thinking about this. I don't really like the idea of producing completely different XML (it doesn't even have network/ as its root element!). But I see what you're trying to achieve. How about putting the bridged interfaces into the network definition (on request signalized by a flag, of course). I think that if we're going to add the list of connected guest devices to a network's status, that it should just always be there - adding a new flag for every little bit of different status sets a bad precedent and sets us up to have an infinitely increasing number of flags. Like I mentioned in my response to one of the patches, I think this information is better gathered and maintained by the bridge driver as guests connect to / disconnect from a network; this avoids the necessity of dragging netcf into the picture and allows much better information - the name of the domain using each interface can be included. You know if this checking for guests were done in the virNetworkDestroy API implementation in src/network/bridge_driver.c, instead of in virsh, then we would not need any of this code for extending the XML nor parsing it in virsh. We could simply check the number of connections which is something we have directly available internally. So 95% of this patch series would go away Except that the virNetworkDestroy() API was created before we realized it was a good idea to have a flags argument to every new API. So that would require creating a new virNetworkDestroyFlags() API (and the first flag to be defined would be VIR_NETWORK_DESTROY_GRACEFUL). Note that a network's connections count *is* returned in the status XML, so virsh could check that and it would work even when connecting to older servers. I think I prefer your idea, though, because it is more consistent with what is done for the virDomain API (it won't work when talking to older servers though, and virsh will have to be written to fall back to virNetworkDestroy() when the server is too old to have virNetworkDestroyFlags(). -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] Prevent removing a in-used static bridge and destroying a in-used virtual network
On Wed, Feb 04, 2015 at 12:39:56PM -0500, Laine Stump wrote: On 02/04/2015 09:58 AM, Daniel P. Berrange wrote: On Wed, Feb 04, 2015 at 02:21:18AM -0500, Laine Stump wrote: On 02/03/2015 11:47 AM, Michal Privoznik wrote: On 02.02.2015 15:08, Lin Ma wrote: * Get the live state info of a virtual network through netcf in networkGetXMLDesc. * Add --system flag for net-dumpxml to show the live state info. * Check the live state info in net-destroy. * Add --force flag for net-destroy to forcibly destroy the virtual network. * Check the transient interfaces info in iface-unbridge. --- Lin Ma (3): bridge_driver: Return the live state info of a given virtual network virsh: prevent destroying a in-used network for net-destroy virsh: prevent removing a in-used bridge for iface-unbridge include/libvirt/libvirt-network.h| 1 + src/Makefile.am | 3 + src/network/bridge_driver.c | 141 ++- src/network/bridge_driver_platform.h | 7 ++ tests/Makefile.am| 4 + tools/virsh-interface.c | 25 ++- tools/virsh-network.c| 62 ++- tools/virsh.pod | 8 +- 8 files changed, 241 insertions(+), 10 deletions(-) So I've spent some time thinking about this. I don't really like the idea of producing completely different XML (it doesn't even have network/ as its root element!). But I see what you're trying to achieve. How about putting the bridged interfaces into the network definition (on request signalized by a flag, of course). I think that if we're going to add the list of connected guest devices to a network's status, that it should just always be there - adding a new flag for every little bit of different status sets a bad precedent and sets us up to have an infinitely increasing number of flags. Like I mentioned in my response to one of the patches, I think this information is better gathered and maintained by the bridge driver as guests connect to / disconnect from a network; this avoids the necessity of dragging netcf into the picture and allows much better information - the name of the domain using each interface can be included. You know if this checking for guests were done in the virNetworkDestroy API implementation in src/network/bridge_driver.c, instead of in virsh, then we would not need any of this code for extending the XML nor parsing it in virsh. We could simply check the number of connections which is something we have directly available internally. So 95% of this patch series would go away Except that the virNetworkDestroy() API was created before we realized it was a good idea to have a flags argument to every new API. So that would require creating a new virNetworkDestroyFlags() API (and the first flag to be defined would be VIR_NETWORK_DESTROY_GRACEFUL). Note that a network's connections count *is* returned in the status XML, so virsh could check that and it would work even when connecting to older servers. I think I prefer your idea, though, because it is more consistent with what is done for the virDomain API (it won't work when talking to older servers though, and virsh will have to be written to fall back to virNetworkDestroy() when the server is too old to have virNetworkDestroyFlags(). Yep, adding a virNetworkDestroyFlags() is no big deal - we'll inevitably need it at some point. There's probably an argument for identifying all our remaining APIs which lack a flags parameter and fixing it once and for all :-) 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] [RFC PATCH 06/12] qemu: memdev: Add infrastructure to load memory device information
On 01/30/2015 08:21 AM, Peter Krempa wrote: When using 'acpi-dimm' memory devices with qemu, some of the information like the slot number and base address need to be reloaded from qemu after process start so that it reflects the actual state. The state then allows to use memory devices across migrations. --- src/qemu/qemu_domain.c | 43 src/qemu/qemu_domain.h | 4 ++ src/qemu/qemu_monitor.c | 45 + src/qemu/qemu_monitor.h | 14 ++ src/qemu/qemu_monitor_json.c | 116 +++ src/qemu/qemu_monitor_json.h | 5 ++ src/qemu/qemu_process.c | 4 ++ 7 files changed, 231 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 25540c4..df912a6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2773,6 +2773,49 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, return 0; } + +int +qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver, + virDomainObjPtr vm, + int asyncJob) +{ +qemuDomainObjPrivatePtr priv = vm-privateData; +virHashTablePtr meminfo = NULL; +size_t i; + +if (vm-def-nmems == 0) +return 0; + +if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) 0) +return -1; +if (qemuMonitorGetMemoryDeviceInfo(priv-mon, meminfo) 0) { +ignore_value(qemuDomainObjExitMonitor(driver, vm)); +return -1; +} + +if (qemuDomainObjExitMonitor(driver, vm) 0) This would leak meminfo +return -1; + I know we don't have a norm for how this sequence goes, but along with Jan's point about -2 being checked back in the caller... The norm seems to be to: ret = qemuMonitor*(); if (*ExitMonitor) 0) ret = -1; goto cleanup or error; if (ret 0) goto cleanup; ... Caller would probably want to make sure the VM is still active or not. +for (i = 0; i vm-def-nmems; i++) { +virDomainMemoryDefPtr mem = vm-def-mems[i]; +qemuMonitorMemoryDeviceInfoPtr dimm; + +if (!mem-info.alias) +continue; + +if (!(dimm = virHashLookup(meminfo, mem-info.alias))) +continue; + +mem-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ACPI_DIMM; +mem-info.addr.acpiDimm.slot = dimm-slot; +mem-info.addr.acpiDimm.base = dimm-address; +} + cleanup: +virHashFree(meminfo); +return ret; +} + + bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, ...snip... diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b0f7b1c..ba7c8e2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4871,6 +4871,10 @@ int qemuProcessStart(virConnectPtr conn, if (qemuDomainUpdateDeviceList(driver, vm, asyncJob) 0) goto cleanup; +VIR_DEBUG(Updating info of memory devices); +if (qemuDomainUpdateMemoryDeviceInfo(driver, vm, asyncJob) 0) +goto cleanup; + Haven't looked forward yet, but is this something that needs to be done at qemuProcessReconnec ? John /* Technically, qemuProcessStart can be called from inside * QEMU_ASYNC_JOB_MIGRATION_IN, but we are okay treating this like * a sync job since no other job can call into the domain until -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2] S390: ccw support for virsh attach-disk address parameter
This patch add the ccw support for the optional address parameter of virsh attach-disk. Stefan Zimmermann (2): S390: ccw support for virsh attach-disk address parameter S390: Documentation for ccw address type docs/formatdomain.html.in | 5 ++--- tools/virsh-domain.c | 46 +- tools/virsh.pod | 3 ++- 3 files changed, 49 insertions(+), 5 deletions(-) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] check fc_host and vport_ops capabilities in SCSI host nodedevs
On 02/03/2015 03:59 PM, John Ferlan wrote: On 02/03/2015 06:55 AM, Shivaprasad G Bhat wrote: fc_host vport_ops devices are SCSI devices with additional capabilities. Mere string comparison of basic types is not sufficient in this case. This patch introduces additional capability checks for SCSI devices if the user is looking to list 'fc_host' or 'vport_ops' devices. Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com --- src/conf/node_device_conf.c |8 1 file changed, 8 insertions(+) While this does work and more or less follows what was done for virNodeDeviceCapMatch, I'm wondering if the 'fc_host' and 'vports_ops' capabilities need to also be returned in a list of capabilities for a node device That is I see that virNodeDeviceListCaps() seems to be only returning 1 capability for every device. However, for the scsi_host, it has those additional fc_host and vport_ops capabilities which if returned in the list would then be found by the python listDevices code which for some devices (like the scsi_host here) there may be more than one way to get at the information. I'm investigating whether modifying nodeDeviceListCaps() in src/node_device/node_device_driver.c to add fc_host and vport_ops to the return caps_list will resolve the issue... This also means virNodeDeviceNumOfCaps() (and it's driver API nodeDeviceNumOfCaps) will need some tweaking too. Another option would be to fix the libvirt-python code to use ListAllDevices with the flags argument like virsh does. John ...snip... As it turns out your patch will be required in order to cover the virNodeListDevices case as well as the attached patch in order to cover the virNodeDeviceNumOfCaps and virNodeDeviceListCaps cases. Could you take a look at the attached code and try it out on your system to make sure it does what I expect (the system I use to test these types of checks is unavailable at the moment). What should happen is for 'scsi_host' devices with 'fc_host' and/or 'vports' capability types - the cap_list returned will be larger than 1. The code currently only has ever returned 1 element. The patch also lists the sample python which should work. With your successful test, I'll push the patches (although I'm tweaking your commit message a bit - it'll be very similar to the attached patch commit message). Thanks - John From 37c59646de925e1f8eb76d1022d33032cd671bf5 Mon Sep 17 00:00:00 2001 From: John Ferlan jfer...@redhat.com Date: Wed, 4 Feb 2015 08:10:52 -0500 Subject: [PATCH] nodedev: check/add for scsi_host caps for NumOfCaps and ListCaps Commit id '652a2ec6' introduced two new node device capability flags and the ability to use those flags as a way to search for a specific subset of a 'scsi_host' device - namely a 'fc_host' and/or 'vports'. The code modified the virNodeDeviceCapMatch whichs allows for searching using the 'virsh nodedev-list [cap]' via virConnectListAllNodeDevices. However, the original patches did not account for other searches for the same capability key from virNodeDeviceNumOfCaps and virNodeDeviceListCaps using nodeDeviceNumOfCaps and nodeDeviceListCaps. Since 'fc_host' and 'vports' are self defined bits of a 'scsi_host' device mere string comparison against the basic/root type is not sufficient. This patch adds the check for the 'fc_host' and 'vports' bits within a 'scsi_host' device and allows the following python code to find the capabilities for the device: import libvirt conn = libvirt.openReadOnly('qemu:///system') devs = conn.listAllDevices() for dev in devs: if 'fc_host' in dev.listCaps() or 'vports' in dev.listCaps(): print dev.name(),dev.numOfCaps(),dev.listCaps() Signed-off-by: John Ferlan jfer...@redhat.com --- src/node_device/node_device_driver.c | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index c1ad3cd..b8d9f4f 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -383,8 +383,20 @@ nodeDeviceNumOfCaps(virNodeDevicePtr dev) if (virNodeDeviceNumOfCapsEnsureACL(dev-conn, obj-def) 0) goto cleanup; -for (caps = obj-def-caps; caps; caps = caps-next) +for (caps = obj-def-caps; caps; caps = caps-next) { ++ncaps; + +if (caps-type == VIR_NODE_DEV_CAP_SCSI_HOST) { +if (caps-data.scsi_host.flags +VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) +ncaps++; + +if (caps-data.scsi_host.flags +VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) +ncaps++; +} +} + ret = ncaps; cleanup: @@ -419,6 +431,24 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames) for (caps = obj-def-caps; caps ncaps maxnames; caps = caps-next) { if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps-type)) 0)
[libvirt] [PATCH 2/2] S390: Documentation for ccw address type
Change the wording in the device-address-part of the docmunentation since the ccw bus address support added to the optional address parameter of virsh attach-disk for S390. Signed-off-by: Stefan Zimmermann s...@linux.vnet.ibm.com Reviewed-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com Reviewed-by: Cornelia Huck cornelia.h...@de.ibm.com --- docs/formatdomain.html.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c5ad6f4..181b23e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2755,9 +2755,8 @@ codedevno/code (a hex value between 0 and 0x, inclusive). Partially specified bus addresses are not allowed. If omitted, libvirt will assign a free bus address with -cssid=0xfe and ssid=0. Virtio devices for s390 must have their -cssid set to 0xfe in order to be recognized by the guest -operating system. +cssid=0xfe and ssid=0. Virtio-ccw devices must have their cssid +set to 0xfe. span class=sinceSince 1.0.4/span /dd dtcodetype='isa'/code/dt -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 08/12] qemu: add support for memory devices
On 01/30/2015 08:21 AM, Peter Krempa wrote: Add support to start qemu instance with 'pc-dimm' device. Thanks to the refactors we are able to reuse the existing function to determine the parameters. --- src/qemu/qemu_command.c | 114 src/qemu/qemu_domain.c | 18 ++-- src/qemu/qemu_domain.h | 2 + tests/qemuxml2xmltest.c | 1 + 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5820fb5..7c31723 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1156,6 +1156,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) if (virAsprintf(def-tpm-info.alias, tpm%d, 0) 0) return -1; } +for (i = 0; i def-nmems; i++) { +if (virAsprintf(def-mems[i]-info.alias, dimm%zu, i) 0) +return -1; +} return 0; } @@ -4748,6 +4752,97 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, } +static char * +qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem, + virDomainDefPtr def, + virQEMUCapsPtr qemuCaps, + virQEMUDriverConfigPtr cfg) +{ +virJSONValuePtr props = NULL; +char *alias = NULL; +const char *backendType; +char *ret = NULL; + +if (!mem-info.alias) { +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(memory device alias is not assigned)); +return NULL; +} + +if (virAsprintf(alias, mem%s, mem-info.alias) 0) +goto cleanup; + +qemuDomainMemoryDeviceAlignSize(mem); + +if (qemuBuildMemoryBackendStr(mem-size, mem-pagesize, + mem-targetNode, mem-sourceNodes, NULL, + def, qemuCaps, cfg, + backendType, props, true) 0) +goto cleanup; + +ret = qemuBuildObjectCommandlineFromJSON(backendType, alias, props); + + cleanup: +VIR_FREE(alias); +virJSONValueFree(props); + +return ret; +} + + +static char * +qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, + virQEMUCapsPtr qemuCaps) +{ +virBuffer buf = VIR_BUFFER_INITIALIZER; + +if (!mem-info.alias) { +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(missing alias for memory device)); +return NULL; +} + +switch ((virDomainMemoryModel) mem-model) { +case VIR_DOMAIN_MEMORY_MODEL_ACPI_DIMM: +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(this qemu doesn't support the pc-dimm device)); +return NULL; +} + +if (mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ACPI_DIMM +mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(only 'acpi-dimm' addresses are supported for the + pc-dimm device)); +return NULL; +} + +virBufferAsprintf(buf, pc-dimm,node=%d,memdev=mem%s,id=%s, + mem-targetNode, mem-info.alias, mem-info.alias); + +if (mem-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ACPI_DIMM) { +virBufferAsprintf(buf, ,slot=%d, mem-info.addr.acpiDimm.slot); +virBufferAsprintf(buf, ,base=%llu, mem-info.addr.acpiDimm.base); +} + +break; + +case VIR_DOMAIN_MEMORY_MODEL_NONE: +case VIR_DOMAIN_MEMORY_MODEL_LAST: +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(invalid memory device type)); +break; + +} + +if (virBufferCheckError(buf) 0) +return NULL; + +return virBufferContentAndReset(buf); +} + + char * qemuBuildNicStr(virDomainNetDefPtr net, const char *prefix, @@ -8351,6 +8446,25 @@ qemuBuildCommandLine(virConnectPtr conn, if (qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) 0) goto error; Coverity has a FORWARD_NULL complaint... Right above this code there's: 8445if (def-cpu def-cpu-ncells) 8446if (qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) 0) 8447goto error; 8448 So there's a chance def-cpu == NULL +for (i = 0; i def-nmems; i++) { +char *backStr; +char *dimmStr; + +if (!(backStr = qemuBuildMemoryDimmBackendStr(def-mems[i], def, + qemuCaps, cfg))) Because def-cpu is NULL above, Coverity points out that qemuBuildMemoryDimmBackendStr will call qemuBuildMemoryBackendStr which deref's def-cpu-cells[guestNode].memAccess John +goto error;
Re: [libvirt] [PATCHv2] Trivially support DomainHasManagedSaveImage
On 02/04/2015 05:36 AM, Ján Tomko wrote: Return 0 instead of ERR_NO_SUPPORT in each driver where we don't support managed save. This avoids spamming daemon logs when 'virsh dominfo' is run. https://bugzilla.redhat.com/show_bug.cgi?id=1095637 --- src/bhyve/bhyve_driver.c | 25 - src/esx/esx_driver.c | 11 ++- src/lxc/lxc_driver.c | 26 +- src/openvz/openvz_driver.c | 12 +++- src/parallels/parallels_driver.c | 11 ++- src/phyp/phyp_driver.c | 11 ++- src/uml/uml_driver.c | 33 - src/vbox/vbox_common.c | 11 ++- src/vmware/vmware_driver.c | 11 ++- src/xenapi/xenapi_driver.c | 11 ++- 10 files changed, 152 insertions(+), 10 deletions(-) +static int +bhyveDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags) +{ +virDomainObjPtr vm = NULL; +int ret = -1; + +virCheckFlags(0, -1); + +if (!(vm = bhyveDomObjFromDomain(domain))) +goto cleanup; Here, you validate that the vm exists. +static int +esxDomainHasManagedSaveImage(virDomainPtr dom ATTRIBUTE_UNUSED, unsigned int flags) +{ +virCheckFlags(0, -1); + +return 0; whereas here, you blindly return 0 even if the vm does not exist. That feels inconsistent to me; I'd feel better if we returned 0 only if we know the domain exists. But I can also be persuaded to live with the weaker semantics, in which case: ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] add guest agent configuration to domain xml
On 02/04/2015 02:36 AM, hongming wrote: hi Jmiao Don't forget to add [libvirt][libvirt-test-API] to your patch summary. The '[libvirt] portion is added by the list server. It is sufficient to do: git config format.subjectprefix 'test-API PATCH' -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 03/12] qemu: Implement setup of memory hotplug parameters
On 01/30/2015 08:21 AM, Peter Krempa wrote: To enable memory hotplug the maximum memory size and slot count need to be specified. As qemu supports now other units than mebibytes when specifying memory, use the new interface in this case. --- docs/formatdomain.html.in | 2 +- src/qemu/qemu_command.c| 41 ++ src/qemu/qemu_domain.c | 4 --- .../qemuxml2argv-memory-hotplug-nonuma.xml | 22 .../qemuxml2argv-memory-hotplug.args | 6 .../qemuxml2argv-memory-hotplug.xml| 34 ++ tests/qemuxml2argvtest.c | 4 +++ tests/qemuxml2xmltest.c| 3 ++ 8 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 12f7ede..c059195 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -713,7 +713,7 @@ Note that due to alignment of the memory chunks added via memory hotplug the full size allocation specified by this element may be impossible to achieve. -span class='since'Since 1.2.12/span +span class='since'Since 1.2.12 supported by the QEMU driver./span /dd dtcodecurrentMemory/code/dt My git am -3 wasn't happy with this change - didn't want to apply it: fatal: sha1 information is lacking or useless (docs/formatdomain.html.in). I just removed it and kept going... John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Bugfix for building with no-git-option
On 02/04/2015 05:49 AM, Stefan Zimmermann wrote: If you will build libvirt with the no-git-option than you is the gnulib-srcdir mandatory. You will lose this information till now. With this patch you will save this inforamtion. s/inforamtion/information/ Reads awkwardly. Better would be: maint: improve usage of autogen's --no-git autogen.sh supports a --no-git mode that avoids the need to use git; but to date, it only worked if GNULIB_SRCDIR is set in the environment. However, the bootstrap script also works if it is passed a --gnulib-srcdir command line argument; add support for that in autogen.sh. Signed-off-by: Stefan Zimmermann s...@linux.vnet.ibm.com --- autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) NACK. diff --git a/autogen.sh b/autogen.sh index 1965f64..0168d24 100755 --- a/autogen.sh +++ b/autogen.sh @@ -18,8 +18,8 @@ test -f src/libvirt.c || { EXTRA_ARGS= no_git= if test x$1 = x--no-git; then - no_git= $1 - shift + no_git= $1 $2 This assumes that the caller supplies --gnulib-srcdir as the second argument, immediately after --no-git. But this is not required; in fact, it is possible to set GNULIB_SRCDIR in the environment and not even pass --gnulib-srcdir on the command line. Also, 'shift 2' is not portable to older /bin/sh. A better fix would be appending to $no_git only after checking if the next argument(s) after --no-git really specify a gnulib srcdir. But the idea of your patch makes sense. Would you like to try your hand at v2? Maybe something like: no_git= if test x$1 = x--no-git; then no_git= $1 shift case $1 $2 in --gnulib-srcdir=*) no_git=$no_git $1; shift ;; --gnulib-srcdir *) no_git=$no_git $1 $2; shift; shift ;; esac -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 02/10] conf: support backend domain name in disk and network devices
At least Xen supports backend drivers in another domain (aka driver domain). This patch introduces XML config option for such setting as 'domain' attribute of 'source' element. Verification its content is left for the driver. In the future same option will be needed for USB devices (hostdev objects), but for now libxl doesn't have support for PVUSB. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- Changes in v2: - describe in docs/formatdomain.html.in - enforce empty domain tag (only 'name' attribute allowed) Changes in v3: - change domain name='xx'/ element to domain='' attribute of source element - this is more logical place - grammar of docs docs/formatdomain.html.in | 29 +++-- docs/schemas/domaincommon.rng | 20 src/conf/domain_conf.c| 33 + src/conf/domain_conf.h| 1 + src/util/virstoragefile.c | 4 +++- src/util/virstoragefile.h | 1 + 6 files changed, 81 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c5ad6f4..38c42d5 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1907,13 +1907,17 @@ span class=sincesince 0.0.3/span/dt dd The codefile/code attribute specifies the fully-qualified - path to the file holding the disk. + path to the file holding the disk. The optional + codedomain/code attribute allows specifying a backend domain + (aka driver domain) where the file is stored. /dd dtcodetype='block'/code span class=sincesince 0.0.3/span/dt dd The codedev/code attribute specifies the path to the - host device to serve as the disk. + host device to serve as the disk. The optional + codedomain/code attribute allows specifying a backend domain + (aka driver domain) for the device. /dd dtcodetype='dir'/code span class=sincesince 0.7.5/span/dt @@ -4336,6 +4340,27 @@ qemu-kvm -net nic,model=? /dev/null element is unspecified is to have the link state codeup/code. span class=sinceSince 0.9.5/span /p +h5a name=elementDomainSetting up a network backend in a driver domain/a/h5 +pre + ... + lt;devicesgt; +... +lt;interface type='bridge'gt; + lt;source bridge='br0' bdomain='netvm'/b/gt; +lt;/interfacegt; +... + lt;/devicesgt; + .../pre + +p + The optional codedomain/code attribute allows specifying a backend + domain (aka driver domain) for the device. Use the codename/code attribute + to specify its name. You can use it to create a direct network link between + domains (so data will not go through host system). Use with type 'ethernet' + to create plain network link, or with 'bridge' to connect to some bridge + inside the driver domain. + span class=sinceSince 1.0.7 (Xen only)/span +/p h5a name=ipconfigIP configuration/a/h5 pre diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d467dce..a4321f1 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1340,6 +1340,11 @@ attribute name=file ref name=absFilePath/ /attribute +optional + attribute name=domain +ref name=domainName/ + /attribute +/optional /optional optional ref name=storageStartupPolicy/ @@ -1365,6 +1370,11 @@ /attribute /optional optional +attribute name=domain + ref name=domainName/ +/attribute + /optional + optional ref name=storageStartupPolicy/ /optional optional @@ -2040,6 +2050,11 @@ attribute name=bridge ref name=deviceName/ /attribute +optional + attribute name=domain +ref name=domainName/ + /attribute +/optional empty/ /element /optional @@ -2059,6 +2074,11 @@ attribute name=dev ref name=deviceName/ /attribute +optional + attribute name=domain +ref name=domainName/ + /attribute +/optional empty/ /element /optional diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4251b13..17b699a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1442,6 +1442,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def) VIR_FREE(def-backend.vhost);
Re: [libvirt] [libvirt-test-API][PATCH 2/2] Fix regression issues
On 02/04/2015 06:03 PM, jiahu wrote: 1. Using .get method to get a optional dict value 2. Adjust variables sequence during call mac_to_ip --- repos/domain/destroy.py | 4 ++-- repos/domain/install_linux_cdrom.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 154ffaf..36f70db 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -32,7 +32,7 @@ def destroy(params): logger = params['logger'] params.pop('logger') guestname = params['guestname'] -br = params['bridgename'] +br = params.get('bridgename','virbr0') flags = if params.has_key('flags'): flags = params['flags'] @@ -59,7 +59,7 @@ def destroy(params): # Get domain ip mac = utils.get_dom_mac_addr(guestname) logger.info(get ip by mac address) -ip = utils.mac_to_ip(mac,br,180) +ip = utils.mac_to_ip(mac,180,br) logger.info(the ip address of guest is %s % ip) # Destroy domain diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 9d3a7e9..412712b 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -147,7 +147,7 @@ def install_linux_cdrom(params): guestname = params.get('guestname') guestos = params.get('guestos') guestarch = params.get('guestarch') -br = params['bridgename'] +br = params.get('bridgename','virbr0') xmlstr = params['xml'] logger.info(the name of guest is %s % guestname) @@ -304,7 +304,7 @@ def install_linux_cdrom(params): time.sleep(10) timeout -= 10 -ip = utils.mac_to_ip(mac,br,180) +ip = utils.mac_to_ip(mac,180,br) if not ip: logger.info(str(timeout) + s left) ACK and Pushed. Thanks Hongming -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 05/10] libxl: pass ipaddr to libxl toolstack
Do not silently ignore its value. LibXL support only one address, so refuse multiple IPs. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- src/libxl/libxl_conf.c | 5 + src/libxl/libxl_domain.c | 11 +++ 2 files changed, 16 insertions(+) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index c9f8ad5..4730585 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1133,6 +1133,11 @@ libxlMakeNic(virDomainDefPtr def, case VIR_DOMAIN_NET_TYPE_ETHERNET: if (VIR_STRDUP(x_nic-script, l_nic-script) 0) return -1; +if (l_nic-nips 0) { +x_nic-ip = virSocketAddrFormat(l_nic-ips[0]-address); +if (!x_nic-ip) +return -1; +} break; case VIR_DOMAIN_NET_TYPE_NETWORK: { diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 856cfb4..afb0b15 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -482,6 +482,17 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, STRNEQ(def-os.type, hvm)) dev-data.chr-targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; +if (dev-type == VIR_DOMAIN_DEVICE_NET +(dev-data.net-type == VIR_DOMAIN_NET_TYPE_BRIDGE || + dev-data.net-type == VIR_DOMAIN_NET_TYPE_ETHERNET)) { +if (dev-data.net-nips 1) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +_(multiple IP addresses not supported on device type %s), +virDomainNetTypeToString(dev-data.net-type)); +return -1; +} +} + if (dev-type == VIR_DOMAIN_DEVICE_HOSTDEV || (dev-type == VIR_DOMAIN_DEVICE_NET dev-data.net-type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) { -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH v2 02/12] domain_conf: introduce cpu def helpers
On Wed, 2015-02-04 at 09:46 +, Daniel P. Berrange wrote: On Wed, Feb 04, 2015 at 05:42:42PM +0800, Zhu Guihua wrote: On Wed, 2015-02-04 at 09:25 +, Daniel P. Berrange wrote: On Wed, Feb 04, 2015 at 05:18:20PM +0800, Zhu Guihua wrote: virDomainCPUDefFree - free memory allocated virDomainCPUDefParseXML - parse job type virDomainCPUDefFormat - output job type Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- docs/formatdomain.html.in | 28 +++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c| 82 +++ src/conf/domain_conf.h| 1 + src/libvirt_private.syms | 1 + 5 files changed, 115 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f8d5f89..10cbd29 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5830,6 +5830,34 @@ qemu-kvm -net nic,model=? /dev/null /dd /dl + h4a name=elementsCpuCPU device/a/h4 + p +CPU device allows to be hot added to the guest. +span class=sinceSince 1.2.12, QEMU and KVM only/span + /p + +pre + ... + lt;devicesgt; +lt;cpu match='exact'gt; + lt;model fallback='allow'gt;core2duolt;/modelgt; + lt;vendorgt;Intellt;/vendorgt; + lt;topology sockets='1' cores='2' threads='1'/gt; + lt;feature policy='disable' name='lahf_lm'/gt; +lt;/cpugt; + lt;devicesgt; NACK, it is just madness to duplicate the CPU info we already have in a different place in the XML. Yes, it's duplicate. But I think it represents different meaning, it is under xml tag 'device'. Regardless my NACK stands. This kind of duplication is just madness that causes problems for applications developers alike. Agree. It is easy to cause misunderstanding. I will find a better way to handle this. Thanks for your help. Regards, Zhu Regards, Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-test-API][PATCH 2/2] Fix regression issues
1. Using .get method to get a optional dict value 2. Adjust variables sequence during call mac_to_ip --- repos/domain/destroy.py | 4 ++-- repos/domain/install_linux_cdrom.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 154ffaf..36f70db 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -32,7 +32,7 @@ def destroy(params): logger = params['logger'] params.pop('logger') guestname = params['guestname'] -br = params['bridgename'] +br = params.get('bridgename','virbr0') flags = if params.has_key('flags'): flags = params['flags'] @@ -59,7 +59,7 @@ def destroy(params): # Get domain ip mac = utils.get_dom_mac_addr(guestname) logger.info(get ip by mac address) -ip = utils.mac_to_ip(mac,br,180) +ip = utils.mac_to_ip(mac,180,br) logger.info(the ip address of guest is %s % ip) # Destroy domain diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 9d3a7e9..412712b 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -147,7 +147,7 @@ def install_linux_cdrom(params): guestname = params.get('guestname') guestos = params.get('guestos') guestarch = params.get('guestarch') -br = params['bridgename'] +br = params.get('bridgename','virbr0') xmlstr = params['xml'] logger.info(the name of guest is %s % guestname) @@ -304,7 +304,7 @@ def install_linux_cdrom(params): time.sleep(10) timeout -= 10 -ip = utils.mac_to_ip(mac,br,180) +ip = utils.mac_to_ip(mac,180,br) if not ip: logger.info(str(timeout) + s left) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 06/12] domain_conf: allocate cpu's apic id dynamically
Add a bitmap apic_idmap to store status of APIC IDs. If you want to use an APIC ID, you can find a minimum value which has not been used in the bitmap. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/conf/domain_conf.c | 15 +++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 5 - 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f83eada..45c8e87 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13020,6 +13020,12 @@ virDomainDefParseXML(xmlDocPtr xml, } } +if (!(def-apic_id_map = virBitmapNew(def-maxvcpus))) +goto error; + +for (i = 0; i def-vcpus; i++) +ignore_value(virBitmapSetBit(def-apic_id_map, i)); + tmp = virXPathString(string(./vcpu[1]/@placement), ctxt); if (tmp) { if ((def-placement_mode = @@ -16432,6 +16438,15 @@ virDomainVcpuPinDel(virDomainDefPtr def, int vcpu) } } +uint32_t +virDomainCPUGetFreeApicID(virDomainDefPtr def) +{ +int idx; +idx = virBitmapNextClearBit(def-apic_id_map, 0); + +return idx; +} + int virDomainEmulatorPinAdd(virDomainDefPtr def, unsigned char *cpumap, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 144f79a..ff8e0b9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2074,6 +2074,7 @@ struct _virDomainDef { unsigned short maxvcpus; int placement_mode; virBitmapPtr cpumask; +virBitmapPtr apic_id_map; unsigned int iothreads; @@ -2551,6 +2552,8 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list, void virDomainVcpuPinDel(virDomainDefPtr def, int vcpu); +uint32_t virDomainCPUGetFreeApicID(virDomainDefPtr def); + int virDomainEmulatorPinAdd(virDomainDefPtr def, unsigned char *cpumap, int maplen); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index df4f508..b23c45c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -430,6 +430,7 @@ virDomainVcpuPinDefFree; virDomainVcpuPinDel; virDomainVcpuPinFindByVcpu; virDomainVcpuPinIsDuplicate; +virDomainCPUGetFreeApicID; virDomainVideoDefaultRAM; virDomainVideoDefaultType; virDomainVideoDefFree; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4ec3b3c..c6318bc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4371,6 +4371,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver, int ncpupids; virCgroupPtr cgroup_vcpu = NULL; char *mem_mask = NULL; +uint32_t apic_id; qemuDomainObjEnterMonitor(driver, vm); @@ -4380,13 +4381,15 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver, if (nvcpus vcpus) { for (i = vcpus; i nvcpus; i++) { /* Online new CPU */ -rc = qemuMonitorSetCPU(priv-mon, i, true); +apic_id = virDomainCPUGetFreeApicID(vm-def); +rc = qemuMonitorSetCPU(priv-mon, apic_id, true); if (rc == 0) goto unsupported; if (rc 0) goto exit_monitor; vcpus++; +ignore_value(virBitmapSetBit(vm-def-apic_id_map, apic_id)); } } else { for (i = vcpus - 1; i = nvcpus; i--) { -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 08/12] qemu: introduce qemuBuildCPUDeviceStr
qemuBuildCPUDeviceStr being introduced is responsible for creating command line argument for '-device' for given cpu device, and checking host cpu compat. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_command.c | 88 + src/qemu/qemu_command.h | 7 2 files changed, 95 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6201e29..513b726 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6003,6 +6003,88 @@ static char *qemuBuildTPMDevStr(const virDomainDef *def, } +int +qemuBuildCPUDeviceStr(char **deviceStr, + virQEMUDriverPtr driver, + const virDomainDef *def, + virDomainCPUDefPtr dev, + virQEMUCapsPtr qemuCaps) +{ +char *model = NULL; +virCPUDefPtr host = NULL; +char *compare_msg = NULL; +virCPUCompareResult cmp; +virCapsPtr caps = NULL; +bool compareAgainstHost = ((def-virtType == VIR_DOMAIN_VIRT_KVM || +def-cpu-mode != VIR_CPU_MODE_CUSTOM) +def-cpu-mode != VIR_CPU_MODE_HOST_PASSTHROUGH); + +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_X86_64_CPU)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(%s not supported in this QEMU binary), dev-virCPU-model); +goto error; +} + +if (!(caps = virQEMUDriverGetCapabilities(driver, false))) +goto error; + +host = caps-host.cpu; + +/* For KVM, CPU features are not emulated, so should consider host compat */ +if (compareAgainstHost) { +cmp = cpuGuestData(host, dev-virCPU, NULL, compare_msg); +switch (cmp) { +case VIR_CPU_COMPARE_INCOMPATIBLE: +if (compare_msg) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(guest and host CPU are not compatible: %s), + compare_msg); +} else { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(guest CPU is not compatible with host CPU)); +} +case VIR_CPU_COMPARE_ERROR: +goto error; + +default: +break; +} +} + +if (virAsprintf(model, %s-x86_64-cpu, dev-virCPU-model) 0) +goto error; + +if (virAsprintf(deviceStr, %s,id=%s,apic-id=%d, +model, dev-info.alias, dev-apic_id) 0) +goto error; + +return 0; + + error: +VIR_FREE(model); +VIR_FREE(compare_msg); +virObjectUnref(caps); +return -1; +} + +static int +qemuBuildCPUDeviceCommandLine(virCommandPtr cmd, + virQEMUDriverPtr driver, + const virDomainDef *def, + virDomainCPUDefPtr dev, + virQEMUCapsPtr qemuCaps) +{ +char *devstr = NULL; + +if (qemuBuildCPUDeviceStr(devstr, driver, def, dev, qemuCaps) 0) +return -1; + +virCommandAddArgList(cmd, -device, devstr, NULL); +VIR_FREE(devstr); +return 0; +} + + static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -9922,6 +10004,12 @@ qemuBuildCommandLine(virConnectPtr conn, goto error; } +/* add cpu devices */ +for (i = 0; i def-ncpus; i++) { +if (qemuBuildCPUDeviceCommandLine(cmd, driver, def, def-cpus[i], qemuCaps) 0) +goto error; +} + if (def-nvram) { if (ARCH_IS_PPC64(def-os.arch) STRPREFIX(def-os.machine, pseries)) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index c63fd30..18e0dfb 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -94,6 +94,13 @@ qemuBuildChrDeviceStr(char **deviceStr, virDomainChrDefPtr chr, virQEMUCapsPtr qemuCaps); +int +qemuBuildCPUDeviceStr(char **deviceStr, + virQEMUDriverPtr driver, + const virDomainDef *def, + virDomainCPUDefPtr cpu, + virQEMUCapsPtr qemuCaps); + /* With vlan == -1, use netdev syntax, else old hostnet */ char *qemuBuildHostNetStr(virDomainNetDefPtr net, virQEMUDriverPtr driver, -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH v2 02/12] domain_conf: introduce cpu def helpers
On Wed, 2015-02-04 at 09:25 +, Daniel P. Berrange wrote: On Wed, Feb 04, 2015 at 05:18:20PM +0800, Zhu Guihua wrote: virDomainCPUDefFree - free memory allocated virDomainCPUDefParseXML - parse job type virDomainCPUDefFormat - output job type Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- docs/formatdomain.html.in | 28 +++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c| 82 +++ src/conf/domain_conf.h| 1 + src/libvirt_private.syms | 1 + 5 files changed, 115 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f8d5f89..10cbd29 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5830,6 +5830,34 @@ qemu-kvm -net nic,model=? /dev/null /dd /dl + h4a name=elementsCpuCPU device/a/h4 + p +CPU device allows to be hot added to the guest. +span class=sinceSince 1.2.12, QEMU and KVM only/span + /p + +pre + ... + lt;devicesgt; +lt;cpu match='exact'gt; + lt;model fallback='allow'gt;core2duolt;/modelgt; + lt;vendorgt;Intellt;/vendorgt; + lt;topology sockets='1' cores='2' threads='1'/gt; + lt;feature policy='disable' name='lahf_lm'/gt; +lt;/cpugt; + lt;devicesgt; NACK, it is just madness to duplicate the CPU info we already have in a different place in the XML. Yes, it's duplicate. But I think it represents different meaning, it is under xml tag 'device'. Regards, Zhu Regards, Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] fsfreeze and fsthaw API testing
Sorry, this is for libvirt-test-API. I should add it to title next time. - Original Message - Added guest agent conf to domain xml in order to test API fsfreeze and fsthaw. Jincheng Miao (3): add guest agent configuration to domain xml Add domain fsfreeze and fsthaw API testing Add fsfreeze fsthaw test case to linux_domain cases/linux_domain.conf| 18 + repos/domain/domain_fsfreeze.py| 76 repos/domain/domain_fsthaw.py | 49 + .../domain/xmls/kvm_linux_guest_install_cdrom.xml |4 + repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 +++-- 5 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 03/12] domain_conf: introduce cpu device hotplug helpers
virDomainCPUFind - to find a cpu within VM def virDomainCPUInsert - wrapper for inserting a new cpu device into VM def virDomainCPURemove - wrapper for removing cpu from VM def Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/conf/domain_conf.c | 58 src/conf/domain_conf.h | 13 +++ src/libvirt_private.syms | 3 +++ 3 files changed, 74 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dfe0d65..f83eada 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12128,6 +12128,64 @@ virDomainChrRemove(virDomainDefPtr vmdef, return ret; } +int +virDomainCPUInsert(virDomainDefPtr vmdef, + virDomainCPUDefPtr cpu) +{ +return VIR_APPEND_ELEMENT(vmdef-cpus, vmdef-ncpus, cpu); +} + +bool +virDomainCPUEquals(virDomainCPUDefPtr src, + virDomainCPUDefPtr tgt) +{ +bool ret = false; + +if (!src || !tgt) +return src == tgt; + +ret = virCPUDefIsEqual(src-virCPU, tgt-virCPU); + +return ret; +} + +virDomainCPUDefPtr +virDomainCPUFind(virDomainDefPtr def, + virDomainCPUDefPtr target) +{ +virDomainCPUDefPtr cpu; +size_t i; + +for (i = 0; i def-ncpus; i++) { +cpu = def-cpus[i]; +if (virDomainCPUEquals(cpu, target)) +return cpu; +} + +return NULL; +} + +virDomainCPUDefPtr +virDomainCPURemove(virDomainDefPtr vmdef, + virDomainCPUDefPtr cpu) +{ +virDomainCPUDefPtr ret; +size_t i; + +for (i = 0; i vmdef-ncpus; i++) { +ret = vmdef-cpus[i]; + +if (virDomainCPUEquals(ret, cpu)) +break; +} + +if (i == vmdef-ncpus) +return NULL; + +VIR_DELETE_ELEMENT(vmdef-cpus, i, vmdef-ncpus); +return ret; +} + char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4096ecc..144f79a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2674,6 +2674,19 @@ virDomainChrDefPtr virDomainChrRemove(virDomainDefPtr vmdef, virDomainChrDefPtr chr); +int +virDomainCPUInsert(virDomainDefPtr vmdef, + virDomainCPUDefPtr cpu); +bool +virDomainCPUEquals(virDomainCPUDefPtr src, + virDomainCPUDefPtr tgt); +virDomainCPUDefPtr +virDomainCPUFind(virDomainDefPtr def, + virDomainCPUDefPtr cpu); +virDomainCPUDefPtr +virDomainCPURemove(virDomainDefPtr vmdef, + virDomainCPUDefPtr cpu); + int virDomainSaveXML(const char *configDir, virDomainDefPtr def, const char *xml); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 897a598..df4f508 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -182,8 +182,11 @@ virDomainControllerModelUSBTypeToString; virDomainControllerRemove; virDomainControllerTypeToString; virDomainCPUDefFree; +virDomainCPUFind; +virDomainCPUInsert; virDomainCpuPlacementModeTypeFromString; virDomainCpuPlacementModeTypeToString; +virDomainCPURemove; virDomainDefAddImplicitControllers; virDomainDefCheckABIStability; virDomainDefClearCCWAddresses; -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] Add fsfreeze fsthaw test case to linux_domain
Signed-off-by: Jincheng Miao jm...@redhat.com --- cases/linux_domain.conf | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf index 515858a..37d 100644 --- a/cases/linux_domain.conf +++ b/cases/linux_domain.conf @@ -139,6 +139,24 @@ domain:cpu_affinity vcpu $defaultvcpu +domain:domain_fsfreeze +guestname +$defaultname + +domain:domain_fsthaw +guestname +$defaultname + +domain:domain_fsfreeze +guestname +$defaultname +mountpoint +/ + +domain:domain_fsthaw +guestname +$defaultname + domain:destroy guestname $defaultname -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] Add domain fsfreeze and fsthaw API testing
Signed-off-by: Jincheng Miao jm...@redhat.com --- repos/domain/domain_fsfreeze.py | 76 +++ repos/domain/domain_fsthaw.py | 49 + 2 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py diff --git a/repos/domain/domain_fsfreeze.py b/repos/domain/domain_fsfreeze.py new file mode 100644 index 000..f91cd46 --- /dev/null +++ b/repos/domain/domain_fsfreeze.py @@ -0,0 +1,76 @@ +#!/usr/bin/evn python +# To test domain fsfreeze + +import time +import libvirt +from libvirt import libvirtError + +from src import sharedmod + +required_params = ('guestname',) +optional_params = {'mountpoint': ''} + + +def check_frozen_num(mp, num): +check the number of frozen fs +if mp == None: +return True + +if len(mp) == num: +return True +else: +return False + + +def parse_mountpoint(mp): +parse the argument mountpoint +if mp == None: +return None + +return [p.strip() for p in mp.split(',')] + + +def check_guest_status(domobj): +Check guest current status +state = domobj.info()[0] +if state == libvirt.VIR_DOMAIN_SHUTOFF or \ +state == libvirt.VIR_DOMAIN_SHUTDOWN: +# add check function +return False +else: +return True + + +def domain_fsfreeze(params): +domain fsfreeze test function +logger = params['logger'] +guestname = params['guestname'] +mountpoint = parse_mountpoint(params.get('mountpoint')) + +conn = sharedmod.libvirtobj['conn'] + +domobj = conn.lookupByName(guestname) + +# Check domain block status +if check_guest_status(domobj): +pass +else: +domobj.create() +time.sleep(90) + +try: +num = domobj.fsFreeze(mountpoint, 0) +logger.info(freeze %s fs % num) + +if check_frozen_num(mountpoint, num): +logger.info(Check frozen fs num: pass) +else: +logger.error(Check frozen fs num: failed) +return 1 + +except libvirtError, e: +logger.error(API error message: %s, error code is %s + % (e.message, e.get_error_code())) +return 1 + +return 0 diff --git a/repos/domain/domain_fsthaw.py b/repos/domain/domain_fsthaw.py new file mode 100644 index 000..cebbe22 --- /dev/null +++ b/repos/domain/domain_fsthaw.py @@ -0,0 +1,49 @@ +#!/usr/bin/evn python +# To test domain fsthaw + +import time +import libvirt +from libvirt import libvirtError + +from src import sharedmod + +required_params = ('guestname',) +optional_params = {} + + +def check_guest_status(domobj): +Check guest current status +state = domobj.info()[0] +if state == libvirt.VIR_DOMAIN_SHUTOFF or \ +state == libvirt.VIR_DOMAIN_SHUTDOWN: +# add check function +return False +else: +return True + + +def domain_fsthaw(params): +domain fsthaw test function +logger = params['logger'] +guestname = params['guestname'] + +conn = sharedmod.libvirtobj['conn'] + +domobj = conn.lookupByName(guestname) + +# Check domain block status +if check_guest_status(domobj): +pass +else: +domobj.create() +time.sleep(90) + +try: +num = domobj.fsThaw() +logger.info(fsThaw %s fs % num) +except libvirtError, e: +logger.error(API error message: %s, error code is %s + % (e.message, e.get_error_code())) +return 1 + +return 0 -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH v2 02/12] domain_conf: introduce cpu def helpers
On Wed, Feb 04, 2015 at 05:42:42PM +0800, Zhu Guihua wrote: On Wed, 2015-02-04 at 09:25 +, Daniel P. Berrange wrote: On Wed, Feb 04, 2015 at 05:18:20PM +0800, Zhu Guihua wrote: virDomainCPUDefFree - free memory allocated virDomainCPUDefParseXML - parse job type virDomainCPUDefFormat - output job type Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- docs/formatdomain.html.in | 28 +++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c| 82 +++ src/conf/domain_conf.h| 1 + src/libvirt_private.syms | 1 + 5 files changed, 115 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f8d5f89..10cbd29 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5830,6 +5830,34 @@ qemu-kvm -net nic,model=? /dev/null /dd /dl + h4a name=elementsCpuCPU device/a/h4 + p +CPU device allows to be hot added to the guest. +span class=sinceSince 1.2.12, QEMU and KVM only/span + /p + +pre + ... + lt;devicesgt; +lt;cpu match='exact'gt; + lt;model fallback='allow'gt;core2duolt;/modelgt; + lt;vendorgt;Intellt;/vendorgt; + lt;topology sockets='1' cores='2' threads='1'/gt; + lt;feature policy='disable' name='lahf_lm'/gt; +lt;/cpugt; + lt;devicesgt; NACK, it is just madness to duplicate the CPU info we already have in a different place in the XML. Yes, it's duplicate. But I think it represents different meaning, it is under xml tag 'device'. Regardless my NACK stands. This kind of duplication is just madness that causes problems for applications developers alike. 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 1/3] add guest agent configuration to domain xml
hi Jmiao Don't forget to add [libvirt][libvirt-test-API] to your patch summary. Thanks Hongming On 02/04/2015 05:26 PM, Jincheng Miao wrote: Signed-off-by: Jincheng Miao jm...@redhat.com --- .../domain/xmls/kvm_linux_guest_install_cdrom.xml |4 repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml index cb59e76..8f398bb 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml @@ -35,5 +35,9 @@ console/ input bus=ps2 type=mouse/ graphics keymap=en-us port=-1 type=vnc/ +channel type='unix' + source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/ + target type='virtio' name='org.qemu.guest_agent.0'/ +/channel /devices /domain diff --git a/repos/domain/xmls/kvm_linux_guest_install_net.xml b/repos/domain/xmls/kvm_linux_guest_install_net.xml index c4a7de7..5fad3a7 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_net.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_net.xml @@ -24,13 +24,17 @@ source file='DISKPATH'/ target bus='HDDRIVER' dev='DEV'/ /disk - interface type=network -source network=default/ -mac address='MACADDR'/ -model type='NICDRIVER'/ - /interface - console/ - input bus=ps2 type=mouse/ - graphics keymap=en-us port=-1 type=vnc/ +interface type=network + source network=default/ + mac address='MACADDR'/ + model type='NICDRIVER'/ +/interface +console/ +input bus=ps2 type=mouse/ +graphics keymap=en-us port=-1 type=vnc/ +channel type='unix' + source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/ + target type='virtio' name='org.qemu.guest_agent.0'/ +/channel /devices /domain -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 00/12] qemu: add support to hot-plug/unplug cpu device
If you apply the folowing patchset in order [PATCH v3 0/7] cpu: add device_add foo-x86_64-cpu support https://lists.nongnu.org/archive/html/qemu-devel/2015-01/msg01552.html, [PATCH v2 0/5] Common unplug and unplug request cb for memory and CPU hot-unplug https://lists.nongnu.org/archive/html/qemu-devel/2015-01/msg03929.html and [PATCH v2 00/11] cpu: add i386 cpu hot remove support https://lists.nongnu.org/archive/html/qemu-devel/2015-01/msg01557.html, qemu can support hotplug and hot-unplug cpu device. So this patch series will make libvirt support hotplug and hot-unplug cpu device for qemu driver. This patch series add a new API to support cpu hot-plug/unplug, and leave the existing API by invoking qemu command 'cpu-add' as a legacy. This patch series realize cpu hot-plug/unplug by libvirt command 'attach-device' and 'detach-device', and invoke qemu command 'device_add' and 'device_del' to support this feature. v2: - update cpu device's definition, and cpu's apic_id is hidded to users. - add check for compatibility between host cpu and hot added cpu - add a capability for *-x86_64-cpu Zhu Guihua (12): domain_conf: add support for cpu device configuration in XML domain_conf: introduce cpu def helpers domain_conf: introduce cpu device hotplug helpers qemu_driver: implement cpu device hotplug on config level qemu_command: introduce a func for cpu device alias assignment domain_conf: allocate cpu's apic id dynamically qemu: add a capability for x86_64-cpu qemu: introduce qemuBuildCPUDeviceStr qemu: implement cpu device hotplug on live level qemu: implement cpu device hotunplug on live level qemu_monitor_json: sort JSON array of cpu info qemu_driver: detect threads corresponding to Vcpus docs/formatdomain.html.in | 28 docs/schemas/domaincommon.rng | 3 + src/conf/domain_conf.c| 189 +- src/conf/domain_conf.h| 33 + src/libvirt_private.syms | 6 + src/qemu/qemu_capabilities.c | 3 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 120 + src/qemu/qemu_command.h | 10 ++ src/qemu/qemu_driver.c| 299 -- src/qemu/qemu_driver.h| 8 ++ src/qemu/qemu_hotplug.c | 140 src/qemu/qemu_hotplug.h | 12 ++ src/qemu/qemu_monitor_json.c | 31 - src/util/virbitmap.c | 2 +- src/util/virbitmap.h | 2 + 16 files changed, 753 insertions(+), 134 deletions(-) -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 11/12] qemu_monitor_json: sort JSON array of cpu info
JSON array of cpu info is sorted in order to find thread id of cpu smoothly. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_monitor_json.c | 31 +-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index da5c14d..96a964c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1162,6 +1162,21 @@ int qemuMonitorJSONSystemReset(qemuMonitorPtr mon) return ret; } +static int +qemuCPUInfoCompare(const void *a, + const void *b) +{ +virJSONValuePtr *entrya = (virJSONValuePtr *)a; +virJSONValuePtr *entryb = (virJSONValuePtr *)b; +int ia; +int ib; + +virJSONValueObjectGetNumberInt(*entrya, CPU, ia); +virJSONValueObjectGetNumberInt(*entryb, CPU, ib); + +return ia - ib; +} + /* * [ { CPU: 0, current: true, halted: false, pc: 3227107138 }, @@ -1176,6 +1191,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, size_t i; int *threads = NULL; int ncpus; +virJSONValuePtr *entryarray = NULL; if (!(data = virJSONValueObjectGet(reply, return))) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, @@ -1198,16 +1214,26 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, if (VIR_ALLOC_N(threads, ncpus) 0) goto cleanup; +if (VIR_ALLOC_N(entryarray, ncpus) 0) +goto cleanup; + for (i = 0; i ncpus; i++) { virJSONValuePtr entry = virJSONValueArrayGet(data, i); -int thread; if (!entry) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(cpu information was missing an array element)); goto cleanup; } -if (virJSONValueObjectGetNumberInt(entry, thread_id, thread) 0) { +entryarray[i] = entry; +} + +qsort(entryarray, ncpus, sizeof(entryarray[0]), qemuCPUInfoCompare); + +for (i = 0; i ncpus; i++) { +int thread; +if (virJSONValueObjectGetNumberInt(entryarray[i], thread_id, thread) 0) { + /* Some older qemu versions don't report the thread_id, * so treat this as non-fatal, simply returning no data */ ret = 0; @@ -1223,6 +1249,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, cleanup: VIR_FREE(threads); +VIR_FREE(entryarray); return ret; } -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] Prevent removing a in-used static bridge and destroying a in-used virtual network
On Wed, Feb 04, 2015 at 02:21:18AM -0500, Laine Stump wrote: On 02/03/2015 11:47 AM, Michal Privoznik wrote: On 02.02.2015 15:08, Lin Ma wrote: * Get the live state info of a virtual network through netcf in networkGetXMLDesc. * Add --system flag for net-dumpxml to show the live state info. * Check the live state info in net-destroy. * Add --force flag for net-destroy to forcibly destroy the virtual network. * Check the transient interfaces info in iface-unbridge. --- Lin Ma (3): bridge_driver: Return the live state info of a given virtual network virsh: prevent destroying a in-used network for net-destroy virsh: prevent removing a in-used bridge for iface-unbridge include/libvirt/libvirt-network.h| 1 + src/Makefile.am | 3 + src/network/bridge_driver.c | 141 ++- src/network/bridge_driver_platform.h | 7 ++ tests/Makefile.am| 4 + tools/virsh-interface.c | 25 ++- tools/virsh-network.c| 62 ++- tools/virsh.pod | 8 +- 8 files changed, 241 insertions(+), 10 deletions(-) So I've spent some time thinking about this. I don't really like the idea of producing completely different XML (it doesn't even have network/ as its root element!). But I see what you're trying to achieve. How about putting the bridged interfaces into the network definition (on request signalized by a flag, of course). I think that if we're going to add the list of connected guest devices to a network's status, that it should just always be there - adding a new flag for every little bit of different status sets a bad precedent and sets us up to have an infinitely increasing number of flags. Like I mentioned in my response to one of the patches, I think this information is better gathered and maintained by the bridge driver as guests connect to / disconnect from a network; this avoids the necessity of dragging netcf into the picture and allows much better information - the name of the domain using each interface can be included. I think we should consider whether we should expose it as an explicit API too, rather than just stuffing it into the XML as a way to avoid the work of defining an API. The XML is generally describing the configuration of the virtual network. This isn't really configuration information, but rather a reporting about usage of the network, so it isn't a clearly compelling thing to put in the XML. I think we've come to a point where we need to introduce live and config XML (like we have for domains). We already have that to some extent, but not truly. I think the situation is more that we have live and config XML, but there may be a small problem here and there. As a matter of fact, a long time ago virsh wasn't using the live XML to edit a network, and this was causing problems (e.g. if you tried to edit a network twice without restarting it, the second time you would lose all the changes from the first edit). 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] [PATCH 0/3] fsfreeze and fsthaw API testing
Added guest agent conf to domain xml in order to test API fsfreeze and fsthaw. Jincheng Miao (3): add guest agent configuration to domain xml Add domain fsfreeze and fsthaw API testing Add fsfreeze fsthaw test case to linux_domain cases/linux_domain.conf| 18 + repos/domain/domain_fsfreeze.py| 76 repos/domain/domain_fsthaw.py | 49 + .../domain/xmls/kvm_linux_guest_install_cdrom.xml |4 + repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 +++-- 5 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: fix forget goto error when report a unsupport error
On 02/04/2015 03:29 PM, Peter Krempa wrote: On Wed, Feb 04, 2015 at 10:33:29 +0800, Luyao Huang wrote: https://bugzilla.redhat.com/show_bug.cgi?id=1188914 This will cause a issue that add a unsupport input device to a hypervisor which unsupport it, also will cause a wrong error message when the input device is not a mouse or keyboard. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/conf/domain_conf.c | 1 + 1 file changed, 1 insertion(+) ACK. Pushed with fixed commit message. Thanks a lot for review and message fixed. Also thanks for review another patch just like this :) Peter Luyao -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-test-API][PATCH 1/2] Give a default value on br variable in mac_to_ip
Set 'virbr0' as defult value --- utils/utils.py | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/utils.py b/utils/utils.py index f841c27..c3e46f6 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -349,17 +349,14 @@ def locate_utils(): result = re.search('(.*)libvirt-test-API(.*)', pwd) return result.group(0) + /utils -def mac_to_ip(mac,br,timeout): -Map mac address to ip +def mac_to_ip(mac, timeout, br = 'virbr0'): +Map mac address to ip under a specified brige Return None on FAILURE and the mac address on SUCCESS if not mac: return None -if not br: -return None - if timeout 10: timeout = 10 -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-test-API][PATCH 0/2] Fix some regression issues
Some issues were introduced by 137211d15 and efac4a3ec commits, fix them. jiahu (2): Give a default value on br variable in mac_to_ip Fix regression issues repos/domain/destroy.py | 4 ++-- repos/domain/install_linux_cdrom.py | 4 ++-- utils/utils.py | 7 ++- 3 files changed, 6 insertions(+), 9 deletions(-) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2] Trivially support DomainHasManagedSaveImage
Return 0 instead of ERR_NO_SUPPORT in each driver where we don't support managed save. This avoids spamming daemon logs when 'virsh dominfo' is run. https://bugzilla.redhat.com/show_bug.cgi?id=1095637 --- src/bhyve/bhyve_driver.c | 25 - src/esx/esx_driver.c | 11 ++- src/lxc/lxc_driver.c | 26 +- src/openvz/openvz_driver.c | 12 +++- src/parallels/parallels_driver.c | 11 ++- src/phyp/phyp_driver.c | 11 ++- src/uml/uml_driver.c | 33 - src/vbox/vbox_common.c | 11 ++- src/vmware/vmware_driver.c | 11 ++- src/xenapi/xenapi_driver.c | 11 ++- 10 files changed, 152 insertions(+), 10 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 56cc8ab..ae39917 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -2,7 +2,7 @@ * bhyve_driver.c: core driver methods for managing bhyve guests * * Copyright (C) 2014 Roman Bogorodskiy - * Copyright (C) 2014 Red Hat, Inc. + * Copyright (C) 2014-2015 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1430,6 +1430,28 @@ bhyveConnectDomainEventDeregisterAny(virConnectPtr conn, return 0; } +static int +bhyveDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags) +{ +virDomainObjPtr vm = NULL; +int ret = -1; + +virCheckFlags(0, -1); + +if (!(vm = bhyveDomObjFromDomain(domain))) +goto cleanup; + +if (virDomainHasManagedSaveImageEnsureACL(domain-conn, vm-def) 0) +goto cleanup; + +ret = 0; + + cleanup: +if (vm) +virObjectUnlock(vm); +return ret; +} + static virHypervisorDriver bhyveHypervisorDriver = { .name = bhyve, .connectOpen = bhyveConnectOpen, /* 1.2.2 */ @@ -1476,6 +1498,7 @@ static virHypervisorDriver bhyveHypervisorDriver = { .connectCompareCPU = bhyveConnectCompareCPU, /* 1.2.4 */ .connectDomainEventRegisterAny = bhyveConnectDomainEventRegisterAny, /* 1.2.5 */ .connectDomainEventDeregisterAny = bhyveConnectDomainEventDeregisterAny, /* 1.2.5 */ +.domainHasManagedSaveImage = bhyveDomainHasManagedSaveImage, /* 1.2.13 */ }; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 6b9965f..53d31e3 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1,7 +1,7 @@ /* * esx_driver.c: core driver functions for managing VMware ESX hosts * - * Copyright (C) 2010-2014 Red Hat, Inc. + * Copyright (C) 2010-2015 Red Hat, Inc. * Copyright (C) 2009-2014 Matthias Bolte matthias.bo...@googlemail.com * Copyright (C) 2009 Maximilian Wilhelm m...@rfc2324.org * @@ -5147,6 +5147,14 @@ esxConnectListAllDomains(virConnectPtr conn, } #undef MATCH +static int +esxDomainHasManagedSaveImage(virDomainPtr dom ATTRIBUTE_UNUSED, unsigned int flags) +{ +virCheckFlags(0, -1); + +return 0; +} + static virHypervisorDriver esxHypervisorDriver = { .name = ESX, @@ -5226,6 +5234,7 @@ static virHypervisorDriver esxHypervisorDriver = { .domainSnapshotHasMetadata = esxDomainSnapshotHasMetadata, /* 0.9.13 */ .domainSnapshotDelete = esxDomainSnapshotDelete, /* 0.8.0 */ .connectIsAlive = esxConnectIsAlive, /* 0.9.8 */ +.domainHasManagedSaveImage = esxDomainHasManagedSaveImage, /* 1.2.13 */ }; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 487e2a2..3adb21d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014 Red Hat, Inc. + * Copyright (C) 2010-2015 Red Hat, Inc. * Copyright IBM Corp. 2008 * * lxc_driver.c: linux container driver functions @@ -5726,6 +5726,29 @@ lxcNodeAllocPages(virConnectPtr conn, } +static int +lxcDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) +{ +virDomainObjPtr vm = NULL; +int ret = -1; + +virCheckFlags(0, -1); + +if (!(vm = lxcDomObjFromDomain(dom))) +return ret; + +if (virDomainHasManagedSaveImageEnsureACL(dom-conn, vm-def) 0) +goto cleanup; + +ret = 0; + + cleanup: +if (vm) +virObjectUnlock(vm); +return ret; +} + + /* Function Tables */ static virHypervisorDriver lxcHypervisorDriver = { .name = LXC_DRIVER_NAME, @@ -5818,6 +5841,7 @@ static virHypervisorDriver lxcHypervisorDriver = { .domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */ .nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */ .nodeAllocPages = lxcNodeAllocPages, /* 1.2.9 */ +.domainHasManagedSaveImage = lxcDomainHasManagedSaveImage, /* 1.2.13 */ }; static virConnectDriver lxcConnectDriver = { diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 556f626..4ce5a41 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1,7 +1,7 @@ /* *
[libvirt] [PATCH] lxc: fix double close handshakefds[1]
Signed-off-by: Luyao Huang lhu...@redhat.com --- src/lxc/lxc_process.c | 5 - 1 file changed, 5 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 01da344..b385423 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1270,11 +1270,6 @@ int virLXCProcessStart(virConnectPtr conn, goto error; } -if (VIR_CLOSE(handshakefds[1]) 0) { -virReportSystemError(errno, %s, _(could not close handshake fd)); -goto error; -} - if (virCommandHandshakeWait(cmd) 0) goto error; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Bugfix for building with no-git-option
If you will build libvirt with the no-git-option than you is the gnulib-srcdir mandatory. You will lose this information till now. With this patch you will save this inforamtion. Signed-off-by: Stefan Zimmermann s...@linux.vnet.ibm.com --- autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index 1965f64..0168d24 100755 --- a/autogen.sh +++ b/autogen.sh @@ -18,8 +18,8 @@ test -f src/libvirt.c || { EXTRA_ARGS= no_git= if test x$1 = x--no-git; then - no_git= $1 - shift + no_git= $1 $2 + shift 2 fi if test -z $NOCONFIGURE ; then if test x$1 = x--system; then -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3] lxc: fix show the wrong xml when guest start failed
https://bugzilla.redhat.com/show_bug.cgi?id=1176503 When guest start failed, libvirt will keep the current vm-def, this will make a issue that we cannot get a right xml after guest start failed. And don't call the stop/release hook to do some other clean work. Call virLXCProcessCleanup to help us clean the source and call the hooks if start a vm failed Signed-off-by: Luyao Huang lhu...@redhat.com --- v2: use virLXCProcessCleanup to free the source and call the hook. v3: rework the patch to suit the virLXCProcessStart code changed. src/lxc/lxc_process.c | 76 ++- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 01da344..1a6cfbb 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1022,6 +1022,7 @@ int virLXCProcessStart(virConnectPtr conn, virCgroupPtr selfcgroup; int status; char *pidfile = NULL; +bool need_stop = false; if (virCgroupNewSelf(selfcgroup) 0) return -1; @@ -1259,6 +1260,7 @@ int virLXCProcessStart(virConnectPtr conn, goto cleanup; } +need_stop = true; priv-stopReason = VIR_DOMAIN_EVENT_STOPPED_FAILED; priv-wantReboot = false; vm-def-id = vm-pid; @@ -1272,20 +1274,20 @@ int virLXCProcessStart(virConnectPtr conn, if (VIR_CLOSE(handshakefds[1]) 0) { virReportSystemError(errno, %s, _(could not close handshake fd)); -goto error; +goto cleanup; } if (virCommandHandshakeWait(cmd) 0) -goto error; +goto cleanup; /* Write domain status to disk for the controller to * read when it starts */ if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm) 0) -goto error; +goto cleanup; /* Allow the child to exec the controller */ if (virCommandHandshakeNotify(cmd) 0) -goto error; +goto cleanup; if (virAtomicIntInc(driver-nactive) == 1 driver-inhibitCallback) driver-inhibitCallback(true, driver-inhibitOpaque); @@ -1298,7 +1300,7 @@ int virLXCProcessStart(virConnectPtr conn, _(guest failed to start: %s), out); } -goto error; +goto cleanup; } /* We know the cgroup must exist by this synchronization @@ -1310,13 +1312,13 @@ int virLXCProcessStart(virConnectPtr conn, vm-def-resource-partition : NULL, -1, priv-cgroup) 0) -goto error; +goto cleanup; if (!priv-cgroup) { virReportError(VIR_ERR_INTERNAL_ERROR, _(No valid cgroup for machine %s), vm-def-name); -goto error; +goto cleanup; } /* And we can get the first monitor connection now too */ @@ -1329,17 +1331,17 @@ int virLXCProcessStart(virConnectPtr conn, virReportError(VIR_ERR_INTERNAL_ERROR, _(guest failed to start: %s), ebuf); } -goto error; +goto cleanup; } if (autoDestroy virCloseCallbacksSet(driver-closeCallbacks, vm, conn, lxcProcessAutoDestroy) 0) -goto error; +goto cleanup; if (virDomainObjSetDefTransient(caps, driver-xmlopt, vm, false) 0) -goto error; +goto cleanup; /* We don't need the temporary NIC names anymore, clear them */ virLXCProcessCleanInterfaces(vm-def); @@ -1358,47 +1360,38 @@ int virLXCProcessStart(virConnectPtr conn, * If the script raised an error abort the launch */ if (hookret 0) -goto error; +goto cleanup; } rc = 0; cleanup: -if (rc != 0 !err) -err = virSaveLastError(); -virCommandFree(cmd); if (VIR_CLOSE(logfd) 0) { virReportSystemError(errno, %s, _(could not close logfile)); rc = -1; } -for (i = 0; i nveths; i++) { -if (rc != 0 veths[i]) -ignore_value(virNetDevVethDelete(veths[i])); -VIR_FREE(veths[i]); -} if (rc != 0) { -if (vm-newDef) { -virDomainDefFree(vm-newDef); -vm-newDef = NULL; -} -if (priv-monitor) { -virObjectUnref(priv-monitor); -priv-monitor = NULL; -} -virDomainConfVMNWFilterTeardown(vm); - -virSecurityManagerRestoreAllLabel(driver-securityManager, - vm-def, false); -virSecurityManagerReleaseLabel(driver-securityManager, vm-def); -/* Clear out dynamically assigned labels */ -if (vm-def-nseclabels -vm-def-seclabels[0]-type == VIR_DOMAIN_SECLABEL_DYNAMIC) { -VIR_FREE(vm-def-seclabels[0]-model); -VIR_FREE(vm-def-seclabels[0]-label); -
[libvirt] [PATCH 1/2] S390: ccw support for virsh attach-disk address parameter
Adding ccw bus address support to the optional address parameter of virsh attach-disk. The format used is ccw:cssid. ssid.devno, e.g. ccw:0xfe.0x0.0x0201 Virtio-ccw devices must have their cssid set to 0xfe. Signed-off-by: Stefan Zimmermann s...@linux.vnet.ibm.com Reviewed-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com Reviewed-by: Cornelia Huck cornelia.h...@de.ibm.com --- tools/virsh-domain.c | 46 +- tools/virsh.pod | 3 ++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bab44fe..358d61c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -404,6 +404,7 @@ enum { DISK_ADDR_TYPE_PCI, DISK_ADDR_TYPE_SCSI, DISK_ADDR_TYPE_IDE, +DISK_ADDR_TYPE_CCW, }; struct PCIAddress { @@ -425,12 +426,19 @@ struct IDEAddress { unsigned int unit; }; +struct CCWAddress { +unsigned int cssid; +unsigned int ssid; +unsigned int devno; +}; + struct DiskAddress { int type; union { struct PCIAddress pci; struct SCSIAddress scsi; struct IDEAddress ide; +struct CCWAddress ccw; } addr; }; @@ -513,9 +521,35 @@ static int str2IDEAddress(const char *str, struct IDEAddress *ideAddr) return 0; } +static int str2CCWAddress(const char *str, struct CCWAddress *ccwAddr) +{ +char *cssid, *ssid, *devno; + +if (!ccwAddr) +return -1; +if (!str) +return -1; + +cssid = (char *)str; + +if (virStrToLong_ui(cssid, ssid, 0, ccwAddr-cssid) != 0) +return -1; + +ssid++; +if (virStrToLong_ui(ssid, devno, 0, ccwAddr-ssid) != 0) +return -1; + +devno++; +if (virStrToLong_ui(devno, NULL, 0, ccwAddr-devno) != 0) +return -1; + +return 0; +} + /* pci address pci:.00.0x0a.0 (domain:bus:slot:function) * ide disk address: ide:00.00.0 (controller:bus:unit) * scsi disk address: scsi:00.00.0 (controller:bus:unit) + * ccw disk address: ccw:0xfe.0. (cssid:ssid:devno) */ static int str2DiskAddress(const char *str, struct DiskAddress *diskAddr) @@ -541,6 +575,9 @@ static int str2DiskAddress(const char *str, struct DiskAddress *diskAddr) } else if (STREQLEN(type, ide, addr - type)) { diskAddr-type = DISK_ADDR_TYPE_IDE; return str2IDEAddress(addr + 1, diskAddr-addr.ide); +} else if (STREQLEN(type, ccw, addr - type)) { +diskAddr-type = DISK_ADDR_TYPE_CCW; +return str2CCWAddress(addr + 1, diskAddr-addr.ccw); } return -1; @@ -675,8 +712,15 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, multifunction)) virBufferAddLit(buf, multifunction='on'); virBufferAddLit(buf, /\n); +} else if (diskAddr.type == DISK_ADDR_TYPE_CCW) { +virBufferAsprintf(buf, + address type='ccw' cssid='0x%02x' + ssid='0x%01x' devno='0x%04x' /\n, + diskAddr.addr.ccw.cssid, diskAddr.addr.ccw.ssid, + diskAddr.addr.ccw.devno); } else { -vshError(ctl, %s, _(expecting a pci:.00.00.00 address.)); +vshError(ctl, %s, + _(expecting a pci:.00.00.00 or ccw:00.0. address.)); goto cleanup; } } else if (STRPREFIX((const char *)target, sd)) { diff --git a/tools/virsh.pod b/tools/virsh.pod index e367e04..a3f527f 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2367,7 +2367,8 @@ this disk may be attached (QEMU only). Iserial is the serial of disk device. Iwwn is the wwn of disk device. Irawio indicates the disk needs rawio capability. Iaddress is the address of disk device in the form of pci:domain.bus.slot.function, -scsi:controller.bus.unit or ide:controller.bus.unit. +scsi:controller.bus.unit, ide:controller.bus.unit or ccw:cssid.ssid.devno. +Virtio-ccw devices must have their cssid set to 0xfe. Imultifunction indicates specified pci address is a multifunction pci device address. -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] cpu: add Freescale ppc64 CPU models
On Fri, Jan 30, 2015 at 02:50:03PM +0800, Olivia Yin wrote: From: Olivia Yin hong-hua@freescale.com With this patch, Freescale ppc64 CPU modesl could be recognized. virsh # cpu-models ppc64 POWERPC_e6500 POWERPC_e5500 power8 power8e power7+ power7 power6 POWER8_v1.0 POWER7+_v2.1 POWER7_v2.3 POWER7_v2.1 POWER7 virsh # capabilities capabilities host uuid5a54efa6-20dc-4da7-b271-0b7fb7062cb8/uuid cpu archppc64/arch modelPOWERPC_e6500/model vendorFreescale/vendor --- src/cpu/cpu_map.xml | 12 1 file changed, 12 insertions(+) Sorry for not replying earlier. I tried checking the PVR values with no luck, unfortunately. However, I see nothing this could break (famous last words?), so ACK and I'm pushing it in a while. pgpoEVlxZBxvY.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] lxc: fix double close handshakefds[1]
On Wed, Feb 04, 2015 at 09:32:52PM +0800, Luyao Huang wrote: Signed-off-by: Luyao Huang lhu...@redhat.com --- src/lxc/lxc_process.c | 5 - 1 file changed, 5 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 01da344..b385423 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1270,11 +1270,6 @@ int virLXCProcessStart(virConnectPtr conn, goto error; } -if (VIR_CLOSE(handshakefds[1]) 0) { -virReportSystemError(errno, %s, _(could not close handshake fd)); -goto error; -} - if (virCommandHandshakeWait(cmd) 0) goto error; ACK, looks like a git merge error 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 0/3] Prevent removing a in-used static bridge and destroying a in-used virtual network
On Wed, Feb 04, 2015 at 02:21:18AM -0500, Laine Stump wrote: On 02/03/2015 11:47 AM, Michal Privoznik wrote: On 02.02.2015 15:08, Lin Ma wrote: * Get the live state info of a virtual network through netcf in networkGetXMLDesc. * Add --system flag for net-dumpxml to show the live state info. * Check the live state info in net-destroy. * Add --force flag for net-destroy to forcibly destroy the virtual network. * Check the transient interfaces info in iface-unbridge. --- Lin Ma (3): bridge_driver: Return the live state info of a given virtual network virsh: prevent destroying a in-used network for net-destroy virsh: prevent removing a in-used bridge for iface-unbridge include/libvirt/libvirt-network.h| 1 + src/Makefile.am | 3 + src/network/bridge_driver.c | 141 ++- src/network/bridge_driver_platform.h | 7 ++ tests/Makefile.am| 4 + tools/virsh-interface.c | 25 ++- tools/virsh-network.c| 62 ++- tools/virsh.pod | 8 +- 8 files changed, 241 insertions(+), 10 deletions(-) So I've spent some time thinking about this. I don't really like the idea of producing completely different XML (it doesn't even have network/ as its root element!). But I see what you're trying to achieve. How about putting the bridged interfaces into the network definition (on request signalized by a flag, of course). I think that if we're going to add the list of connected guest devices to a network's status, that it should just always be there - adding a new flag for every little bit of different status sets a bad precedent and sets us up to have an infinitely increasing number of flags. Like I mentioned in my response to one of the patches, I think this information is better gathered and maintained by the bridge driver as guests connect to / disconnect from a network; this avoids the necessity of dragging netcf into the picture and allows much better information - the name of the domain using each interface can be included. You know if this checking for guests were done in the virNetworkDestroy API implementation in src/network/bridge_driver.c, instead of in virsh, then we would not need any of this code for extending the XML nor parsing it in virsh. We could simply check the number of connections which is something we have directly available internally. So 95% of this patch series would go away 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] [RFC PATCH v2 04/12] qemu_driver: implement cpu device hotplug on config level
The config level requires an insert or remove from domain definition structure. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_driver.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31c7655..4ec3b3c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7326,6 +7326,11 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, break; case VIR_DOMAIN_DEVICE_CPU: +if (virDomainCPUInsert(vmdef, dev-data.cpu) 0) +return -1; +dev-data.cpu = NULL; +break; + case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: @@ -7362,6 +7367,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainControllerDefPtr cont, det_cont; virDomainChrDefPtr chr; virDomainFSDefPtr fs; +virDomainCPUDefPtr cpu; int idx; switch ((virDomainDeviceType) dev-type) { @@ -7443,6 +7449,14 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, break; case VIR_DOMAIN_DEVICE_CPU: +if (!(cpu = virDomainCPURemove(vmdef, dev-data.cpu))) +return -1; + +virDomainCPUDefFree(cpu); +virDomainCPUDefFree(dev-data.cpu); +dev-data.cpu = NULL; +break; + case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 07/12] qemu: add a capability for x86_64-cpu
This patch adds a new capability bit QEMU_CAPS_DEVICE_X86_64_CPU. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 13f3cd3..1f6facd 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -277,6 +277,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, vmware-svga.vgamem_mb, qxl.vgamem_mb, qxl-vga.vgamem_mb, + x86_64_cpu, ); @@ -1524,6 +1525,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { usb-audio, QEMU_CAPS_OBJECT_USB_AUDIO }, { iothread, QEMU_CAPS_OBJECT_IOTHREAD}, { ivshmem, QEMU_CAPS_DEVICE_IVSHMEM }, +{ x86_64_cpu, QEMU_CAPS_DEVICE_X86_64_CPU }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { @@ -3157,6 +3159,7 @@ virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps, virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI); virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET); virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT); +virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_X86_64_CPU); } ret = 0; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 12e1688..6872e09 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -223,6 +223,7 @@ typedef enum { QEMU_CAPS_VMWARE_SVGA_VGAMEM = 181, /* -device vmware-svga.vgamem_mb */ QEMU_CAPS_QXL_VGAMEM = 182, /* -device qxl.vgamem_mb */ QEMU_CAPS_QXL_VGA_VGAMEM = 183, /* -device qxl-vga.vgamem_mb */ +QEMU_CAPS_DEVICE_X86_64_CPU = 184, /* -device *x86_64-cpu */ QEMU_CAPS_LAST, /* this must always be the last item */ } virQEMUCapsFlags; -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH v2 02/12] domain_conf: introduce cpu def helpers
On Wed, Feb 04, 2015 at 05:18:20PM +0800, Zhu Guihua wrote: virDomainCPUDefFree - free memory allocated virDomainCPUDefParseXML - parse job type virDomainCPUDefFormat - output job type Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- docs/formatdomain.html.in | 28 +++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c| 82 +++ src/conf/domain_conf.h| 1 + src/libvirt_private.syms | 1 + 5 files changed, 115 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f8d5f89..10cbd29 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5830,6 +5830,34 @@ qemu-kvm -net nic,model=? /dev/null /dd /dl + h4a name=elementsCpuCPU device/a/h4 + p +CPU device allows to be hot added to the guest. +span class=sinceSince 1.2.12, QEMU and KVM only/span + /p + +pre + ... + lt;devicesgt; +lt;cpu match='exact'gt; + lt;model fallback='allow'gt;core2duolt;/modelgt; + lt;vendorgt;Intellt;/vendorgt; + lt;topology sockets='1' cores='2' threads='1'/gt; + lt;feature policy='disable' name='lahf_lm'/gt; +lt;/cpugt; + lt;devicesgt; NACK, it is just madness to duplicate the CPU info we already have in a different place in the XML. 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] [PATCH 1/3] add guest agent configuration to domain xml
Signed-off-by: Jincheng Miao jm...@redhat.com --- .../domain/xmls/kvm_linux_guest_install_cdrom.xml |4 repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml index cb59e76..8f398bb 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml @@ -35,5 +35,9 @@ console/ input bus=ps2 type=mouse/ graphics keymap=en-us port=-1 type=vnc/ +channel type='unix' + source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/ + target type='virtio' name='org.qemu.guest_agent.0'/ +/channel /devices /domain diff --git a/repos/domain/xmls/kvm_linux_guest_install_net.xml b/repos/domain/xmls/kvm_linux_guest_install_net.xml index c4a7de7..5fad3a7 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_net.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_net.xml @@ -24,13 +24,17 @@ source file='DISKPATH'/ target bus='HDDRIVER' dev='DEV'/ /disk - interface type=network -source network=default/ -mac address='MACADDR'/ -model type='NICDRIVER'/ - /interface - console/ - input bus=ps2 type=mouse/ - graphics keymap=en-us port=-1 type=vnc/ +interface type=network + source network=default/ + mac address='MACADDR'/ + model type='NICDRIVER'/ +/interface +console/ +input bus=ps2 type=mouse/ +graphics keymap=en-us port=-1 type=vnc/ +channel type='unix' + source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/ + target type='virtio' name='org.qemu.guest_agent.0'/ +/channel /devices /domain -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 12/12] qemu_driver: detect threads corresponding to Vcpus
After hotplugging the CPUs, we need to re-detect threads corresponding to Vcpus. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 274 --- src/qemu/qemu_driver.h | 8 ++ src/qemu/qemu_hotplug.c | 7 ++ src/util/virbitmap.c | 2 +- src/util/virbitmap.h | 2 + 6 files changed, 160 insertions(+), 134 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b23c45c..4399b58 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1047,6 +1047,7 @@ virBitmapFree; virBitmapGetBit; virBitmapIsAllClear; virBitmapIsAllSet; +virBitmapIsSet; virBitmapLastSetBit; virBitmapNew; virBitmapNewCopy; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bf33d7a..745bedd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4357,89 +4357,49 @@ static void qemuProcessEventHandler(void *data, void *opaque) VIR_FREE(processEvent); } -static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver, - virDomainObjPtr vm, - unsigned int nvcpus) +/* After hotplugging the CPUs we need to re-detect threads corresponding + * * to the virtual CPUs. Some older versions don't provide the thread ID + * * or don't have the info cpus command (and they don't support multiple + ** CPUs anyways), so errors in the re-detection will not be treated + * * fatal */ +int +qemuDomainDetectVcpu(virQEMUDriverPtr driver, + virDomainObjPtr vm, + int apic_id, + bool plug) { qemuDomainObjPrivatePtr priv = vm-privateData; -size_t i; -int rc = 1; -int ret = -1; int oldvcpus = vm-def-vcpus; int vcpus = oldvcpus; pid_t *cpupids = NULL; int ncpupids; +int ret = -1; virCgroupPtr cgroup_vcpu = NULL; char *mem_mask = NULL; -uint32_t apic_id; - -qemuDomainObjEnterMonitor(driver, vm); - -/* We need different branches here, because we want to offline - * in reverse order to onlining, so any partial fail leaves us in a - * reasonably sensible state */ -if (nvcpus vcpus) { -for (i = vcpus; i nvcpus; i++) { -/* Online new CPU */ -apic_id = virDomainCPUGetFreeApicID(vm-def); -rc = qemuMonitorSetCPU(priv-mon, apic_id, true); -if (rc == 0) -goto unsupported; -if (rc 0) -goto exit_monitor; - -vcpus++; -ignore_value(virBitmapSetBit(vm-def-apic_id_map, apic_id)); -} -} else { -for (i = vcpus - 1; i = nvcpus; i--) { -/* Offline old CPU */ -rc = qemuMonitorSetCPU(priv-mon, i, false); -if (rc == 0) -goto unsupported; -if (rc 0) -goto exit_monitor; - -vcpus--; -} -} - -/* hotplug succeeded */ +int idx = 0; +size_t i; +int *thread = NULL; ret = 0; +if (plug) +vcpus++; +else +vcpus--; + +qemuDomainObjEnterMonitor(driver, vm); -/* After hotplugging the CPUs we need to re-detect threads corresponding - * to the virtual CPUs. Some older versions don't provide the thread ID - * or don't have the info cpus command (and they don't support multiple - * CPUs anyways), so errors in the re-detection will not be treated - * fatal */ if ((ncpupids = qemuMonitorGetCPUInfo(priv-mon, cpupids)) = 0) { virResetLastError(); -goto exit_monitor; -} -if (qemuDomainObjExitMonitor(driver, vm) 0) { -ret = -1; goto cleanup; } -/* check if hotplug has failed */ -if (vcpus oldvcpus ncpupids == oldvcpus) { -virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s, - _(qemu didn't unplug the vCPUs properly)); -vcpus = oldvcpus; -ret = -1; -goto cleanup; +for (i = 0; i apic_id; i++) { +if (virBitmapIsSet(vm-def-apic_id_map, i)) +idx++; } -if (ncpupids != vcpus) { -virReportError(VIR_ERR_INTERNAL_ERROR, - _(got wrong number of vCPU pids from QEMU monitor. - got %d, wanted %d), - ncpupids, vcpus); -vcpus = oldvcpus; -ret = -1; +if (VIR_ALLOC_N(thread, vcpus) 0) goto cleanup; -} if (virDomainNumatuneGetMode(vm-def-numatune, -1) == VIR_DOMAIN_NUMATUNE_MEM_STRICT @@ -4448,105 +4408,153 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver, mem_mask, -1) 0) goto cleanup; -if (nvcpus oldvcpus) { -for (i = oldvcpus; i nvcpus; i++) { -if (priv-cgroup) { -int rv = -1; -/* Create cgroup for
[libvirt] [RFC PATCH v2 01/12] domain_conf: add support for cpu device configuration in XML
This patch adds configuration support for the cpu device. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/conf/domain_conf.c | 34 +- src/conf/domain_conf.h | 16 src/qemu/qemu_driver.c | 6 ++ src/qemu/qemu_hotplug.c | 1 + 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 10dbabd..0f4baaf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -236,7 +236,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, rng, shmem, tpm, - panic) + panic, + cpu) VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, none, @@ -1981,6 +1982,7 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) case VIR_DOMAIN_DEVICE_PANIC: virDomainPanicDefFree(def-data.panic); break; +case VIR_DOMAIN_DEVICE_CPU: case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: break; @@ -2687,6 +2689,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) return device-data.tpm-info; case VIR_DOMAIN_DEVICE_PANIC: return device-data.panic-info; +case VIR_DOMAIN_DEVICE_CPU: +return device-data.cpu-info; /* The following devices do not contain virDomainDeviceInfo */ case VIR_DOMAIN_DEVICE_LEASE: @@ -2917,6 +2921,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, if (cb(def, device, def-panic-info, opaque) 0) return -1; } +device.type = VIR_DOMAIN_DEVICE_CPU; +for (i = 0; i def-ncpus; i++) { +device.data.cpu = def-cpus[i]; +if (cb(def, device, def-cpus[i]-info, opaque) 0) +return -1; +} /* Coverity is not very happy with this - all dead_error_condition */ #if !STATIC_ANALYSIS @@ -2950,6 +2960,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_RNG: +case VIR_DOMAIN_DEVICE_CPU: break; } #endif @@ -11175,6 +11186,7 @@ virDomainDeviceDefParse(const char *xmlStr, if (!(dev-data.panic = virDomainPanicDefParseXML(node))) goto error; break; +case VIR_DOMAIN_DEVICE_CPU: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LAST: break; @@ -15552,6 +15564,19 @@ virDomainPanicDefCheckABIStability(virDomainPanicDefPtr src, return virDomainDeviceInfoCheckABIStability(src-info, dst-info); } +static bool +virDomainCPUDefCheckABIStability(virDomainCPUDefPtr src, + virDomainCPUDefPtr dst) +{ +if (src-virCPU-model != dst-virCPU-model) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Target CPU device model doesn't match source)); +return false; +} + +return virDomainDeviceInfoCheckABIStability(src-info, dst-info); +} + /* This compares two configurations and looks for any differences * which will affect the guest ABI. This is primarily to allow * validation of custom XML config passed in during migration @@ -15985,6 +16010,11 @@ virDomainDefCheckABIStability(virDomainDefPtr src, goto error; } +for (i = 0; i src-ncpus; i++) { +if (!virDomainCPUDefCheckABIStability(src-cpus[i], dst-cpus[i])) +goto error; +} + /* Coverity is not very happy with this - all dead_error_condition */ #if !STATIC_ANALYSIS /* This switch statement is here to trigger compiler warning when adding @@ -16016,6 +16046,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_SHMEM: +case VIR_DOMAIN_DEVICE_CPU: break; } #endif @@ -21448,6 +21479,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, case VIR_DOMAIN_DEVICE_PANIC: rc = virDomainPanicDefFormat(buf, src-data.panic); break; +case VIR_DOMAIN_DEVICE_CPU: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 563c18b..b9d4e7c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -144,6 +144,9 @@ typedef virDomainShmemDef *virDomainShmemDefPtr; typedef struct _virDomainTPMDef virDomainTPMDef; typedef virDomainTPMDef *virDomainTPMDefPtr; +typedef struct _virDomainCPUDef virDomainCPUDef; +typedef virDomainCPUDef *virDomainCPUDefPtr; + /* Flags for the 'type' field in virDomainDeviceDef */ typedef enum { VIR_DOMAIN_DEVICE_NONE = 0, @@ -168,6 +171,7 @@ typedef enum { VIR_DOMAIN_DEVICE_SHMEM, VIR_DOMAIN_DEVICE_TPM, VIR_DOMAIN_DEVICE_PANIC, +VIR_DOMAIN_DEVICE_CPU, VIR_DOMAIN_DEVICE_LAST } virDomainDeviceType; @@ -192,6 +196,7 @@ struct
[libvirt] [RFC PATCH v2 10/12] qemu: implement cpu device hotunplug on live level
This patch implements live hotunplug of a cpu device. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_driver.c | 2 ++ src/qemu/qemu_hotplug.c | 75 + src/qemu/qemu_hotplug.h | 4 +++ 3 files changed, 81 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 00a36e7..bf33d7a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7090,6 +7090,8 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, ret = qemuDomainDetachChrDevice(driver, vm, dev-data.chr); break; case VIR_DOMAIN_DEVICE_CPU: +ret = qemuDomainDetachCPUDevice(driver, vm, dev-data.cpu); +break; case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f51555d..975ed1d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2918,6 +2918,27 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver, } +static int +qemuDomainRemoveCPUDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainCPUDefPtr cpu) +{ +virObjectEventPtr event; + +VIR_DEBUG(Removing cpu device %s from domain %p %s, + cpu-info.alias, vm, vm-def-name); + +event = virDomainEventDeviceRemovedNewFromObj(vm, cpu-info.alias); +if (event) +qemuDomainEventQueue(driver, event); + +virDomainCPURemove(vm-def, cpu); +virDomainCPUDefFree(cpu); + +return 0; +} + + int qemuDomainRemoveDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3843,3 +3864,57 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, VIR_FREE(devstr); return ret; } + +int qemuDomainDetachCPUDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainCPUDefPtr cpu) +{ +int ret = -1; +qemuDomainObjPrivatePtr priv = vm-privateData; +virDomainDefPtr vmdef = vm-def; +virDomainCPUDefPtr tmpCPU; +int rc = 0; + +if (!(tmpCPU = virDomainCPUFind(vmdef, cpu))) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(device not present in domain configration)); +return ret; +} + +if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE)) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(qemu does not support -device)); +} + +if (!tmpCPU-info.alias) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(detaching cpu device without id is not supported)); +return ret; +} + +qemuDomainMarkDeviceForRemoval(vm, tmpCPU-info); + +qemuDomainObjEnterMonitor(driver, vm); +if (qemuMonitorDelDevice(priv-mon, tmpCPU-info.alias) 0) { +if (qemuDomainObjExitMonitor(driver, vm) 0) +ret = -1; + +goto cleanup; +} +if (qemuDomainObjExitMonitor(driver, vm) 0) { +ret = -1; +goto cleanup; +} + +ignore_value(virBitmapClearBit(vm-def-apic_id_map, tmpCPU-apic_id)); + +rc = qemuDomainWaitForDeviceRemoval(vm); +if (rc == 0 || rc == 1) +ret = qemuDomainRemoveCPUDevice(driver, vm, tmpCPU); +else +goto cleanup; + + cleanup: +qemuDomainResetDeviceRemoval(vm); +return ret; +} diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index c583fb7..c168ac5 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -113,6 +113,10 @@ qemuDomainAttachCPUDevice(virQEMUDriverPtr driver, int qemuDomainCPUInsert(virDomainDefPtr vmdef, virDomainCPUDefPtr cpu); +int +qemuDomainDetachCPUDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainCPUDefPtr cpu); int qemuDomainRemoveDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH v2 09/12] qemu: implement cpu device hotplug on live level
This patch implements live hotplug of a cpu device. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- src/qemu/qemu_driver.c | 6 ++ src/qemu/qemu_hotplug.c | 57 + src/qemu/qemu_hotplug.h | 8 +++ 3 files changed, 71 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c6318bc..00a36e7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7008,6 +7008,12 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, break; case VIR_DOMAIN_DEVICE_CPU: +ret = qemuDomainAttachCPUDevice(driver, vm, +dev-data.cpu); +if (!ret) +dev-data.cpu = NULL; +break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index cf8362c..f51555d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1543,6 +1543,63 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, return ret; } +int +qemuDomainCPUInsert(virDomainDefPtr vmdef, +virDomainCPUDefPtr cpu) +{ +if (virDomainCPUInsert(vmdef, cpu) 0) +return -1; + +return 0; +} + +int qemuDomainAttachCPUDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainCPUDefPtr cpu) +{ +int ret = -1; +char *devstr = NULL; +qemuDomainObjPrivatePtr priv = vm-privateData; +virDomainDefPtr vmdef = vm-def; + +if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE)) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(qemu does not support -device)); +goto cleanup; +} + +if (qemuAssignDeviceCPUAlias(vmdef, cpu, -1) 0) +goto cleanup; + +cpu-apic_id = virDomainCPUGetFreeApicID(vmdef); + +if (qemuBuildCPUDeviceStr(devstr, driver, vmdef, cpu, priv-qemuCaps) 0) +goto cleanup; + +if (qemuDomainCPUInsert(vmdef, cpu) 0) +goto cleanup; + +qemuDomainObjEnterMonitor(driver, vm); +if (devstr qemuMonitorAddDevice(priv-mon, devstr) 0) { +if (qemuDomainObjExitMonitor(driver, vm) 0) +ret = -1; + +goto cleanup; +} + +if (qemuDomainObjExitMonitor(driver, vm) 0) { +ret = -1; +goto cleanup; +} + +ignore_value(virBitmapSetBit(vm-def-apic_id_map, cpu-apic_id)); +ret = 0; + + cleanup: +VIR_FREE(devstr); +return ret; +} + static int qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index a30788d..c583fb7 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -106,6 +106,14 @@ virDomainChrDefPtr qemuDomainChrRemove(virDomainDefPtr vmdef, virDomainChrDefPtr chr); +int +qemuDomainAttachCPUDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainCPUDefPtr cpu); +int +qemuDomainCPUInsert(virDomainDefPtr vmdef, +virDomainCPUDefPtr cpu); + int qemuDomainRemoveDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev); -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] check fc_host and vport_ops capabilities in SCSI host nodedevs
On Wed, Feb 4, 2015 at 7:25 PM, John Ferlan jfer...@redhat.com wrote: On 02/03/2015 03:59 PM, John Ferlan wrote: On 02/03/2015 06:55 AM, Shivaprasad G Bhat wrote: fc_host vport_ops devices are SCSI devices with additional capabilities. Mere string comparison of basic types is not sufficient in this case. This patch introduces additional capability checks for SCSI devices if the user is looking to list 'fc_host' or 'vport_ops' devices. Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com --- src/conf/node_device_conf.c |8 1 file changed, 8 insertions(+) While this does work and more or less follows what was done for virNodeDeviceCapMatch, I'm wondering if the 'fc_host' and 'vports_ops' capabilities need to also be returned in a list of capabilities for a node device That is I see that virNodeDeviceListCaps() seems to be only returning 1 capability for every device. However, for the scsi_host, it has those additional fc_host and vport_ops capabilities which if returned in the list would then be found by the python listDevices code which for some devices (like the scsi_host here) there may be more than one way to get at the information. I'm investigating whether modifying nodeDeviceListCaps() in src/node_device/node_device_driver.c to add fc_host and vport_ops to the return caps_list will resolve the issue... This also means virNodeDeviceNumOfCaps() (and it's driver API nodeDeviceNumOfCaps) will need some tweaking too. Another option would be to fix the libvirt-python code to use ListAllDevices with the flags argument like virsh does. John ...snip... As it turns out your patch will be required in order to cover the virNodeListDevices case as well as the attached patch in order to cover the virNodeDeviceNumOfCaps and virNodeDeviceListCaps cases. You are right, The listDevices doesn't use either of these APIs. Could you take a look at the attached code and try it out on your system to make sure it does what I expect (the system I use to test these types of checks is unavailable at the moment). What should happen is for 'scsi_host' devices with 'fc_host' and/or 'vports' capability types - the cap_list returned will be larger than 1. The code currently only has ever returned 1 element. The patch also lists the sample python which should work. With your successful test, I'll push the patches (although I'm tweaking your commit message a bit - it'll be very similar to the attached patch commit message). Thanks John. I agree with your changes for virNodeDeviceListCaps and virNodeDeviceNumOfCaps. I too don't have systems for verifying the patch for now. Let me see if I can catch hold of a system tomorrow. Thanks - John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 10/10] tests: add some simple libxl XML-XML tests
Handle features supported only on xen: driver domains, qemu in stubdomain. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- tests/Makefile.am | 9 +- tests/domainschematest | 2 +- tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml | 41 + tests/xlxml2xmldata/xlxml2xml-hvm.xml | 40 + tests/xlxml2xmldata/xlxml2xml-network-bridged.xml | 38 + .../xlxml2xml-network-driver-domain.xml| 38 + tests/xlxml2xmldata/xlxml2xml-network-routed.xml | 39 + tests/xlxml2xmldata/xlxml2xml-pv.xml | 38 + tests/xlxml2xmltest.c | 189 + 9 files changed, 431 insertions(+), 3 deletions(-) create mode 100644 tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-hvm.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-network-bridged.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-network-driver-domain.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-network-routed.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-pv.xml create mode 100644 tests/xlxml2xmltest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 938270c..48648b9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -85,6 +85,7 @@ EXTRA_DIST = \ domainsnapshotxml2xmlout \ fchostdata \ interfaceschemadata \ + xlxml2xmldata \ lxcconf2xmldata \ lxcxml2xmldata \ lxcxml2xmloutdata \ @@ -230,7 +231,7 @@ test_programs += xml2sexprtest sexpr2xmltest \ endif WITH_XEN if WITH_LIBXL -test_programs += xlconfigtest +test_programs += xlconfigtest xlxml2xmltest endif WITH_LIBXL if WITH_QEMU @@ -515,8 +516,12 @@ xlconfigtest_SOURCES = \ xlconfigtest.c testutilsxen.c testutilsxen.h \ testutils.c testutils.h xlconfigtest_LDADD =$(libxl_LDADDS) +xlxml2xmltest_SOURCES = \ + xlxml2xmltest.c testutilsxen.c testutilsxen.h \ + testutils.c testutils.h +xlxml2xmltest_LDADD =$(libxl_LDADDS) else ! WITH_LIBXL -EXTRA_DIST += xlconfigtest.c +EXTRA_DIST += xlconfigtest.c xlxml2xmltest.c endif ! WITH_LIBXL QEMUMONITORTESTUTILS_SOURCES = \ diff --git a/tests/domainschematest b/tests/domainschematest index ba90180..18b442b 100755 --- a/tests/domainschematest +++ b/tests/domainschematest @@ -8,7 +8,7 @@ DIRS= DIRS=$DIRS domainschemadata qemuxml2argvdata sexpr2xmldata DIRS=$DIRS xmconfigdata xml2sexprdata qemuxml2xmloutdata DIRS=$DIRS lxcxml2xmldata lxcxml2xmloutdata -DIRS=$DIRS bhyvexml2argvdata +DIRS=$DIRS bhyvexml2argvdata xlxml2xmldata SCHEMA=domain.rng check_schema $DIRS $SCHEMA diff --git a/tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml b/tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml new file mode 100644 index 000..ed6440c --- /dev/null +++ b/tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml @@ -0,0 +1,41 @@ +domain type='xen' + nametesthvm/name + uuida3d3fa04-dc23-4136-9eab-b579d2930817/uuid + memory unit='KiB'524288/memory + currentMemory unit='KiB'524288/currentMemory + vcpu placement='static'2/vcpu + os +type arch='x86_64' machine='xenfv'hvm/type +loader type='rom'/usr/lib/xen/boot/hvmloader/loader +boot dev='cdrom'/ +boot dev='hd'/ + /os + features +acpi/ +apic/ +pae/ +viridian/ + /features + clock offset='variable' adjustment='0' basis='localtime'/ + on_poweroffdestroy/on_poweroff + on_rebootdestroy/on_reboot + on_crashdestroy/on_crash + devices +emulator type='stubdom'/usr/lib/xen/bin/qemu-dm/emulator +disk type='file' device='disk' + driver name='file'/ + source file='/var/lib/libvirt/images/testhvm/root.img'/ + target dev='xvda' bus='xen'/ +/disk +disk type='file' device='disk' + driver name='file'/ + source file='/var/lib/libvirt/images/testhvm/private.img'/ + target dev='xvdb' bus='xen'/ +/disk +interface type='network' + mac address='00:16:3e:5e:6c:09'/ + source network='default'/ +/interface +input type='tablet' bus='usb'/ + /devices +/domain diff --git a/tests/xlxml2xmldata/xlxml2xml-hvm.xml b/tests/xlxml2xmldata/xlxml2xml-hvm.xml new file mode 100644 index 000..95d9b84 --- /dev/null +++ b/tests/xlxml2xmldata/xlxml2xml-hvm.xml @@ -0,0 +1,40 @@ +domain type='xen' + nametesthvm/name + uuida3d3fa04-dc23-4136-9eab-b579d2930817/uuid + memory unit='KiB'524288/memory + currentMemory unit='KiB'524288/currentMemory + vcpu placement='static'2/vcpu + os +type arch='x86_64' machine='xenfv'hvm/type +loader type='rom'/usr/lib/xen/boot/hvmloader/loader +boot dev='cdrom'/ +boot dev='hd'/ + /os + features +acpi/ +apic/ +pae/ +viridian/ + /features + clock offset='variable' adjustment='0' basis='localtime'/ + on_poweroffdestroy/on_poweroff + on_rebootdestroy/on_reboot + on_crashdestroy/on_crash + devices +disk type='file'
[libvirt] [PATCH 00/10] A bunch of extensions to libxl driver
This are some additional features to libxl driver. Some of them require change in domain config structures/syntax. Details described with each patch. Actually this is next iteration of a few years old patch series... Marek Marczykowski-Górecki (10): libxl: update dom-id in libxlDomainCreateWithFlags conf: support backend domain name in disk and network devices libxl: support backend domain setting for disk and net devices libxl: fill HVM SDL and VNC settings based on graphics/ entries libxl: pass ipaddr to libxl toolstack libxl: add tablet/mouse input device support libxl: prevent attaching multiple netdevs with the same MAC libxl: support domain config modification in virDomainRestoreFlags libxl: stubdom emulator type tests: add some simple libxl XML-XML tests docs/formatdomain.html.in | 43 - docs/schemas/domaincommon.rng | 43 - src/conf/domain_conf.c | 69 +++- src/conf/domain_conf.h | 10 ++ src/libxl/libxl_conf.c | 194 ++--- src/libxl/libxl_domain.c | 11 ++ src/libxl/libxl_driver.c | 61 ++- src/util/virstoragefile.c | 4 +- src/util/virstoragefile.h | 1 + tests/Makefile.am | 9 +- tests/domainschematest | 2 +- tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml | 41 + tests/xlxml2xmldata/xlxml2xml-hvm.xml | 40 + tests/xlxml2xmldata/xlxml2xml-network-bridged.xml | 38 .../xlxml2xml-network-driver-domain.xml| 38 tests/xlxml2xmldata/xlxml2xml-network-routed.xml | 39 + tests/xlxml2xmldata/xlxml2xml-pv.xml | 38 tests/xlxml2xmltest.c | 189 18 files changed, 824 insertions(+), 46 deletions(-) create mode 100644 tests/xlxml2xmldata/xlxml2xml-hvm-stubdom.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-hvm.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-network-bridged.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-network-driver-domain.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-network-routed.xml create mode 100644 tests/xlxml2xmldata/xlxml2xml-pv.xml create mode 100644 tests/xlxml2xmltest.c -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 09/10] libxl: Stubdom emulator type
Xen have feature of having device model in separate domain (called stub domain). Add a 'type' attribute to 'emulator' element to allow selecting such a configuration. Emulator path is still used for qemu running in dom0 (if any). Libxl currently do not allow to select stubdomain path. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- I think it would be good idea to introduce the same change to capabilities XML. The problem is I can't include domain_conf.h from capabilities.h, so probably that enum declaration needs to be moved to capabilities.h. Is it the right way? Or it should be done somehow different? docs/formatdomain.html.in | 14 ++ docs/schemas/domaincommon.rng | 23 ++- src/conf/domain_conf.c| 36 ++-- src/conf/domain_conf.h| 9 + src/libxl/libxl_conf.c| 17 + 5 files changed, 96 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 38c42d5..4f539e2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1652,6 +1652,20 @@ The a href=formatcaps.htmlcapabilities XML/a specifies the recommended default emulator to use for each particular domain type / architecture combination. + +span class=sinceSince 1.2.13/span, the codeemulator/code +element may contain codetype/code attribute. Possible values are: +dl + dtcodetype='default'/code/dt + ddEquivalent to not setting codetype/code attribute at all. + /dd + + dtcodetype='stubdom'/code/dt + ddLaunch emulator in stub domain (Xen only). The emulator path + still indicate which binary is used in dom0 - there is no control + which binary is used as a stub domain. + /dd +/dl /dd /dl diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a4321f1..2a12073 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2519,7 +2519,28 @@ -- define name=emulator element name=emulator - ref name=absFilePath/ + choice +group + optional +attribute name=type + choice +valueqemu/value +valuestubdom/value + /choice +/attribute + /optional + ref name=absFilePath/ +/group +group + attribute name=type +choice + valueqemu/value + valuestubdom/value +/choice + /attribute + empty/ +/group + /choice /element /define !-- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 17b699a..c268091 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -741,6 +741,10 @@ VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST, closed, open); +VIR_ENUM_IMPL(virDomainEmulatorType, VIR_DOMAIN_EMULATOR_TYPE_LAST, + qemu, + stubdom); + VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, virtio); @@ -13712,6 +13716,14 @@ virDomainDefParseXML(xmlDocPtr xml, } def-emulator = virXPathString(string(./devices/emulator[1]), ctxt); +if ((tmp = virXPathString(string(./devices/emulator/@type), ctxt))) { +def-emulator_type = virDomainEmulatorTypeTypeFromString(tmp); +VIR_FREE(tmp); +if (def-emulator_type 0) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Unknown emulator type '%s'), tmp); +} +} /* analysis of the disk devices */ if ((n = virXPathNodeSet(./devices/disk, ctxt, nodes)) 0) @@ -15690,6 +15702,14 @@ virDomainDefCheckABIStability(virDomainDefPtr src, goto error; } +if (src-emulator_type != dst-emulator_type) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +_(Target domain emulator type %s does not match source %s), +virDomainEmulatorTypeTypeToString(dst-emulator_type), +virDomainEmulatorTypeTypeToString(src-emulator_type)); +goto error; +} + if (!virDomainDefFeaturesCheckABIStability(src, dst)) goto error; @@ -19893,8 +19913,20 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAddLit(buf, devices\n); virBufferAdjustIndent(buf, 2); -virBufferEscapeString(buf, emulator%s/emulator\n, - def-emulator); +if (def-emulator || +def-emulator_type != VIR_DOMAIN_EMULATOR_TYPE_DEFAULT) { +virBufferAddLit(buf, emulator); +if (def-emulator_type != VIR_DOMAIN_EMULATOR_TYPE_DEFAULT) { +virBufferAsprintf(buf, type='%s', + virDomainEmulatorTypeTypeToString(def-emulator_type)); +} +if
[libvirt] [PATCH 08/10] libxl: support domain config modification in virDomainRestoreFlags
Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- There was a discussion about calling virDomainDefCheckABIStability. The use case I have for this is to start multiple domains from the same savefile. This require changing: - UUID - name - IP address Those are exactly type of changes blocked by virDomainDefCheckABIStability. Perhaps some permissive mode should be introduced to the virDomainDefCheckABIStability function? src/libxl/libxl_driver.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 005cc96..7539d33 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1456,11 +1456,6 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from, #endif virCheckFlags(VIR_DOMAIN_SAVE_PAUSED, -1); -if (dxml) { -virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, - _(xml modification unsupported)); -return -1; -} fd = libxlDomainSaveImageOpen(driver, cfg, from, def, hdr); if (fd 0) @@ -1469,6 +1464,18 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from, if (virDomainRestoreFlagsEnsureACL(conn, def) 0) goto cleanup_unlock; +if (dxml) { +virDomainDefPtr def2 = NULL; + +if (!(def2 = virDomainDefParseString(dxml, cfg-caps, driver-xmlopt, +1 VIR_DOMAIN_VIRT_XEN, +VIR_DOMAIN_XML_INACTIVE))) { +goto cleanup; +} +virDomainDefFree(def); +def = def2; +} + if (!(vm = virDomainObjListAdd(driver-domains, def, driver-xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 06/10] libxl: add tablet/mouse input device support
Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- Changes in v2: - rebase on 1.2.12+ - multiple devices support src/libxl/libxl_conf.c | 48 1 file changed, 48 insertions(+) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 4730585..b1131ea 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -815,6 +815,54 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } } +if (def-ninputs) { +#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST +if (VIR_ALLOC_N(b_info-u.hvm.usbdevice_list, def-ninputs+1) 0) +return -1; +#else +if (def-ninputs 1) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(libxenlight supports only one input device)); +return -1; +} +#endif +for (i = 0; i def-ninputs; i++) { +if (def-inputs[i]-bus != VIR_DOMAIN_INPUT_BUS_USB) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(libxenlight supports only USB input)); +return -1; +} +} +for (i = 0; i def-ninputs; i++) { +switch (def-inputs[i]-type) { +case VIR_DOMAIN_INPUT_TYPE_MOUSE: +#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST +if (VIR_STRDUP(b_info-u.hvm.usbdevice_list[i], mouse) 0) +return -1; +#else +VIR_FREE(b_info-u.hvm.usbdevice); +if (VIR_STRDUP(b_info-u.hvm.usbdevice, mouse) 0) +return -1; +#endif +break; +case VIR_DOMAIN_INPUT_TYPE_TABLET: +#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST +if (VIR_STRDUP(b_info-u.hvm.usbdevice_list[i], tablet) 0) +return -1; +#else +VIR_FREE(b_info-u.hvm.usbdevice); +if (VIR_STRDUP(b_info-u.hvm.usbdevice, tablet) 0) +return -1; +#endif +break; +default: +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(Unknown input device type)); +return -1; +} +} +} + /* * The following comment and calculation were taken directly from * libxenlight's internal function libxl_get_required_shadow_memory(): -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 03/10] libxl: support backend domain setting for disk and net devices
This implement handling of source domain=''/ parameter introduced in previous patch. Lookup on domain name (to get domain ID) requires libxlDriverPrivate object, so it must be passed down to libxlMakeDisk and libxlMakeNet from top level callers. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- Changes in v2: - rebase on 1.0.6+ - fix indentation - make libxl_name_to_domid switch more defensive Changes in v3: - rebase on 1.2.12+ - leave name-XID resolution to libxl itself, which greatly simplify the code (but requires Xen at least 4.3) src/libxl/libxl_conf.c | 24 1 file changed, 24 insertions(+) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 0555b91..1811a83 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -971,6 +971,18 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk) return -1; } +if (l_disk-src-domain_name) { +#ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME +if (VIR_STRDUP(x_disk-backend_domname, l_disk-src-domain_name) 0) +return -1; +#else +virReportError(VIR_ERR_XML_DETAIL, %s, +_(this version of libxenlight does not + support backend domain name)); +return -1; +#endif +} + return 0; } @@ -1098,6 +1110,18 @@ libxlMakeNic(virDomainDefPtr def, return -1; } +if (l_nic-domain_name) { +#ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME +if (VIR_STRDUP(x_nic-backend_domname, l_nic-domain_name) 0) +return -1; +#else +virReportError(VIR_ERR_XML_DETAIL, %s, +_(this version of libxenlight does not + support backend domain name)); +return -1; +#endif +} + return 0; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 04/10] libxl: fill HVM SDL and VNC settings based on graphics/ entries
Vfb entries in domain config are used only by PV drivers. Qemu parameters are build based on b_info struct. So fill it with the same data as vfb entries (actually the first one). This will additionally allow graphic-less domain, when no graphics/ entries are present in domain XML (previously VNC was always enabled). Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- src/libxl/libxl_conf.c | 100 - 1 file changed, 74 insertions(+), 26 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 1811a83..c9f8ad5 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -618,12 +618,53 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) _(unsupported chardev '%s'), type); return -1; } +return 0; +} + +static int +libxlMakeVNCInfo(virPortAllocatorPtr graphicsports, + virDomainGraphicsDefPtr l_vfb, + libxl_vnc_info *x_vnc) +{ +unsigned short port; +const char *listenAddr; + +libxl_defbool_set(x_vnc-enable, 1); +/* driver handles selection of free port */ +libxl_defbool_set(x_vnc-findunused, 0); +if (l_vfb-data.vnc.autoport) { + +if (virPortAllocatorAcquire(graphicsports, port) 0) +return -1; +l_vfb-data.vnc.port = port; +} +x_vnc-display = l_vfb-data.vnc.port - LIBXL_VNC_PORT_MIN; +listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0); +if (listenAddr) { +/* libxl_device_vfb_init() does VIR_STRDUP(127.0.0.1) */ +VIR_FREE(x_vnc-listen); +if (VIR_STRDUP(x_vnc-listen, listenAddr) 0) +return -1; +} +return 0; +} + +static int +libxlMakeSDLInfo(virDomainGraphicsDefPtr l_vfb, + libxl_sdl_info *x_sdl) +{ +libxl_defbool_set(x_sdl-enable, 1); +if (VIR_STRDUP(x_sdl-display, l_vfb-data.sdl.display) 0) +return -1; +if (VIR_STRDUP(x_sdl-xauthority, l_vfb-data.sdl.xauth) 0) +return -1; return 0; } static int libxlMakeDomBuildInfo(virDomainDefPtr def, + virPortAllocatorPtr graphicsports, libxl_ctx *ctx, libxl_domain_config *d_config) { @@ -745,6 +786,35 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, return -1; } +/* Disable VNC and SDL until explicitly enabled */ +libxl_defbool_set(b_info-u.hvm.vnc.enable, 0); +libxl_defbool_set(b_info-u.hvm.sdl.enable, 0); + +for (i = 0; i def-ngraphics; i++) { +switch (def-graphics[i]-type) { +case VIR_DOMAIN_GRAPHICS_TYPE_VNC: +if (libxl_defbool_val(b_info-u.hvm.vnc.enable)) +continue; +if (libxlMakeVNCInfo(graphicsports, +def-graphics[i], +b_info-u.hvm.vnc) 0) +return -1; +if (def-graphics[i]-data.vnc.keymap +VIR_STRDUP(b_info-u.hvm.keymap, + def-graphics[i]-data.vnc.keymap) 0) { +virReportOOMError(); +return -1; +} +break; +case VIR_DOMAIN_GRAPHICS_TYPE_SDL: +if (libxl_defbool_val(b_info-u.hvm.sdl.enable)) +continue; +if (libxlMakeSDLInfo(def-graphics[i], b_info-u.hvm.sdl) 0) +return -1; +break; +} +} + /* * The following comment and calculation were taken directly from * libxenlight's internal function libxl_get_required_shadow_memory(): @@ -1171,38 +1241,16 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports, virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb) { -unsigned short port; -const char *listenAddr; - libxl_device_vfb_init(x_vfb); switch (l_vfb-type) { case VIR_DOMAIN_GRAPHICS_TYPE_SDL: -libxl_defbool_set(x_vfb-sdl.enable, 1); -if (VIR_STRDUP(x_vfb-sdl.display, l_vfb-data.sdl.display) 0) -return -1; -if (VIR_STRDUP(x_vfb-sdl.xauthority, l_vfb-data.sdl.xauth) 0) +if (libxlMakeSDLInfo(l_vfb, x_vfb-sdl) 0) return -1; break; case VIR_DOMAIN_GRAPHICS_TYPE_VNC: -libxl_defbool_set(x_vfb-vnc.enable, 1); -/* driver handles selection of free port */ -libxl_defbool_set(x_vfb-vnc.findunused, 0); -if (l_vfb-data.vnc.autoport) { - -if (virPortAllocatorAcquire(graphicsports, port) 0) -return -1; -l_vfb-data.vnc.port = port; -} -x_vfb-vnc.display = l_vfb-data.vnc.port - LIBXL_VNC_PORT_MIN; - -
[libvirt] [PATCH 01/10] libxl: update dom-id in libxlDomainCreateWithFlags
Otherwise domainCreateWithFlags via remote returns -1 as domid. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- src/libxl/libxl_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index c95b387..ce3a99b 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2375,6 +2375,9 @@ libxlDomainCreateWithFlags(virDomainPtr dom, } ret = libxlDomainStart(driver, vm, (flags VIR_DOMAIN_START_PAUSED) != 0, -1); +if (ret 0) +goto cleanup; +dom-id = vm-def-id; cleanup: if (vm) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 07/10] libxl: prevent attaching multiple netdevs with the same MAC
It will not be possible to detach such device later. Also improve logging in such cases. Signed-off-by: Marek Marczykowski-Górecki marma...@invisiblethingslab.com --- src/libxl/libxl_driver.c | 41 +++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ce3a99b..005cc96 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2787,6 +2787,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver, int actualType; libxl_device_nic nic; int ret = -1; +char mac[VIR_MAC_STRING_BUFLEN]; /* preallocate new slot for device */ if (VIR_REALLOC_N(vm-def-nets, vm-def-nnets + 1) 0) @@ -2801,6 +2802,14 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver, actualType = virDomainNetGetActualType(net); +/* -2 means multiple matches so then fail also */ +if (virDomainNetFindIdx(vm-def, net) != -1) { +virReportError(VIR_ERR_OPERATION_FAILED, +_(device matching mac address %s already exists), +virMacAddrFormat(net-mac, mac)); +return -1; +} + if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { /* This is really a smart hostdev, so it should be attached * as a hostdev (the hostdev code will reach over into the @@ -2879,6 +2888,7 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev) virDomainHostdevDefPtr hostdev; virDomainHostdevDefPtr found; virDomainHostdevSubsysPCIPtr pcisrc; +char mac[VIR_MAC_STRING_BUFLEN]; switch (dev-type) { case VIR_DOMAIN_DEVICE_DISK: @@ -2896,6 +2906,12 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev) case VIR_DOMAIN_DEVICE_NET: net = dev-data.net; +if (virDomainNetFindIdx(vmdef, net) = 0) { +virReportError(VIR_ERR_INVALID_ARG, + _(network device with mac %s already exists.), + virMacAddrFormat(net-mac, mac)); +return -1; +} if (virDomainNetInsert(vmdef, net)) return -1; dev-data.net = NULL; @@ -3060,8 +3076,18 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver, char mac[VIR_MAC_STRING_BUFLEN]; int ret = -1; -if ((detachidx = virDomainNetFindIdx(vm-def, net)) 0) +if ((detachidx = virDomainNetFindIdx(vm-def, net)) 0) { +if (detachidx == -2) { +virReportError(VIR_ERR_OPERATION_FAILED, +_(multiple devices matching mac address %s found), +virMacAddrFormat(net-mac, mac)); +} else { +virReportError(VIR_ERR_OPERATION_FAILED, +_(network device %s not found), +virMacAddrFormat(net-mac, mac)); +} return -1; +} detach = vm-def-nets[detachidx]; @@ -3136,6 +3162,7 @@ libxlDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev) virDomainHostdevDefPtr hostdev, det_hostdev; virDomainNetDefPtr net; int idx; +char mac[VIR_MAC_STRING_BUFLEN]; switch (dev-type) { case VIR_DOMAIN_DEVICE_DISK: @@ -3150,8 +3177,18 @@ libxlDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev) case VIR_DOMAIN_DEVICE_NET: net = dev-data.net; -if ((idx = virDomainNetFindIdx(vmdef, net)) 0) +if ((idx = virDomainNetFindIdx(vmdef, net)) 0) { +if (idx == -2) { +virReportError(VIR_ERR_OPERATION_FAILED, +_(multiple devices matching mac address %s found), +virMacAddrFormat(dev-data.net-mac, mac)); +} else { +virReportError(VIR_ERR_OPERATION_FAILED, +_(network device %s not found), +virMacAddrFormat(dev-data.net-mac, mac)); +} return -1; +} /* this is guaranteed to succeed */ virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 05/12] conf: Add interface to parse and format memory device information
On 01/30/2015 08:21 AM, Peter Krempa wrote: WIP: TODO: docs Also forbid the new device in post parse callback in all driver that implement the callback to warn users right away that the device is not supported with their hypervisor. --- docs/schemas/domaincommon.rng | 50 src/bhyve/bhyve_domain.c | 5 +- src/conf/domain_conf.c | 317 - src/conf/domain_conf.h | 33 +++ src/libvirt_private.syms | 2 + src/libxl/libxl_domain.c | 3 + src/lxc/lxc_domain.c | 4 + src/openvz/openvz_driver.c | 3 + src/qemu/qemu_domain.c | 3 + src/qemu/qemu_driver.c | 13 + src/qemu/qemu_hotplug.c| 3 + src/uml/uml_driver.c | 3 + src/xen/xen_driver.c | 3 + src/xenapi/xenapi_driver.c | 3 + .../qemuxml2argv-memory-hotplug-dimm.xml | 47 +++ 15 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml ...snip... diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0b9fb06..298b574 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -236,7 +236,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, rng, shmem, tpm, - panic) + panic, + memory) VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, none, @@ -779,6 +780,12 @@ VIR_ENUM_DECL(virDomainBlockJob) VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST, , , copy, , active-commit) +VIR_ENUM_IMPL(virDomainMemoryModel, VIR_DOMAIN_MEMORY_MODEL_LAST, + , acpi-dimm) + +#define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE +#define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE + static virClassPtr virDomainObjClass; static virClassPtr virDomainObjListClass; static virClassPtr virDomainXMLOptionClass; @@ -1003,6 +1010,27 @@ virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def) } +/** + * virDomainDeviceDefCheckUnsupportedMemoryDevice: + * @dev: device definition + * + * Returns -1 if the device definition describes a memory device and reports an + * error. Otherwise returns 0. + */ +int +virDomainDeviceDefCheckUnsupportedMemoryDevice(virDomainDeviceDefPtr dev) +{ +/* This driver doesn't yet know how to handle memory devices */ +if (dev-type == VIR_DOMAIN_DEVICE_MEMORY) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(memory devices are not supported by this driver)); +return -1; +} + +return 0; +} + + static void virDomainObjListDataFree(void *payload, const void *name ATTRIBUTE_UNUSED) { @@ -1934,6 +1962,15 @@ void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def) VIR_FREE(def); } +void virDomainMemoryDefFree(virDomainMemoryDefPtr def) +{ +if (!def) +return; + +virDomainDeviceInfoClear(def-info); +VIR_FREE(def); +} + void virDomainDeviceDefFree(virDomainDeviceDefPtr def) { if (!def) @@ -2003,6 +2040,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) case VIR_DOMAIN_DEVICE_PANIC: virDomainPanicDefFree(def-data.panic); break; +case VIR_DOMAIN_DEVICE_MEMORY: +virDomainMemoryDefFree(def-data.memory); +break; case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: break; @@ -2200,6 +2240,10 @@ void virDomainDefFree(virDomainDefPtr def) virDomainRNGDefFree(def-rngs[i]); VIR_FREE(def-rngs); +for (i = 0; i def-nmems; i++) +virDomainMemoryDefFree(def-mems[i]); +VIR_FREE(def-mems); + virDomainTPMDefFree(def-tpm); virDomainPanicDefFree(def-panic); @@ -2709,6 +2753,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) return device-data.tpm-info; case VIR_DOMAIN_DEVICE_PANIC: return device-data.panic-info; +case VIR_DOMAIN_DEVICE_MEMORY: +return device-data.memory-info; /* The following devices do not contain virDomainDeviceInfo */ case VIR_DOMAIN_DEVICE_LEASE: @@ -2940,6 +2986,13 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, return -1; } +device.type = VIR_DOMAIN_DEVICE_MEMORY; +for (i = 0; i def-nmems; i++) { +device.data.memory = def-mems[i]; +if (cb(def, device, def-mems[i]-info, opaque) 0) +return -1; +} + /* Coverity is not very happy with this - all dead_error_condition */
[libvirt] [PATCH] qemu: Properly report error when cookin uuid not match the ctxt uuid
Add the missing jump to the error label when cookin uuid does not match the ctxt uuid. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_migration.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 8a8fa63..879b1bf 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1147,6 +1147,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, virReportError(VIR_ERR_INTERNAL_ERROR, _(Incoming cookie data had unexpected UUID %s vs %s), tmp, uuidstr); +goto error; } VIR_FREE(tmp); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list