Re: [libvirt] [PATCH 2/2] mdev: Fix daemon crash on domain shutdown after reconnect

2017-05-03 Thread Erik Skultety
On Wed, May 03, 2017 at 11:25:30AM -0400, Laine Stump wrote:
> On 04/28/2017 03:46 AM, Erik Skultety wrote:
> > The problem resides in virHostdevUpdateActiveMediatedDevices which gets
> > called during qemuProcessReconnect. The issue here is that
> > virMediatedDeviceListAdd takes a pointer to the item to be added to the
> > list to which VIR_APPEND_ELEMENT is used, which also clears the pointer.
> > However, in this case only the local copy of the pointer got cleared,
> > leaving the original pointing to valid memory. To sum it up, during
> > cleanup phase, the original pointer is freed and the daemon crashes
> > basically any time it would access it.
> >
> > Backtrace:
> > 0x73ccdeba in __strcmp_sse2_unaligned
> > 0x772a444a in virMediatedDeviceListFindIndex
> > 0x77241446 in virHostdevReAttachMediatedDevices
> > 0x7fffc60215d9 in qemuHostdevReAttachMediatedDevices
> > 0x7fffc60216dc in qemuHostdevReAttachDomainDevices
> > 0x7fffc6046e6f in qemuProcessStop
> > 0x7fffc6091596 in processMonitorEOFEvent
> > 0x7fffc6091793 in qemuProcessEventHandler
> > 0x77294bf5 in virThreadPoolWorker
> > 0x77294184 in virThreadHelper
> > 0x73fdc3c4 in start_thread () from /lib64/libpthread.so.0
> > 0x73d269cf in clone () from /lib64/libc.so.6
> >
> > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446455
> >
> > Signed-off-by: Erik Skultety 
>
> Reviewed-by: Laine Stump 
>
> or ACK, or whatever is the new accepted hotness.

Thanks, I pushed them both to master and v3.2-maint.
Erik

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] 答复: Re: 答复: Re: [PATCH] qemu: change the name of tap device for a tapand bridge network

2017-05-03 Thread Laine Stump
(Please don't top-post replies. ALso, I added libvir-list back to the To:)

On 05/03/2017 08:46 PM, lu.zhip...@zte.com.cn wrote:
> 
> Some other scenarios such as migration. 
> 
> Can we guarantee that the network card driver has been
> closed before  killing QEMU ?

During a migration, before we ever get to the point of killing the
source qemu process, we have already stopped the guest CPUs and made
sure that the entire state of the guest has been transferred to the qemu
process on the destination host. It doesn't matter if we detach the tap
device from the bridge or not - any traffic received on the source host
during that time (after stopping the guest CPUs) will be dropped (and
re-transmitted + received by the guest after it starts running on the
destination).

Since the guest CPU is already stopped on the source, and the guest on
the destination already has the full state of the guest ready to start
up (and will not receive any new updates), keeping the tap device
connected to the bridge for a small fraction of a second is not going to
make any difference at all.

Is that convincing enough? :-)

> 
> if we are sure,that's ok
> 
> 
> 
> 
> 
> *为了让您的VPlat虚拟化故障得到高效的处理,请上报故障到: $VPlat技术支持。*
> 
> 芦志朋 luzhipeng
> 
> 
> IT开发工程师 IT Development Engineer
> 操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D
> Institute/System Product
> 
> 
>   
> 深圳市南山区科技南路55号中兴通讯研发大楼33楼
> 33/F, R&D Building, ZTE Corporation Hi-tech Road South,
> Hi-tech Industrial Park Nanshan District, Shenzhen, P.R.China, 518057
> T: +86 755  F:+86 755 
> M: +86 xxx
> E: lu.zhip...@zte.com.cn
> www.zte.com.cn 
> 
> 原始邮件
> *发件人:*<la...@laine.org>;
> *收件人:*芦志朋10108272;
> *日 期 :*2017年05月04日 08:31
> *主 题 :**Re: 答复: Re: [libvirt] [PATCH] qemu: change the name of tap
> device for a tapand bridge network*
> 
> 
> 
> 
> On May 3, 2017 8:28 PM,  <lu.zhip...@zte.com.cn
> > wrote:
> 
> 
> I'm worried that the network packet loss rate will increase after
>  reversing the order.
> 
> 
> Why? The guest is already shut down (or being shut down). By this time
> there is no traffic that would make any difference. And anyway, we've
> already determined that the current order causes a race so it is wrong.
> 
> 
> 
> 
> 
> *为了让您的VPlat虚拟化故障得到高效的处理,请上报故障到: $VPlat技术支
> 持。*
> 
> 芦志朋 luzhipeng
> 
> 
> IT开发工程师 IT Development Engineer
> 操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D
> Institute/System Product
> 
> 
>   
> 深圳市南山区科技南路55号中兴通讯研发大楼33楼
> 33/F, R&D Building, ZTE Corporation Hi-tech Road South,
> Hi-tech Industrial Park Nanshan District, Shenzhen, P.R.China, 518057
> T: +86 755  F:+86 755 
> M: +86 xxx
> E: lu.zhip...@zte.com.cn 
> www.zte.com.cn 
> 
> 原始邮件
> *发件人:*<berra...@redhat.com >;
> *收件人:*<la...@laine.org >;
> *抄送人:*<libvir-list@redhat.com  l...@redhat.com>>;芦志朋10108272;
> *日 期 :*2017年05月02日 16:30
> *主 题 :**Re: [libvirt] [PATCH] qemu: change the name of tap device
> for a tapand bridge network*
> 
> 
> On Fri, Apr 28, 2017 at 01:08:45PM -0400, Laine Stump wrote:
> > On 04/28/2017 05:33 AM, Daniel P. Berrange wrote:
> > > On Fri, Apr 28, 2017 at 05:23:19PM +0800, ZhiPeng Lu wrote:
> > >> Creating tap device and adding the device to bridge are not atomic 
> operation.
> > >> Similarly deleting tap device and removing it from bridge are not 
> atomic operation.
> > >> The Problem occurs when two vms start and shutdown. When one vm with 
> the nic
> > >> named "vnet0" stopping, it deleted tap device but not removing port 
> from bridge.
> > >> At this time, another vm created the tap device named "vnet0" and 
> added port to the
> > >> same bridge. Then, the first vm deleted the tap device from the same 
> bridge.
> > >> Finally, the tap device of the second vm don't attached to the 
> bridge.
> > >> So, we can add domid to vm's nic name. For example, the vm's domid 
> is 1 and vnet0
> > >> is renamed to vnet1.0.
> > > 
> > > Surely deleting the NIC automatically removes it from the bridge so we
> > > can just remove the code that delets the bridge port.
> > 
> > That is true when using a Linux host bridge, but I recall that for
> > openvswitch (which I think is what ZhiPeng is using, based on an earlier
> > patch), you must explicitly remove the port from the bridge - apparently
> > the port is still there in openvswitch's table as some sort of "zombie"
> > connection even after the tap device itself no longer exists.
> > 
> > 
> > But instead of changing the naming scheme, maybe we should just delete
> > the bridge port *before* deleting the tap device instead of after. (Am I
> > recalling correctly that the tap device is deleted autom

[libvirt] 答复: Re: [PATCH] qemu: change the name of tap device for a tapand bridge network

2017-05-03 Thread lu.zhipeng
I'm worried that the network packet loss rate will increase after  reversing 
the order.
















为了让您的VPlat虚拟化故障得到高效的处理,请上报故障到: $VPlat技术支持。


芦志朋 luzhipeng






IT开发工程师 IT Development
Engineer
操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D Institute/System Product









深圳市南山区科技南路55号中兴通讯研发大楼33楼 
33/F, R&D Building, ZTE
Corporation Hi-tech Road South, 
Hi-tech
Industrial Park Nanshan District, Shenzhen, P.R.China, 518057 
T: +86 755  F:+86 755  
M: +86 xxx 
E: lu.zhip...@zte.com.cn 
www.zte.com.cn






原始邮件



发件人: <berra...@redhat.com>
收件人: <la...@laine.org>
抄送人: <libvir-list@redhat.com>芦志朋10108272
日 期 :2017年05月02日 16:30
主 题 :Re: [libvirt] [PATCH] qemu: change the name of tap device for a tapand 
bridge network





On Fri, Apr 28, 2017 at 01:08:45PM -0400, Laine Stump wrote:
> On 04/28/2017 05:33 AM, Daniel P. Berrange wrote:
> > On Fri, Apr 28, 2017 at 05:23:19PM +0800, ZhiPeng Lu wrote:
> >> Creating tap device and adding the device to bridge are not atomic 
operation.
> >> Similarly deleting tap device and removing it from bridge are not atomic 
operation.
> >> The Problem occurs when two vms start and shutdown. When one vm with the 
nic
> >> named "vnet0" stopping, it deleted tap device but not removing port from 
bridge.
> >> At this time, another vm created the tap device named "vnet0" and added 
port to the
> >> same bridge. Then, the first vm deleted the tap device from the same 
bridge.
> >> Finally, the tap device of the second vm don't attached to the bridge.
> >> So, we can add domid to vm's nic name. For example, the vm's domid is 1 
and vnet0
> >> is renamed to vnet1.0.
> > 
> > Surely deleting the NIC automatically removes it from the bridge so we
> > can just remove the code that delets the bridge port.
> 
> That is true when using a Linux host bridge, but I recall that for
> openvswitch (which I think is what ZhiPeng is using, based on an earlier
> patch), you must explicitly remove the port from the bridge - apparently
> the port is still there in openvswitch's table as some sort of "zombie"
> connection even after the tap device itself no longer exists.
> 
> 
> But instead of changing the naming scheme, maybe we should just delete
> the bridge port *before* deleting the tap device instead of after. (Am I
> recalling correctly that the tap device is deleted automatically when
> the qemu process is killed? If so, then what's needed is to move the
> loop in qemuProcessStop() that cleans up network interfaces so that it
> happens before qemuProcessKill() is called.

Agreed, we should just reverse the order.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2 08/38] util: Introduce virFileInData

2017-05-03 Thread John Ferlan


On 04/30/2017 02:43 AM, Michal Privoznik wrote:
> On 04/29/2017 06:46 PM, John Ferlan wrote:
>>
>>
>> On 04/20/2017 06:01 AM, Michal Privoznik wrote:
>>> This function takes a FD and determines whether the current
>>> position is in data section or in a hole. In addition to that,
>>> it also determines how much bytes are there remaining till the
>>> current section ends.
>>>
>>> Signed-off-by: Michal Privoznik 
>>> ---
>>>  src/libvirt_private.syms |   1 +
>>>  src/util/virfile.c   |  81 +++
>>>  src/util/virfile.h   |   3 +
>>>  tests/virfiletest.c  | 203 
>>> +++
>>>  4 files changed, 288 insertions(+)
>>>
>>
>> FWIW: This feels like an "inflection point" from which the remainder of
>> the algorithms are built around. I've forgotten anything from the
>> discussion for the original set of patches, but since I had a few cycles
>> to think... Apologies in advance for the length.
>>
>> I guess I was under the impression that the purpose for sparse streams
>> is to find hole's in a file|stream and ensure those don't get copied
>> instead generating the hole on the target. If so, a bunch of different
>> small API's come to mind after reading this patch and trying to
>> internalize what's taking place:
>>
>> vir{File|Stream}SeekHoleSupported
>>   -> If SEEK_{DATA|HOLE} returns -1 and EINVAL, then either don't
>> use sparse streams and force usage of the non sparse option or just fail.
> 
> We shouldn't fail. All the tools that I've seen and do support sparse
> files do accept fully allocated files gracefully, e.g. cp --sparse
> allways or rsync -S. I mean, even though this function you're suggesting
> here would fail or something, the whole stream transmission should just
> carry on.
> 

My "default" thought was, if sparse wasn't supported, then fallback to
full copy; however, someone else may say no I don't want that. If I had
a 100G file I knew was sparse, I'm not sure I would want that fallback
to full copy!

>>
>> vir{File|Stream}HasHole
>>   -> From beginning of file, find first HOLE < EOF
>>  -> If none, then sparse streams won't matter, right?
> 
> No. I will not. But it doesn't matter if the first hole is at EOF or
> before it, if we know how to transfer holes effectively.
> 
>>
>> vir{File|Stream}IsInHole
>>   -> From @cur if SEEK_DATA > SEEK_HOLE
>>
>> vir{File|Stream}IsInData
>>   -> From @cur if SEEK_HOLE > SEEK_DATA
>>
>> vir{File|Stream}GetDataEnd
>>   -> From @cur of DATA return @length
>>
>> vir{File|Stream}GetHoleEnd
>>   -> From @cur of HOLE return @length
>>
>> We should know where we are and be able to keep track, right? Having to
>> determine @cur each time just seems to be overhead. 
> 
> Firstly, this is merely what I'm implementing later in the series (see
> patch 33/38 [and I just realized that due to a mistake patch 34/38 has
> wrong commit message]).

Yes, I need to get further in the series, but I'm also easily distracted
by external forces.

> Secondly, getting current position in a file should be as quick as this
> (imagine me snapping my fingers :-)). The VFS has to keep track of the
> current position in a file for sake of all file operations. /me goes and
> looks into kernel sources... Yep, it looks like so:
> generic_file_llseek() from fs/read_write.c. But the main point is ..
> 
>> For the purpose of
>> what's being done - I would think we start at 0 and know we have a
>> findable @end - then it would be "just" (hah!) a matter of ensuring we
>> have holes and then a sequence of finding hole/data from whence we start
>> (since theoretically we could start in a hole, right?).
>>
>> Maybe the following is too simplistic...
>>
>>if (supportsSparse)
>>if ((cur = lseek(fd, 0, SEEK_SET)) != 0)
>>goto error;
>>
>>if (!hasHoles)
>>return fullCopy? (although I think the rest would still work)
>>
>>if ((end = lseek(fd, 0, SEEK_END)) < 0)
>>goto error;
>>
>>inHole = virFile|StreamIsInHole(fd, cur)
>>while (cur < end)
>>if (inHole)
>> get size of hole
>> if ret < 0, then size would be end-cur, right?
>> update remote to write hole
>> update cur to include size of hole
>>else /* assume? in data */
>> get size of data
>> if ret < 0, then size would be end-cur, right?
>> update remote to include data
>> update cur to include size of data
> 
> ... that here, in this branch, we should send the data from the data
> section to client, right? But how can we do that if we lseek()-ed away
> (to the end of the section)?. I mean virFileStreamIsInHole() would need
> to seek back to the original current position in the file anyway. Just
> like virFileInData() does. Otherwise, if a file is in data section we
> would not read it.
> 

OK fair enough. 

Re: [libvirt] [PATCH v1] libxl: report numa sibling distances on host capabilities

2017-05-03 Thread Jim Fehlig
Wim Ten Have wrote:
> From: Wim ten Have 
> 
> When running on a NUMA machine, populate the sibling node
> and distance information using data supplied by Xen.
> 
> With locality distances information, under Xen, new host
> capabilities would like:
> 
> 
>   
> 
>   263902380
>   
> 
> 
>   
> ...
>   
>   ...
>   
>   ...
> 
> 
> Signed-off-by: Wim ten Have 
> ---
>  src/libxl/libxl_capabilities.c | 20 ++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
> index 839a2ee..1702ecb 100644
> --- a/src/libxl/libxl_capabilities.c
> +++ b/src/libxl/libxl_capabilities.c
> @@ -247,8 +247,9 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
>  {
>  libxl_numainfo *numa_info = NULL;
>  libxl_cputopology *cpu_topo = NULL;
> -int nr_nodes = 0, nr_cpus = 0;
> +int nr_nodes = 0, nr_cpus = 0, nr_siblings = 0;
>  virCapsHostNUMACellCPUPtr *cpus = NULL;
> +virCapsHostNUMACellSiblingInfoPtr siblings = NULL;
>  int *nr_cpus_node = NULL;
>  size_t i;
>  int ret = -1;
> @@ -322,10 +323,24 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
>  if (numa_info[i].size == LIBXL_NUMAINFO_INVALID_ENTRY)
>  continue;
>  
> +#ifdef LIBXL_HAVE_VNUMA

AFAICT, this is not dependent on LIBXL_HAVE_VNUMA. The libxl_numainfo struct,
including dists and num_dists fields, was introduced in commit 97467ae4a04.

$ git describe --contains 97467ae4a04
4.2.2-rc1~433

Indeed I removed it and successfully built the patch on Xen 4.4.

Looks good otherwise, thanks!

Regards,
Jim

> +nr_siblings = numa_info[i].num_dists;
> +if (nr_siblings) {
> +size_t j;
> +
> +if (VIR_ALLOC_N(siblings, nr_siblings) < 0)
> +goto cleanup;
> +
> +for (j = 0; j < nr_siblings; j++) {
> +siblings[j].node = j;
> +siblings[j].distance = numa_info[i].dists[j];
> +}
> +}
> +#endif
>  if (virCapabilitiesAddHostNUMACell(caps, i,
> numa_info[i].size / 1024,
> nr_cpus_node[i], cpus[i],
> -   0, NULL,
> +   nr_siblings, siblings,
> 0, NULL) < 0) {
>  virCapabilitiesClearHostNUMACellCPUTopology(cpus[i],
>  nr_cpus_node[i]);
> @@ -343,6 +358,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
>  for (i = 0; cpus && i < nr_nodes; i++)
>  VIR_FREE(cpus[i]);
>  virCapabilitiesFreeNUMAInfo(caps);
> +VIR_FREE(siblings);
>  }
>  
>  VIR_FREE(cpus);

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 3/2] news: Add even more v3.3.0 entries

2017-05-03 Thread Ján Tomko

On Wed, May 03, 2017 at 06:03:23PM +0200, Andrea Bolognani wrote:

---
docs/news.xml | 10 ++
1 file changed, 10 insertions(+)

diff --git a/docs/news.xml b/docs/news.xml
index 8f6b768..593cc52 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -176,6 +176,16 @@
  qemu: Do not crash on USB address with no port and invalid bus

  
+  
+
+  crypto: Always pad data before encrypting it
+
+
+  If this step is not performed, when the data length matches the
+  chunk size the decryption routines will misinterpret the last byte
+  of data as the padding lenght and fail to decode it correctly.


s/lenght/length/

ACK with that fixed

I make no statement regarding its eligibility for the freeze (except
this one).

Jan


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/2] news: Add more v3.3.0 entries

2017-05-03 Thread Andrea Bolognani
On Wed, 2017-05-03 at 17:25 +0200, Ján Tomko wrote:
> > > Rather than this I'd mention the bug in the padding of data passed to
> > > qemu: 71890992daf37ec78b00b4ce873369421dc99731
> > 
> > Why not both? :)
> > 
> > However, I'm unable to find that commit in either libvirt's
> > or QEMU's git repositories, are you sure it's correct? If
> > you can point me to it I can definitely add an entry for it.
> 
> commit 71890992daf37ec78b00b4ce873369421dc99731
> Author: Daniel P. Berrange 
> AuthorDate: 2017-05-02 11:32:43 +0100
> Commit: Daniel P. Berrange 
> CommitDate: 2017-05-02 17:27:13 +0100
> 
> Fix padding of encrypted data
> 
> git describe: v3.3.0-rc1-3-g7189099 contains: v3.3.0-rc2~2
> 
> http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=71890992daf37ec78b00b4ce873369421dc99731

Yeah, apparently I had merely failed to fetch :/

I've posted patch 3/2, which adds an entry for that change.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 3/2] news: Add even more v3.3.0 entries

2017-05-03 Thread Andrea Bolognani
---
 docs/news.xml | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/docs/news.xml b/docs/news.xml
index 8f6b768..593cc52 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -176,6 +176,16 @@
   qemu: Do not crash on USB address with no port and invalid bus
 
   
+  
+
+  crypto: Always pad data before encrypting it
+
+
+  If this step is not performed, when the data length matches the
+  chunk size the decryption routines will misinterpret the last byte
+  of data as the padding lenght and fail to decode it correctly.
+
+  
 
   
   
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/2] util: mdev: Use a local variable instead of an invalid pointer reference

2017-05-03 Thread Pavel Hrdina
On Wed, May 03, 2017 at 05:35:47PM +0200, Pavel Hrdina wrote:
> On Fri, Apr 28, 2017 at 09:46:32AM +0200, Erik Skultety wrote:
> > virMediatedDeviceListAdd calls VIR_APPEND_ELEMENT which normally clears
> > the element to be added, thus the pointer must not be used afterwards,
> > but because the pointer here is passed by value, what gets cleared is
> > a copy of the original pointer that got created on the stack
> > automatically when calling the function. The fact that it works now is
> > just a coincidence and a bug in virMediatedDeviceListAdd that needs to
> > be fixed in a separate commit. Therefore, use a local variable to hold
> > data, rather than accessing the pointer later.
> 
> I don't thing that this patch is required.  What happens here is that
> in this function we get a pointer to an existing memory that stores
> virMediatedDevice, if the mdev is not used we mark it as used and store
> that pointer to *dst* list. That's what virMediatedDeviceListAdd does,
> it only stores the pointer to an allocated into the list so it doesn't
> clear the real data, it only operates with pointers.  This means that
> the memory addressed by local *mdev* variable still points to a
> valid memory and everything is OK, there is no issue at all apart
> from a fact, that setting the pointer in virMediatedDeviceListAdd
> is pointless.
> 
> Pavel

After reading the second patch, this one will be required, however
I would change the commit message because there is no issue right
now, this change is only necessary for the following patch.

Pavel

> 
> > Signed-off-by: Erik Skultety 
> > ---
> >  src/util/virmdev.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/util/virmdev.c b/src/util/virmdev.c
> > index 2a1ade739..c1499d238 100644
> > --- a/src/util/virmdev.c
> > +++ b/src/util/virmdev.c
> > @@ -447,20 +447,21 @@ 
> > virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
> >  virObjectLock(dst);
> >  for (i = 0; i < count; i++) {
> >  virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
> > +const char *mdev_path = mdev->path;
> >  
> >  if (virMediatedDeviceIsUsed(mdev, dst) ||
> >  virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
> >  goto cleanup;
> >  
> >  /* Copy mdev references to the driver list:
> > - * - caller is responsible for NOT freeing devices in @list on 
> > success
> > + * - caller is responsible for NOT freeing devices in @src on 
> > success
> >   * - we're responsible for performing a rollback on failure
> >   */
> >  if (virMediatedDeviceListAdd(dst, mdev) < 0)
> >  goto rollback;
> >  
> >  VIR_DEBUG("'%s' added to list of active mediated devices used by 
> > '%s'",
> > -  mdev->path, domname);
> > +  mdev_path, domname);
> >  }
> >  
> >  ret = 0;
> > -- 
> > 2.12.2
> > 
> > --
> > libvir-list mailing list
> > libvir-list@redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list



> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list



signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/2] util: mdev: Use a local variable instead of an invalid pointer reference

2017-05-03 Thread Pavel Hrdina
On Fri, Apr 28, 2017 at 09:46:32AM +0200, Erik Skultety wrote:
> virMediatedDeviceListAdd calls VIR_APPEND_ELEMENT which normally clears
> the element to be added, thus the pointer must not be used afterwards,
> but because the pointer here is passed by value, what gets cleared is
> a copy of the original pointer that got created on the stack
> automatically when calling the function. The fact that it works now is
> just a coincidence and a bug in virMediatedDeviceListAdd that needs to
> be fixed in a separate commit. Therefore, use a local variable to hold
> data, rather than accessing the pointer later.

I don't thing that this patch is required.  What happens here is that
in this function we get a pointer to an existing memory that stores
virMediatedDevice, if the mdev is not used we mark it as used and store
that pointer to *dst* list. That's what virMediatedDeviceListAdd does,
it only stores the pointer to an allocated into the list so it doesn't
clear the real data, it only operates with pointers.  This means that
the memory addressed by local *mdev* variable still points to a
valid memory and everything is OK, there is no issue at all apart
from a fact, that setting the pointer in virMediatedDeviceListAdd
is pointless.

Pavel

> Signed-off-by: Erik Skultety 
> ---
>  src/util/virmdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/virmdev.c b/src/util/virmdev.c
> index 2a1ade739..c1499d238 100644
> --- a/src/util/virmdev.c
> +++ b/src/util/virmdev.c
> @@ -447,20 +447,21 @@ 
> virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
>  virObjectLock(dst);
>  for (i = 0; i < count; i++) {
>  virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
> +const char *mdev_path = mdev->path;
>  
>  if (virMediatedDeviceIsUsed(mdev, dst) ||
>  virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
>  goto cleanup;
>  
>  /* Copy mdev references to the driver list:
> - * - caller is responsible for NOT freeing devices in @list on 
> success
> + * - caller is responsible for NOT freeing devices in @src on success
>   * - we're responsible for performing a rollback on failure
>   */
>  if (virMediatedDeviceListAdd(dst, mdev) < 0)
>  goto rollback;
>  
>  VIR_DEBUG("'%s' added to list of active mediated devices used by 
> '%s'",
> -  mdev->path, domname);
> +  mdev_path, domname);
>  }
>  
>  ret = 0;
> -- 
> 2.12.2
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/2] util: mdev: Use a local variable instead of an invalid pointer reference

2017-05-03 Thread Laine Stump
On 04/28/2017 03:46 AM, Erik Skultety wrote:
> virMediatedDeviceListAdd calls VIR_APPEND_ELEMENT which normally clears
> the element to be added, thus the pointer must not be used afterwards,
> but because the pointer here is passed by value, what gets cleared is
> a copy of the original pointer that got created on the stack
> automatically when calling the function. The fact that it works now is
> just a coincidence and a bug in virMediatedDeviceListAdd that needs to
> be fixed in a separate commit. Therefore, use a local variable to hold
> data, rather than accessing the pointer later.
> 
> Signed-off-by: Erik Skultety 

Reviewed-by: Laine Stump 


(Oh, and "safe for freeze", in case that wasn't assumed. Same goes for 2/2)

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/2] mdev: Fix daemon crash on domain shutdown after reconnect

2017-05-03 Thread Laine Stump
On 04/28/2017 03:46 AM, Erik Skultety wrote:
> The problem resides in virHostdevUpdateActiveMediatedDevices which gets
> called during qemuProcessReconnect. The issue here is that
> virMediatedDeviceListAdd takes a pointer to the item to be added to the
> list to which VIR_APPEND_ELEMENT is used, which also clears the pointer.
> However, in this case only the local copy of the pointer got cleared,
> leaving the original pointing to valid memory. To sum it up, during
> cleanup phase, the original pointer is freed and the daemon crashes
> basically any time it would access it.
> 
> Backtrace:
> 0x73ccdeba in __strcmp_sse2_unaligned
> 0x772a444a in virMediatedDeviceListFindIndex
> 0x77241446 in virHostdevReAttachMediatedDevices
> 0x7fffc60215d9 in qemuHostdevReAttachMediatedDevices
> 0x7fffc60216dc in qemuHostdevReAttachDomainDevices
> 0x7fffc6046e6f in qemuProcessStop
> 0x7fffc6091596 in processMonitorEOFEvent
> 0x7fffc6091793 in qemuProcessEventHandler
> 0x77294bf5 in virThreadPoolWorker
> 0x77294184 in virThreadHelper
> 0x73fdc3c4 in start_thread () from /lib64/libpthread.so.0
> 0x73d269cf in clone () from /lib64/libc.so.6
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446455
> 
> Signed-off-by: Erik Skultety 

Reviewed-by: Laine Stump 

or ACK, or whatever is the new accepted hotness.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/2] news: Add more v3.3.0 entries

2017-05-03 Thread Ján Tomko

On Wed, May 03, 2017 at 05:11:29PM +0200, Andrea Bolognani wrote:

On Wed, 2017-05-03 at 09:19 +0200, Peter Krempa wrote:

> +
> +  storage: Fix capacity value for LUKS encrypted volumes
> +
> +
> +  The 'capacity' value (e.g. guest logical size) for a LUKS volume is
> +  smaller than the 'physical' value of the file in the file system, 
so
> +  we need to account for that.
> +
 
Rather than this I'd mention the bug in the padding of data passed to
qemu: 71890992daf37ec78b00b4ce873369421dc99731


Why not both? :)

However, I'm unable to find that commit in either libvirt's
or QEMU's git repositories, are you sure it's correct? If
you can point me to it I can definitely add an entry for it.



commit 71890992daf37ec78b00b4ce873369421dc99731
Author: Daniel P. Berrange 
AuthorDate: 2017-05-02 11:32:43 +0100
Commit: Daniel P. Berrange 
CommitDate: 2017-05-02 17:27:13 +0100

   Fix padding of encrypted data

git describe: v3.3.0-rc1-3-g7189099 contains: v3.3.0-rc2~2

http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=71890992daf37ec78b00b4ce873369421dc99731

Jan


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/2] news: Add more v3.3.0 entries

2017-05-03 Thread Andrea Bolognani
On Wed, 2017-05-03 at 09:19 +0200, Peter Krempa wrote:
> > +
> > +  storage: Fix capacity value for LUKS encrypted volumes
> > +
> > +
> > +  The 'capacity' value (e.g. guest logical size) for a LUKS volume 
> > is
> > +  smaller than the 'physical' value of the file in the file 
> > system, so
> > +  we need to account for that.
> > +
> 
> Rather than this I'd mention the bug in the padding of data passed to
> qemu: 71890992daf37ec78b00b4ce873369421dc99731

Why not both? :)

However, I'm unable to find that commit in either libvirt's
or QEMU's git repositories, are you sure it's correct? If
you can point me to it I can definitely add an entry for it.

> > +
> > +  virsh: Report initialization errors
> > +
> > +
> > +  Sometimes virsh might be unable to start: when that happens, 
> > report
> > +  useful diagnostics instead of failing silently.
> 
> This does not seem to be a bugfix, but rather an improvement.

I've moved it and pushed the series.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] Availability of Candidate Release 2 of libvirt-3.3.0

2017-05-03 Thread Daniel Veillard

  Due to some Red Hat Summit event, I got severely distracted yesterday and
forgot to tag RC2, this is now done, there is signed tarball and rpms at
the usual place:

   ftp://libvirt.org/libvirt/


 Things seems to look fine, there is relatively few changes from RC1,
but so far I didn;t heard any feedback on RC1, is that a good thing :-) ?

  So please give it a try, and I will try to push the final release
on Friday,

   sorry for the delay,

Daniel

-- 
Daniel Veillard  | Red Hat Developers Tools http://developer.redhat.com/
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/1] vz: minor cleanup in prlsdkDomainSetUserPassword

2017-05-03 Thread Nikolay Shirokovskiy


On 03.05.2017 13:44, Konstantin Neumoin wrote:
> No need begin job for asynchronous operation.
> 
> Signed-off-by: Konstantin Neumoin 
> ---
>  src/vz/vz_sdk.c | 16 ++--
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index 138aea3..bc1a9eb 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -3926,30 +3926,18 @@ prlsdkDomainSetUserPassword(virDomainObjPtr dom,
>  const char *user,
>  const char *password)
>  {
> -int ret = -1;
>  vzDomObjPtr privdom = dom->privateData;
>  PRL_HANDLE job = PRL_INVALID_HANDLE;
>  
> -job = PrlVm_BeginEdit(privdom->sdkdom);
> -if (PRL_FAILED(waitDomainJob(job, dom)))
> -goto cleanup;
> -
>  job = PrlVm_SetUserPasswd(privdom->sdkdom,
>user,
>password,
>0);
>  
>  if (PRL_FAILED(waitDomainJob(job, dom)))
> -goto cleanup;
> -
> -job = PrlVm_CommitEx(privdom->sdkdom, 0);
> -if (PRL_FAILED(waitDomainJob(job, dom)))
> -goto cleanup;
> -
> -ret = 0;
> +return -1;
>  
> - cleanup:
> -return ret;
> +return 0;
>  }
>  
>  static int
> 

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/1] vz: fix raise in vzDomainBlock

2017-05-03 Thread Konstantin Neumoin

On 05/03/2017 05:10 PM, Nikolay Shirokovskiy wrote:


On 03.05.2017 13:44, Konstantin Neumoin wrote:

Need begin job before lookup disk in config,
because it can be edited at this moment.

I would slightly change commit message to something like:

OK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/1] vz: fix raise in vzDomainBlock

2017-05-03 Thread Nikolay Shirokovskiy


On 03.05.2017 13:44, Konstantin Neumoin wrote:
> Need begin job before lookup disk in config,
> because it can be edited at this moment.

I would slightly change commit message to something like:

Put domain access after acquiring job condition, otherwise
another job can change it meanwhile.

Otherwise ACK.

> 
> Signed-off-by: Konstantin Neumoin 
> ---
>  src/vz/vz_driver.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
> index 8f94326..954ca6a 100644
> --- a/src/vz/vz_driver.c
> +++ b/src/vz/vz_driver.c
> @@ -4000,12 +4000,6 @@ vzDomainBlockResize(virDomainPtr domain,
>  size /= 1024;
>  size /= 1024;
>  
> -if (!(disk = virDomainDiskByName(dom->def, path, false))) {
> -virReportError(VIR_ERR_INVALID_ARG,
> -   _("invalid path: %s"), path);
> -goto cleanup;
> -}
> -
>  if (vzDomainObjBeginJob(dom) < 0)
>  goto cleanup;
>  job = true;
> @@ -4019,6 +4013,12 @@ vzDomainBlockResize(virDomainPtr domain,
>  goto cleanup;
>  }
>  
> +if (!(disk = virDomainDiskByName(dom->def, path, false))) {
> +virReportError(VIR_ERR_INVALID_ARG,
> +   _("invalid path: %s"), path);
> +goto cleanup;
> +}
> +
>  ret = prlsdkResizeImage(dom, disk, size);
>  
>   cleanup:
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv4 6/6] qemu: format caching-mode on iommu command line

2017-05-03 Thread Ján Tomko
Format the caching-mode option for the intel-iommu device,
based on its  attribute value.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 src/qemu/qemu_capabilities.c   |  2 ++
 src/qemu/qemu_capabilities.h   |  1 +
 src/qemu/qemu_command.c| 11 ++
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
 .../qemuxml2argv-intel-iommu-caching-mode.args | 25 ++
 tests/qemuxml2argvtest.c   | 11 ++
 6 files changed, 51 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 8458a29..9d50389 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -370,6 +370,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "kernel-irqchip", /* 255 */
   "kernel-irqchip.split",
   "intel-iommu.intremap",
+  "intel-iommu.caching-mode",
 );
 
 
@@ -1723,6 +1724,7 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsObjectPropsUSBNECXHCI[] = {
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
 { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
+{ "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
 };
 
 /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2810513..aa99fda 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -408,6 +408,7 @@ typedef enum {
 QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
 QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
 QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
+QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, /* intel-iommu.caching-mode */
 
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f162e0a..d8d0dea 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6694,6 +6694,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
  "with this QEMU binary"));
 return -1;
 }
+if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT &&
+!virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_CACHING_MODE))  {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("iommu: caching mode is not supported "
+ "with this QEMU binary"));
+return -1;
+}
 break;
 case VIR_DOMAIN_IOMMU_MODEL_LAST:
 break;
@@ -6723,6 +6730,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
 virBufferAsprintf(&opts, ",intremap=%s",
   virTristateSwitchTypeToString(iommu->intremap));
 }
+if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
+virBufferAsprintf(&opts, ",caching-mode=%s",
+  
virTristateSwitchTypeToString(iommu->caching_mode));
+}
 case VIR_DOMAIN_IOMMU_MODEL_LAST:
 break;
 }
diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml 
b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
index 0f273d6..19fe4b7 100644
--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
@@ -213,6 +213,7 @@
   
   
   
+  
   2009000
   0
(v2.9.0)
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args 
b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
new file mode 100644
index 000..1bec6d0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
@@ -0,0 +1,25 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name QEMUGuest1 \
+-S \
+-machine q35,accel=tcg \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device intel-iommu,intremap=on,caching-mode=on \
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
+-device ich9-usb-ehci1,id=usb,bus=pci.2,addr=0x2.0x7 \
+-device rtl8139,vlan=0,id=net0,mac=52:54:00:ab:0c:5c,bus=pci.2,addr=0x1 \
+-net user,vlan=0,name=hostnet0
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a554416..e308ffd 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2515,6 +2515,17 @@ mymain(void)
 QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
 QEMU_CAPS_INTEL_IOMMU_INTREMAP,
 

[libvirt] [PATCHv4 2/6] qemu: format kernel_irqchip on the command line

2017-05-03 Thread Ján Tomko
Add kernel_irqchip=split/on to the QEMU command line
and a capability that looks for it in query-command-line-options
output. For the 'split' option, use a version check
since it cannot be reasonably probed.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 src/qemu/qemu_capabilities.c   |  8 +++
 src/qemu/qemu_capabilities.h   |  4 
 src/qemu/qemu_command.c| 25 ++
 tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |  1 +
 .../caps_2.6.0-gicv2.aarch64.xml   |  2 ++
 .../caps_2.6.0-gicv3.aarch64.xml   |  2 ++
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml  |  2 ++
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |  2 ++
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|  2 ++
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  2 ++
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|  2 ++
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  2 ++
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  2 ++
 .../qemuxml2argv-intel-iommu-ioapic.args   | 19 
 tests/qemuxml2argvtest.c   |  5 +
 20 files changed, 85 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 8bc3ea0..9c08912 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -366,6 +366,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "query-named-block-nodes",
   "cpu-cache",
   "qemu-xhci",
+
+  "kernel-irqchip", /* 255 */
+  "kernel-irqchip.split",
 );
 
 
@@ -3127,6 +3130,7 @@ static struct virQEMUCapsCommandLineProps 
virQEMUCapsCommandLine[] = {
 { "drive", "throttling.bps-total-max-length", 
QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH },
 { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP },
 { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE },
+{ "machine", "kernel_irqchip", QEMU_CAPS_MACHINE_KERNEL_IRQCHIP },
 };
 
 static int
@@ -4739,6 +4743,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
 if (qemuCaps->version >= 2004050)
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION);
 
+/* no way to query if -machine kernel_irqchip supports split */
+if (qemuCaps->version >= 2006000)
+virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT);
+
 if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
 goto cleanup;
 
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 06a43ab..61d3ae2 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -404,6 +404,10 @@ typedef enum {
 QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache 
properties */
 QEMU_CAPS_DEVICE_QEMU_XHCI, /* -device qemu-xhci */
 
+/* 255 */
+QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
+QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
+
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 813a851..2b235c6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7422,6 +7422,31 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
 }
 }
 
+if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == 
VIR_TRISTATE_SWITCH_ON) {
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("I/O APIC tuning is not supported by this "
+ "QEMU binary"));
+goto cleanup;
+}
+switch (def->ioapic) {
+case VIR_DOMAIN_IOAPIC_QEMU:
+if (!virQEMUCapsGet(qemuCaps, 
QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("split I/O APIC is not supported by this "
+ "QEMU binary"));
+goto cleanup;
+}
+virBufferAddLit(&buf, ",kernel_irqchip=split");
+break;
+case VIR_DOMAIN_IOAPIC_KVM:
+virBufferAddLit(&buf, ",kernel_irqchip=on");
+break;
+case VIR_DOMAIN_IOAPIC_LAST:
+break;
+}
+}
+
 virCommandAddArgBuffer(cmd, &buf);
 }
 
diff --git a/tests/qemucapabilitiesdata/caps_

[libvirt] [PATCHv4 5/6] conf: add caching_mode attribute to iommu device

2017-05-03 Thread Ján Tomko
Add a new attribute to control the caching mode.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 docs/formatdomain.html.in  |  9 
 docs/schemas/domaincommon.rng  |  5 +++
 src/conf/domain_conf.c | 24 +--
 src/conf/domain_conf.h |  1 +
 .../qemuxml2argv-intel-iommu-caching-mode.xml  | 50 ++
 .../qemuxml2xmlout-intel-iommu-caching-mode.xml|  1 +
 tests/qemuxml2xmltest.c|  1 +
 7 files changed, 88 insertions(+), 3 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
 create mode 12 
tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index ca98f0e..4552037 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7426,6 +7426,15 @@ qemu-kvm -net nic,model=? /dev/null
   Since 3.4.0 (QEMU/KVM only)
 
   
+  caching_mode
+  
+
+  The caching_mode attribute with possible values
+  on and off can be used to
+  turn on the VT-d caching mode (useful for assigned devices)
+  Since 3.4.0 (QEMU/KVM only)
+
+  
 
   
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 00d9290..f88e84a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3954,6 +3954,11 @@
   
 
   
+  
+
+  
+
+  
 
   
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4eefd92..ef31f4a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14176,6 +14176,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
 iommu->intremap = val;
 }
 
+VIR_FREE(tmp);
+if ((tmp = virXPathString("string(./driver/@caching_mode)", ctxt))) {
+if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
+virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: 
%s"), tmp);
+goto cleanup;
+}
+iommu->caching_mode = val;
+}
+
 ret = iommu;
 iommu = NULL;
 
@@ -24143,9 +24152,18 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
 
 virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
 
-if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
-virBufferAsprintf(&childBuf, "\n",
-  virTristateSwitchTypeToString(iommu->intremap));
+if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT ||
+iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
+virBufferAddLit(&childBuf, "intremap) {
+virBufferAsprintf(&childBuf, " intremap='%s'",
+  virTristateSwitchTypeToString(iommu->intremap));
+}
+if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
+virBufferAsprintf(&childBuf, " caching_mode='%s'",
+  
virTristateSwitchTypeToString(iommu->caching_mode));
+}
+virBufferAddLit(&childBuf, "/>\n");
 }
 
 virBufferAsprintf(buf, "
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-x86_64
+
+
+  
+  
+
+
+  
+  
+  
+
+
+  
+  
+  
+
+
+  
+
+
+  
+
+
+  
+  
+  
+
+
+
+
+
+  
+
+  
+
diff --git 
a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
new file mode 12
index 000..d971a35
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0f00b20..81d8105 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1123,6 +1123,7 @@ mymain(void)
 QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACHINE_IOMMU);
 DO_TEST("intel-iommu-ioapic", NONE);
+DO_TEST("intel-iommu-caching-mode", NONE);
 
 DO_TEST("cpu-check-none", NONE);
 DO_TEST("cpu-check-partial", NONE);
-- 
2.10.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv4 3/6] conf: add to

2017-05-03 Thread Ján Tomko
Add a new attribute to control interrupt remapping.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 docs/formatdomain.html.in  | 24 +-
 docs/schemas/domaincommon.rng  |  9 +
 src/conf/domain_conf.c | 38 +++---
 src/conf/domain_conf.h |  1 +
 .../qemuxml2argv-intel-iommu-ioapic.xml|  4 ++-
 5 files changed, 70 insertions(+), 6 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6669e71..ca98f0e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7395,7 +7395,9 @@ qemu-kvm -net nic,model=? /dev/null
 
 ...
 
-  
+  
+
+  
 
 ...
 
@@ -7406,6 +7408,26 @@ qemu-kvm -net nic,model=? /dev/null
   Currently only the intel model is supported.
 
   
+  driver
+  
+
+  The driver subelement can be used to configure
+  additional options:
+
+
+  intremap
+  
+
+  The intremap attribute with possible values
+  on and off can be used to
+  turn on interrupt remapping, a part of the VT-d functionality.
+  Currently this requires split I/O APIC
+  ()
+  Since 3.4.0 (QEMU/KVM only)
+
+  
+
+  
 
 
 Security label
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 64f718b..00d9290 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3947,6 +3947,15 @@
   
 intel
   
+  
+
+  
+
+  
+
+  
+
+  
 
   
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 29b04d3..4eefd92 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14141,12 +14141,16 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
 
 
 static virDomainIOMMUDefPtr
-virDomainIOMMUDefParseXML(xmlNodePtr node)
+virDomainIOMMUDefParseXML(xmlNodePtr node,
+  xmlXPathContextPtr ctxt)
 {
 virDomainIOMMUDefPtr iommu = NULL, ret = NULL;
+xmlNodePtr save = ctxt->node;
 char *tmp = NULL;
 int val;
 
+ctxt->node = node;
+
 if (VIR_ALLOC(iommu) < 0)
 goto cleanup;
 
@@ -14163,10 +14167,20 @@ virDomainIOMMUDefParseXML(xmlNodePtr node)
 
 iommu->model = val;
 
+VIR_FREE(tmp);
+if ((tmp = virXPathString("string(./driver/@intremap)", ctxt))) {
+if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
+virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), 
tmp);
+goto cleanup;
+}
+iommu->intremap = val;
+}
+
 ret = iommu;
 iommu = NULL;
 
  cleanup:
+ctxt->node = save;
 VIR_FREE(iommu);
 VIR_FREE(tmp);
 return ret;
@@ -14319,7 +14333,7 @@ virDomainDeviceDefParse(const char *xmlStr,
 goto error;
 break;
 case VIR_DOMAIN_DEVICE_IOMMU:
-if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node)))
+if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node, ctxt)))
 goto error;
 break;
 case VIR_DOMAIN_DEVICE_NONE:
@@ -18449,7 +18463,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 }
 
 if (n > 0) {
-if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0])))
+if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0], ctxt)))
 goto error;
 }
 VIR_FREE(nodes);
@@ -24125,8 +24139,24 @@ static void
 virDomainIOMMUDefFormat(virBufferPtr buf,
 const virDomainIOMMUDef *iommu)
 {
-virBufferAsprintf(buf, "\n",
+virBuffer childBuf = VIR_BUFFER_INITIALIZER;
+
+virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
+
+if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
+virBufferAsprintf(&childBuf, "\n",
+  virTristateSwitchTypeToString(iommu->intremap));
+}
+
+virBufferAsprintf(buf, "model));
+if (virBufferUse(&childBuf)) {
+virBufferAddLit(buf, ">\n");
+virBufferAddBuffer(buf, &childBuf);
+virBufferAddLit(buf, "\n");
+} else {
+virBufferAddLit(buf, "/>\n");
+}
 }
 
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 82b4785..8eda516 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2209,6 +2209,7 @@ typedef enum {
 
 struct _virDomainIOMMUDef {
 virDomainIOMMUModel model;
+virTristateSwitch intremap;
 };
 /*
  * Guest VM main configuration
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
index 284d63a..bfe714a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xm

[libvirt] [PATCHv4 0/6] Support more options for intel-iommu

2017-05-03 Thread Ján Tomko
https://bugzilla.redhat.com/show_bug.cgi?id=1427005

v1: https://www.redhat.com/archives/libvir-list/2017-March/msg01072.html
v2: https://www.redhat.com/archives/libvir-list/2017-April/msg00932.html
v3: https://www.redhat.com/archives/libvir-list/2017-April/msg01248.html
new in v4:
  * mention VT-d in the docs
  * rename irqchip mode to ioapic driver
  * rename caching to caching_mode
  * mention intremap's dependency on ioapic in the intermap section
  * add a separate versioned capability for kernel-irqchip=split

Ján Tomko (6):
  conf: add  to 
  qemu: format kernel_irqchip on the command line
  conf: add  to 
  qemu: format intel-iommu,intremap on the command line
  conf: add caching_mode attribute to iommu device
  qemu: format caching-mode on iommu command line

 docs/formatdomain.html.in  | 41 +-
 docs/schemas/domaincommon.rng  | 29 +++
 src/conf/domain_conf.c | 89 --
 src/conf/domain_conf.h | 13 
 src/qemu/qemu_capabilities.c   | 18 +
 src/qemu/qemu_capabilities.h   |  6 ++
 src/qemu/qemu_command.c| 54 +
 tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |  1 +
 tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |  1 +
 .../qemucapabilitiesdata/caps_2.4.0.x86_64.replies | 22 --
 tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |  1 +
 .../qemucapabilitiesdata/caps_2.5.0.x86_64.replies | 24 --
 tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |  1 +
 .../caps_2.6.0-gicv2.aarch64.xml   |  2 +
 .../caps_2.6.0-gicv3.aarch64.xml   |  2 +
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml  |  2 +
 .../qemucapabilitiesdata/caps_2.6.0.x86_64.replies | 24 --
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |  2 +
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|  2 +
 .../qemucapabilitiesdata/caps_2.7.0.x86_64.replies | 28 +--
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  3 +
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|  2 +
 .../qemucapabilitiesdata/caps_2.8.0.x86_64.replies | 37 +++--
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  3 +
 .../qemucapabilitiesdata/caps_2.9.0.x86_64.replies | 49 +---
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  4 +
 .../qemuxml2argv-intel-iommu-caching-mode.args | 25 ++
 .../qemuxml2argv-intel-iommu-caching-mode.xml  | 50 
 .../qemuxml2argv-intel-iommu-ioapic.args   | 19 +
 .../qemuxml2argv-intel-iommu-ioapic.xml| 31 
 tests/qemuxml2argvtest.c   | 17 +
 .../qemuxml2xmlout-intel-iommu-caching-mode.xml|  1 +
 .../qemuxml2xmlout-intel-iommu-ioapic.xml  |  1 +
 tests/qemuxml2xmltest.c|  2 +
 36 files changed, 559 insertions(+), 49 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
 create mode 12 
tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
 create mode 12 
tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml

-- 
2.10.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCHv4 4/6] qemu: format intel-iommu, intremap on the command line

2017-05-03 Thread Ján Tomko
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 src/qemu/qemu_capabilities.c   |  8 
 src/qemu/qemu_capabilities.h   |  1 +
 src/qemu/qemu_command.c| 18 
 .../qemucapabilitiesdata/caps_2.4.0.x86_64.replies | 22 +++---
 .../qemucapabilitiesdata/caps_2.5.0.x86_64.replies | 24 +++
 .../qemucapabilitiesdata/caps_2.6.0.x86_64.replies | 24 +++
 .../qemucapabilitiesdata/caps_2.7.0.x86_64.replies | 28 +
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  1 +
 .../qemucapabilitiesdata/caps_2.8.0.x86_64.replies | 37 
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  1 +
 .../qemucapabilitiesdata/caps_2.9.0.x86_64.replies | 49 ++
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
 .../qemuxml2argv-intel-iommu-ioapic.args   |  2 +-
 tests/qemuxml2argvtest.c   |  1 +
 14 files changed, 173 insertions(+), 44 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9c08912..8458a29 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -369,6 +369,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 
   "kernel-irqchip", /* 255 */
   "kernel-irqchip.split",
+  "intel-iommu.intremap",
 );
 
 
@@ -1720,6 +1721,10 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsObjectPropsUSBNECXHCI[] = {
 { "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS },
 };
 
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
+{ "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
+};
+
 /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
 static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
 { "blockdev-add/arg-type/options/+gluster/debug-level", 
QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
@@ -1827,6 +1832,9 @@ static struct virQEMUCapsObjectTypeProps 
virQEMUCapsObjectProps[] = {
 { "nec-usb-xhci", virQEMUCapsObjectPropsUSBNECXHCI,
   ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI),
   -1 },
+{ "intel-iommu", virQEMUCapsObjectPropsIntelIOMMU,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsIntelIOMMU),
+  QEMU_CAPS_DEVICE_INTEL_IOMMU},
 };
 
 struct virQEMUCapsPropTypeObjects {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 61d3ae2..2810513 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -407,6 +407,7 @@ typedef enum {
 /* 255 */
 QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
 QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
+QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
 
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2b235c6..f162e0a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6685,6 +6685,20 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
 if (!iommu)
 return 0;
 
+switch (iommu->model) {
+case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT &&
+!virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_INTREMAP)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("iommu: interrupt remapping is not supported "
+ "with this QEMU binary"));
+return -1;
+}
+break;
+case VIR_DOMAIN_IOMMU_MODEL_LAST:
+break;
+}
+
 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
 return 0; /* Already handled via -machine */
 
@@ -6705,6 +6719,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
 return -1;
 }
 virBufferAddLit(&opts, "intel-iommu");
+if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
+virBufferAsprintf(&opts, ",intremap=%s",
+  virTristateSwitchTypeToString(iommu->intremap));
+}
 case VIR_DOMAIN_IOMMU_MODEL_LAST:
 break;
 }
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies 
b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
index 6822181..9f256c4 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
@@ -3123,6 +3123,16 @@
 {
   "return": [
 {
+  "name": "version",
+  "type": "uint32"
+}
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+{
   "name": "pc-i440fx-2.4",
   "is-default": true,
   "cpu-max": 255,
@@ -3246,7 +3256,7 @@
   "cpu-max": 255
 }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -3336,21 +3346,21 @@
   "name": "qemu64"
 }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
 "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }

[libvirt] [PATCHv4 1/6] conf: add to

2017-05-03 Thread Ján Tomko
Add a new  element with a driver attribute.

Possible values are qemu and kvm. With 'qemu', the I/O
APIC can be put in the userspace even for KVM domains.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 docs/formatdomain.html.in  |  8 ++
 docs/schemas/domaincommon.rng  | 15 ++
 src/conf/domain_conf.c | 33 +-
 src/conf/domain_conf.h | 11 
 .../qemuxml2argv-intel-iommu-ioapic.xml| 29 +++
 .../qemuxml2xmlout-intel-iommu-ioapic.xml  |  1 +
 tests/qemuxml2xmltest.c|  1 +
 7 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
 create mode 12 
tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8c884f4..6669e71 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1678,6 +1678,7 @@
   
   
   
+  
 
 
 ...
@@ -1839,6 +1840,13 @@
   for hypervisor to decide.
   Since 2.1.0
   
+  ioapic
+  Tune the I/O APIC. Possible values for the
+  driver attribute are:
+  kvm (default for KVM domains)
+  and qemu which puts I/O APIC in userspace.
+  Since 3.4.0 (KVM only)
+  
 
 
 Time keeping
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 281309e..64f718b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4569,6 +4569,9 @@
   
 
   
+  
+
+  
 
   
 
@@ -4747,6 +4750,18 @@
 
   
 
+  
+
+  
+
+  qemu
+  kvm
+
+  
+  
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0ff216e..29b04d3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -141,7 +141,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
   "pmu",
   "vmport",
   "gic",
-  "smm")
+  "smm",
+  "ioapic")
 
 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
   "default",
@@ -859,6 +860,11 @@ VIR_ENUM_IMPL(virDomainLoader,
   "rom",
   "pflash")
 
+VIR_ENUM_IMPL(virDomainIOAPIC,
+  VIR_DOMAIN_IOAPIC_LAST,
+  "qemu",
+  "kvm")
+
 /* Internal mapping: subset of block job types that can be present in
  *  XML (remaining types are not two-phase). */
 VIR_ENUM_DECL(virDomainBlockJob)
@@ -17527,6 +17533,24 @@ virDomainDefParseXML(xmlDocPtr xml,
 ctxt->node = node;
 break;
 
+case VIR_DOMAIN_FEATURE_IOAPIC:
+node = ctxt->node;
+ctxt->node = nodes[i];
+tmp = virXPathString("string(./@driver)", ctxt);
+if (tmp) {
+int value = virDomainIOAPICTypeFromString(tmp);
+if (value < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("Unknown driver mode: %s"),
+   tmp);
+goto error;
+}
+def->ioapic = value;
+def->features[val] = VIR_TRISTATE_SWITCH_ON;
+}
+ctxt->node = node;
+break;
+
 /* coverity[dead_error_begin] */
 case VIR_DOMAIN_FEATURE_LAST:
 break;
@@ -24627,6 +24651,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 }
 break;
 
+case VIR_DOMAIN_FEATURE_IOAPIC:
+if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
+virBufferAsprintf(buf, "\n",
+  
virDomainIOAPICTypeToString(def->ioapic));
+}
+break;
+
 /* coverity[dead_error_begin] */
 case VIR_DOMAIN_FEATURE_LAST:
 break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 09fb7aa..82b4785 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1670,6 +1670,7 @@ typedef enum {
 VIR_DOMAIN_FEATURE_VMPORT,
 VIR_DOMAIN_FEATURE_GIC,
 VIR_DOMAIN_FEATURE_SMM,
+VIR_DOMAIN_FEATURE_IOAPIC,
 
 VIR_DOMAIN_FEATURE_LAST
 } virDomainFeature;
@@ -1809,6 +1810,15 @@ struct _virDomainLoaderDef {
 
 void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
 
+typedef enum {
+VIR_DOMAIN_IOAPIC_QEMU = 0,
+VIR_DOMAIN_IOAPIC_KVM,
+
+VIR_DOMAIN_IOAPIC_LAST
+} virDomainIOAPIC;
+
+VIR_ENUM_DECL(virDomainIOAPIC);
+
 /* Operating system configuration data & machine / arch */
 typedef struct _virDomainOSDef virD

Re: [libvirt] [PATCH 1/1] vz: unlock dom until resize operation

2017-05-03 Thread Nikolay Shirokovskiy


On 03.05.2017 14:23, Konstantin Neumoin wrote:
> We have to use waitDomainJob instead of waitJob, because of it
> unlock the domain until job has finished, so domain will be available
> for other clients.
> 
> Signed-off-by: Konstantin Neumoin 
> ---
>  src/vz/vz_sdk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index bc1a9eb..79b356d 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -4993,7 +4993,7 @@ int prlsdkResizeImage(virDomainObjPtr dom, 
> virDomainDiskDefPtr disk,
>  
>  job = PrlVmDev_ResizeImage(prldisk, newsize,
> PRIF_RESIZE_LAST_PARTITION);
> -if (PRL_FAILED(waitJob(job)))
> +if (PRL_FAILED(waitDomainJob(job, dom)))
>  goto cleanup;
>  
>  ret = 0;
> 

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 4/5] qemuDomainAttachDeviceMknodRecursive: Don't try to create devices under preserved mount points

2017-05-03 Thread Cedric Bosdonnat
On Fri, 2017-04-28 at 13:22 +0200, Michal Privoznik wrote:
> Just like in previous commit, this fixes the same issue for
> hotplug.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_domain.c | 112 
> ++---
>  1 file changed, 97 insertions(+), 15 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 5840c57..60f8f01 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -8238,6 +8238,8 @@ static int
>  qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
>   virDomainObjPtr vm,
>   const char *file,
> + char * const *devMountsPath,
> + size_t ndevMountsPath,
>   unsigned int ttl)
>  {
>  struct qemuDomainAttachDeviceMknodData data;
> @@ -8315,20 +8317,36 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr 
> driver,
>  #endif
>  
>  if (STRPREFIX(file, DEVPREFIX)) {
> -if (qemuSecurityPreFork(driver->securityManager) < 0)
> -goto cleanup;
> +size_t i;
>  
> -if (virProcessRunInMountNamespace(vm->pid,
> -  qemuDomainAttachDeviceMknodHelper,
> -  &data) < 0) {
> +for (i = 0; i < ndevMountsPath; i++) {
> +if (STREQ(devMountsPath[i], "/dev"))
> +continue;
> +if (STRPREFIX(file, devMountsPath[i]))
> +break;
> +}
> +
> +if (i == ndevMountsPath) {
> +if (qemuSecurityPreFork(driver->securityManager) < 0)
> +goto cleanup;
> +
> +if (virProcessRunInMountNamespace(vm->pid,
> +  
> qemuDomainAttachDeviceMknodHelper,
> +  &data) < 0) {
> +qemuSecurityPostFork(driver->securityManager);
> +goto cleanup;
> +}
>  qemuSecurityPostFork(driver->securityManager);
> -goto cleanup;
> +} else {
> +VIR_DEBUG("Skipping dev %s because of %s mount point",
> +  file, devMountsPath[i]);
>  }
> -qemuSecurityPostFork(driver->securityManager);
>  }
>  
>  if (isLink &&
> -qemuDomainAttachDeviceMknodRecursive(driver, vm, target, ttl -1) < 0)
> +qemuDomainAttachDeviceMknodRecursive(driver, vm, target,
> + devMountsPath, ndevMountsPath,
> + ttl -1) < 0)
>  goto cleanup;
>  
>  ret = 0;
> @@ -8345,11 +8363,15 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr 
> driver,
>  static int
>  qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
>  virDomainObjPtr vm,
> -const char *file)
> +const char *file,
> +char * const *devMountsPath,
> +size_t ndevMountsPath)
>  {
>  long symloop_max = sysconf(_SC_SYMLOOP_MAX);
>  
> -return qemuDomainAttachDeviceMknodRecursive(driver, vm, file, 
> symloop_max);
> +return qemuDomainAttachDeviceMknodRecursive(driver, vm, file,
> +devMountsPath, 
> ndevMountsPath,
> +symloop_max);
>  }
>  
>  
> @@ -8389,6 +8411,9 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
>   virDomainObjPtr vm,
>   virStorageSourcePtr src)
>  {
> +virQEMUDriverConfigPtr cfg = NULL;
> +char **devMountsPath = NULL;
> +size_t ndevMountsPath = 0;
>  virStorageSourcePtr next;
>  struct stat sb;
>  int ret = -1;
> @@ -8396,6 +8421,12 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
>  if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
>  return 0;
>  
> +cfg = virQEMUDriverGetConfig(driver);
> +if (qemuDomainGetPreservedMounts(cfg, vm,
> + &devMountsPath, NULL,
> + &ndevMountsPath) < 0)
> +goto cleanup;
> +
>  for (next = src; next; next = next->backingStore) {
>  if (virStorageSourceIsEmpty(next) ||
>  !virStorageSourceIsLocalStorage(next)) {
> @@ -8414,12 +8445,15 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
>  
>  if (qemuDomainAttachDeviceMknod(driver,
>  vm,
> -next->path) < 0)
> +next->path,
> +devMountsPath, ndevMountsPath) < 0)
>  goto cleanup;
>  }
>  
>  ret = 0;
>   cleanup:
> +virStringListFreeC

Re: [libvirt] [PATCH 5/5] qemuDomainDetachDeviceUnlink: Don't unlink files we haven't created

2017-05-03 Thread Cedric Bosdonnat
On Fri, 2017-04-28 at 13:22 +0200, Michal Privoznik wrote:
> Even though there are several checks before calling this function
> and for some scenarios we don't call it at all (e.g. on disk hot
> unplug), it may be possible to sneak in some weird files (e.g. if
> domain would have RNG with /dev/shm/some_file as its backend). No
> matter how improbable, we shouldn't unlink it as we would be
> unlinking a file from the host which we haven't created in the
> first place.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_domain.c | 86 
> --
>  1 file changed, 76 insertions(+), 10 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 60f8f01..c393d5e 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -8395,14 +8395,32 @@ qemuDomainDetachDeviceUnlinkHelper(pid_t pid 
> ATTRIBUTE_UNUSED,
>  static int
>  qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
>   virDomainObjPtr vm,
> - const char *file)
> + const char *file,
> + char * const *devMountsPath,
> + size_t ndevMountsPath)
>  {
> -if (virProcessRunInMountNamespace(vm->pid,
> -  qemuDomainDetachDeviceUnlinkHelper,
> -  (void *)file) < 0)
> -return -1;
> +int ret = -1;
> +size_t i;
>  
> -return 0;
> +if (STRPREFIX(file, DEVPREFIX)) {
> +for (i = 0; i < ndevMountsPath; i++) {
> +if (STREQ(devMountsPath[i], "/dev"))
> +continue;
> +if (STRPREFIX(file, devMountsPath[i]))
> +break;
> +}
> +
> +if (i == ndevMountsPath) {
> +if (virProcessRunInMountNamespace(vm->pid,
> +  
> qemuDomainDetachDeviceUnlinkHelper,
> +  (void *)file) < 0)
> +goto cleanup;
> +}
> +}
> +
> +ret = 0;
> + cleanup:
> +return ret;
>  }
>  
>  
> @@ -8521,6 +8539,9 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr 
> driver,
> virDomainObjPtr vm,
> virDomainHostdevDefPtr hostdev)
>  {
> +virQEMUDriverConfigPtr cfg = NULL;
> +char **devMountsPath = NULL;
> +size_t ndevMountsPath = 0;
>  int ret = -1;
>  char **path = NULL;
>  size_t i, npaths = 0;
> @@ -8532,8 +8553,15 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr 
> driver,
>   &npaths, &path, NULL) < 0)
>  goto cleanup;
>  
> +cfg = virQEMUDriverGetConfig(driver);
> +if (qemuDomainGetPreservedMounts(cfg, vm,
> + &devMountsPath, NULL,
> + &ndevMountsPath) < 0)
> +goto cleanup;
> +
>  for (i = 0; i < npaths; i++) {
> -if (qemuDomainDetachDeviceUnlink(driver, vm, path[i]) < 0)
> +if (qemuDomainDetachDeviceUnlink(driver, vm, path[i],
> + devMountsPath, ndevMountsPath) < 0)
>  goto cleanup;
>  }
>  
> @@ -8542,6 +8570,8 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr 
> driver,
>  for (i = 0; i < npaths; i++)
>  VIR_FREE(path[i]);
>  VIR_FREE(path);
> +virStringListFreeCount(devMountsPath, ndevMountsPath);
> +virObjectUnref(cfg);
>  return ret;
>  }
>  
> @@ -8584,6 +8614,9 @@ qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr 
> driver,
>    virDomainObjPtr vm,
>    virDomainMemoryDefPtr mem)
>  {
> +virQEMUDriverConfigPtr cfg = NULL;
> +char **devMountsPath = NULL;
> +size_t ndevMountsPath = 0;
>  int ret = -1;
>  
>  if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
> @@ -8592,10 +8625,19 @@ qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr 
> driver,
>  if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
>  return 0;
>  
> -if (qemuDomainDetachDeviceUnlink(driver, vm, mem->nvdimmPath) < 0)
> +cfg = virQEMUDriverGetConfig(driver);
> +if (qemuDomainGetPreservedMounts(cfg, vm,
> + &devMountsPath, NULL,
> + &ndevMountsPath) < 0)
> +goto cleanup;
> +
> +if (qemuDomainDetachDeviceUnlink(driver, vm, mem->nvdimmPath,
> + devMountsPath, ndevMountsPath) < 0)
>  goto cleanup;
>  ret = 0;
>   cleanup:
> +virStringListFreeCount(devMountsPath, ndevMountsPath);
> +virObjectUnref(cfg);
>  return ret;
>  }
>  
> @@ -8643,6 +8685,9 @@ qemuDomainNamespaceTeardownChardev(virQEMUDriverPtr 
> driver,
> virDomainObjPtr vm,
>    

Re: [libvirt] [PATCH 3/5] qemuDomainCreateDeviceRecursive: Don't try to create devices under preserved mount points

2017-05-03 Thread Cedric Bosdonnat
On Fri, 2017-04-28 at 13:22 +0200, Michal Privoznik wrote:
> While the code allows devices to already be there (by some
> miracle), we shouldn't try to create devices that don't belong to
> us. For instance, we shouldn't try to create /dev/shm/file
> because /dev/shm is a mount point that is preserved. Therefore if
> a file is created there from an outside (e.g. by mgmt application
> or some other daemon running on the system like vhostmd), it
> exists in the qemu namespace too as the mount point is the same.
> It's only /dev and /dev only that is different. The same

One 'only' should be dropped perhaps?

> reasoning applies to all other preserved mount points.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_domain.c | 39 ++-
>  1 file changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 9e18f7e..5840c57 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -7339,6 +7339,8 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
>  
>  struct qemuDomainCreateDeviceData {
>  const char *path; /* Path to temp new /dev location */
> +char * const *devMountsPath;
> +size_t ndevMountsPath;
>  };
>  
>  
> @@ -7392,17 +7394,34 @@ qemuDomainCreateDeviceRecursive(const char *device,
>   * For now, lets hope callers play nice.
>   */
>  if (STRPREFIX(device, DEVPREFIX)) {
> -if (virAsprintf(&devicePath, "%s/%s",
> -data->path, device + strlen(DEVPREFIX)) < 0)
> -goto cleanup;
> +size_t i;
>  
> -if (virFileMakeParentPath(devicePath) < 0) {
> -virReportSystemError(errno,
> - _("Unable to create %s"),
> - devicePath);
> -goto cleanup;
> +for (i = 0; i < data->ndevMountsPath; i++) {
> +if (STREQ(data->devMountsPath[i], "/dev"))
> +continue;
> +if (STRPREFIX(device, data->devMountsPath[i]))
> +break;
> +}
> +
> +if (i == data->ndevMountsPath) {
> +/* Okay, @device is in /dev but not in any mount point under 
> /dev.
> + * Create it. */
> +if (virAsprintf(&devicePath, "%s/%s",
> +data->path, device + strlen(DEVPREFIX)) < 0)
> +goto cleanup;
> +
> +if (virFileMakeParentPath(devicePath) < 0) {
> +virReportSystemError(errno,
> + _("Unable to create %s"),
> + devicePath);
> +goto cleanup;
> +}
> +VIR_DEBUG("Creating dev %s", device);
> +create = true;
> +} else {
> +VIR_DEBUG("Skipping dev %s because of %s mount point",
> +  device, data->devMountsPath[i]);
>  }
> -create = true;
>  }
>  
>  if (isLink) {
> @@ -7951,6 +7970,8 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
>  }
>  
>  data.path = devPath;
> +data.devMountsPath = devMountsPath;
> +data.ndevMountsPath = ndevMountsPath;
>  
>  if (virProcessSetupPrivateMountNS() < 0)
>  goto cleanup;

ACK

--
Cedric

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] client: Report proper close reason

2017-05-03 Thread Peter Krempa
On Tue, May 02, 2017 at 16:55:59 +0200, Jiri Denemark wrote:
> When we get a POLLHUP or VIR_EVENT_HANDLE_HANGUP event for a client, we
> still want to read from the socket to process any accumulated data. But
> doing so inevitably results in an error and a call to
> virNetClientMarkClose before we get to processing the hangup event (and
> another call to virNetClientMarkClose). However the close reason passed
> to the second virNetClientMarkClose call is ignored because another one
> was already set. We need to pass the correct close reason when marking
> the socket to be closed for the first time.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1373859

So this basically partially overrides what this commit has done (wrong):

commit f1271380381bb49b4a4c38950fe77a60d19ea9a3
Author: Martin Kletzander 
Date:   Sun Nov 30 20:09:08 2014 +0100

rpc: Report proper close reason

Whenever client socket was marked as closed for some reason, it could've
been changed when really closing the connection.  With this patch the
proper reason is kept since the first time it's marked as closed.

Without the mentioned commit the last error would be remembered. It is
probable that in some cases the error would be overwritten incorrectly
so I think that the combination of these two patches should do the
trick.

ACK



signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/5] qemuDomainCreateDeviceRecursive: pass a structure instead of bare path

2017-05-03 Thread Cedric Bosdonnat
On Fri, 2017-04-28 at 13:22 +0200, Michal Privoznik wrote:
> Currently, all we need to do in qemuDomainCreateDeviceRecursive() is to
> take given @device, get all kinds of info on it (major & minor numbers,
> owner, seclabels) and create its copy at a temporary location @path
> (usually /var/run/libvirt/qemu/$domName.dev), if @device live under
> /dev. This is, however, very loose condition, as it also means
> /dev/shm/* is created too. Therefor, we will need to pass more arguments
> into the function for better decision making (e.g. list of mount points
> under /dev). Instead of adding more arguments to all the functions (not
> easily reachable because some functions are callback with strictly
> defined type), lets just turn this one 'const char *' into a 'struct *'.
> New "arguments" can be then added at no cost.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_domain.c | 106 
> ++---
>  1 file changed, 57 insertions(+), 49 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index be02d54..9e18f7e 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -7337,9 +7337,14 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr 
> cfg,
>  }
>  
>  
> +struct qemuDomainCreateDeviceData {
> +const char *path; /* Path to temp new /dev location */
> +};
> +
> +
>  static int
>  qemuDomainCreateDeviceRecursive(const char *device,
> -const char *path,
> +const struct qemuDomainCreateDeviceData 
> *data,
>  bool allow_noent,
>  unsigned int ttl)
>  {
> @@ -7388,7 +7393,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
>   */
>  if (STRPREFIX(device, DEVPREFIX)) {
>  if (virAsprintf(&devicePath, "%s/%s",
> -path, device + strlen(DEVPREFIX)) < 0)
> +data->path, device + strlen(DEVPREFIX)) < 0)
>  goto cleanup;
>  
>  if (virFileMakeParentPath(devicePath) < 0) {
> @@ -7449,7 +7454,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
>  tmp = NULL;
>  }
>  
> -if (qemuDomainCreateDeviceRecursive(target, path,
> +if (qemuDomainCreateDeviceRecursive(target, data,
>  allow_noent, ttl - 1) < 0)
>  goto cleanup;
>  } else {
> @@ -7533,12 +7538,12 @@ qemuDomainCreateDeviceRecursive(const char *device,
>  
>  static int
>  qemuDomainCreateDevice(const char *device,
> -   const char *path,
> +   const struct qemuDomainCreateDeviceData *data,
> bool allow_noent)
>  {
>  long symloop_max = sysconf(_SC_SYMLOOP_MAX);
>  
> -return qemuDomainCreateDeviceRecursive(device, path,
> +return qemuDomainCreateDeviceRecursive(device, data,
> allow_noent, symloop_max);
>  }
>  
> @@ -7546,7 +7551,7 @@ qemuDomainCreateDevice(const char *device,
>  static int
>  qemuDomainPopulateDevices(virQEMUDriverConfigPtr cfg,
>    virDomainObjPtr vm ATTRIBUTE_UNUSED,
> -  const char *path)
> +  const struct qemuDomainCreateDeviceData *data)
>  {
>  const char *const *devices = (const char *const *) cfg->cgroupDeviceACL;
>  size_t i;
> @@ -7556,7 +7561,7 @@ qemuDomainPopulateDevices(virQEMUDriverConfigPtr cfg,
>  devices = defaultDeviceACL;
>  
>  for (i = 0; devices[i]; i++) {
> -if (qemuDomainCreateDevice(devices[i], path, true) < 0)
> +if (qemuDomainCreateDevice(devices[i], data, true) < 0)
>  goto cleanup;
>  }
>  
> @@ -7570,7 +7575,7 @@ static int
>  qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
> virSecurityManagerPtr mgr,
> virDomainObjPtr vm,
> -   const char *path)
> +   const struct qemuDomainCreateDeviceData *data)
>  {
>  char *mount_options = NULL;
>  char *opts = NULL;
> @@ -7592,10 +7597,10 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
>  "mode=755,size=65536%s", mount_options) < 0)
>  goto cleanup;
>  
> -if (virFileSetupDev(path, opts) < 0)
> +if (virFileSetupDev(data->path, opts) < 0)
>  goto cleanup;
>  
> -if (qemuDomainPopulateDevices(cfg, vm, path) < 0)
> +if (qemuDomainPopulateDevices(cfg, vm, data) < 0)
>  goto cleanup;
>  
>  ret = 0;
> @@ -7609,7 +7614,7 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
>  static int
>  qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
>  virDomainDiskDefPtr disk,
> -const char *devPath)
> +const struct qemuDomainCreateDeviceData *data)
>  {
>  virStorageSourcePtr next;
>  char *dst = NULL;
> @@ -7621,7 +76

Re: [libvirt] [PATCH 1/5] qemuDomainBuildNamespace: Move /dev/* mountpoints later

2017-05-03 Thread Cedric Bosdonnat
On Fri, 2017-04-28 at 13:22 +0200, Michal Privoznik wrote:
> When setting up mount namespace for a qemu domain the following
> steps are executed:
> 
> 1) get list of mountpoints under /dev/
> 2) move them to /var/run/libvirt/qemu/$domName.ext
> 3) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
> 4) move the mountpoint of the new device tree to /dev
> 5) restore original mountpoints from step 2)
> 
> Not the problem with this approach is that if some device in step

You may have wanted to write "Note" rather than "Not".
Otherwise ACK.

--
Cedric

> 3) requires access to a mountpoint from step 2) it will fail as
> the mountpoint is not there anymore. For instance consider the
> following domain disk configuration:
> 
> 
>   
>   
>   
>    function='0x0'/>
> 
> 
> In this case operation fails as we are unable to create vhostmd0
> in the new device tree because after step 2) there is no /dev/shm
> anymore. Leave aside fact that we shouldn't try to create devices
> living in other mountpoints. That's a separate bug that will be
> addressed later.
> 
> Currently, the order described above is rearranged to:
> 
> 1) get list of mountpoints under /dev/
> 2) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
> 3) move them to /var/run/libvirt/qemu/$domName.ext
> 4) move the mountpoint of the new device tree to /dev
> 5) restore original mountpoints from step 3)
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_domain.c | 54 
> +-
>  1 file changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 00b0b4a..be02d54 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -7950,33 +7950,6 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
>  if (qemuDomainSetupDev(cfg, mgr, vm, devPath) < 0)
>  goto cleanup;
>  
> -/* Save some mount points because we want to share them with the host */
> -for (i = 0; i < ndevMountsPath; i++) {
> -struct stat sb;
> -
> -if (devMountsSavePath[i] == devPath)
> -continue;
> -
> -if (stat(devMountsPath[i], &sb) < 0) {
> -virReportSystemError(errno,
> - _("Unable to stat: %s"),
> - devMountsPath[i]);
> -goto cleanup;
> -}
> -
> -/* At this point, devMountsPath is either a regular file or a 
> directory. */
> -if ((S_ISDIR(sb.st_mode) && virFileMakePath(devMountsSavePath[i]) < 
> 0) ||
> -(S_ISREG(sb.st_mode) && virFileTouch(devMountsSavePath[i], 
> sb.st_mode) < 0)) {
> -virReportSystemError(errno,
> - _("Failed to create %s"),
> - devMountsSavePath[i]);
> -goto cleanup;
> -}
> -
> -if (virFileMoveMount(devMountsPath[i], devMountsSavePath[i]) < 0)
> -goto cleanup;
> -}
> -
>  if (qemuDomainSetupAllDisks(cfg, vm, devPath) < 0)
>  goto cleanup;
>  
> @@ -8001,6 +7974,33 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
>  if (qemuDomainSetupAllRNGs(cfg, vm, devPath) < 0)
>  goto cleanup;
>  
> +/* Save some mount points because we want to share them with the host */
> +for (i = 0; i < ndevMountsPath; i++) {
> +struct stat sb;
> +
> +if (devMountsSavePath[i] == devPath)
> +continue;
> +
> +if (stat(devMountsPath[i], &sb) < 0) {
> +virReportSystemError(errno,
> + _("Unable to stat: %s"),
> + devMountsPath[i]);
> +goto cleanup;
> +}
> +
> +/* At this point, devMountsPath is either a regular file or a 
> directory. */
> +if ((S_ISDIR(sb.st_mode) && virFileMakePath(devMountsSavePath[i]) < 
> 0) ||
> +(S_ISREG(sb.st_mode) && virFileTouch(devMountsSavePath[i], 
> sb.st_mode) < 0)) {
> +virReportSystemError(errno,
> + _("Failed to create %s"),
> + devMountsSavePath[i]);
> +goto cleanup;
> +}
> +
> +if (virFileMoveMount(devMountsPath[i], devMountsSavePath[i]) < 0)
> +goto cleanup;
> +}
> +
>  if (virFileMoveMount(devPath, "/dev") < 0)
>  goto cleanup;
>  

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] RFE: virsh list improvement (--description and --details)

2017-05-03 Thread Przemysław Sztoch
Hello,

1. Please add —description parameter to virsh list command. It should be 
similar to —title.
It will be very helpful for administrators who like to leave the order and 
documentation after their work.

2. Please add new columns to virsh list (for —details):
a) CPUs
b) MaxMem
c) Flags: p-persistent, t-transient, a-autostart, m-managed save, s-with 
snapshot(s)
and total sum for column vCPUs and Mem.

In my opinion it is very popular use case. It will help you control vCPU and 
memory overcommiting in very simple and fast way.
Put flags on list will prevents many additional commands from being executed. 
You will get all important information in one place.

3. Please add —domtime parameter to virsh list command. It should show column 
with domain’s system time similar to virsh domtime domname --pretty.
It will be very helpful for fast guest-agent checking for every domain.

4. Please add column Parent and Metadata to virsh snapshot-list. 

—
Przemyslaw Sztoch

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 1/1] vz: unlock dom until resize operation

2017-05-03 Thread Konstantin Neumoin
We have to use waitDomainJob instead of waitJob, because of it
unlock the domain until job has finished, so domain will be available
for other clients.

Signed-off-by: Konstantin Neumoin 
---
 src/vz/vz_sdk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index bc1a9eb..79b356d 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -4993,7 +4993,7 @@ int prlsdkResizeImage(virDomainObjPtr dom, 
virDomainDiskDefPtr disk,
 
 job = PrlVmDev_ResizeImage(prldisk, newsize,
PRIF_RESIZE_LAST_PARTITION);
-if (PRL_FAILED(waitJob(job)))
+if (PRL_FAILED(waitDomainJob(job, dom)))
 goto cleanup;
 
 ret = 0;
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/1] vz: fix raise in vzDomainBlock

2017-05-03 Thread Konstantin Neumoin
Need begin job before lookup disk in config,
because it can be edited at this moment.

Signed-off-by: Konstantin Neumoin 
---
 src/vz/vz_driver.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 8f94326..954ca6a 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -4000,12 +4000,6 @@ vzDomainBlockResize(virDomainPtr domain,
 size /= 1024;
 size /= 1024;
 
-if (!(disk = virDomainDiskByName(dom->def, path, false))) {
-virReportError(VIR_ERR_INVALID_ARG,
-   _("invalid path: %s"), path);
-goto cleanup;
-}
-
 if (vzDomainObjBeginJob(dom) < 0)
 goto cleanup;
 job = true;
@@ -4019,6 +4013,12 @@ vzDomainBlockResize(virDomainPtr domain,
 goto cleanup;
 }
 
+if (!(disk = virDomainDiskByName(dom->def, path, false))) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _("invalid path: %s"), path);
+goto cleanup;
+}
+
 ret = prlsdkResizeImage(dom, disk, size);
 
  cleanup:
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/1] vz: minor cleanup in prlsdkDomainSetUserPassword

2017-05-03 Thread Konstantin Neumoin
No need begin job for asynchronous operation.

Signed-off-by: Konstantin Neumoin 
---
 src/vz/vz_sdk.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 138aea3..bc1a9eb 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3926,30 +3926,18 @@ prlsdkDomainSetUserPassword(virDomainObjPtr dom,
 const char *user,
 const char *password)
 {
-int ret = -1;
 vzDomObjPtr privdom = dom->privateData;
 PRL_HANDLE job = PRL_INVALID_HANDLE;
 
-job = PrlVm_BeginEdit(privdom->sdkdom);
-if (PRL_FAILED(waitDomainJob(job, dom)))
-goto cleanup;
-
 job = PrlVm_SetUserPasswd(privdom->sdkdom,
   user,
   password,
   0);
 
 if (PRL_FAILED(waitDomainJob(job, dom)))
-goto cleanup;
-
-job = PrlVm_CommitEx(privdom->sdkdom, 0);
-if (PRL_FAILED(waitDomainJob(job, dom)))
-goto cleanup;
-
-ret = 0;
+return -1;
 
- cleanup:
-return ret;
+return 0;
 }
 
 static int
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Libvirt CAT support plan

2017-05-03 Thread Eli Qiao


On Wednesday, 3 May 2017 at 4:34 PM, Daniel P. Berrange wrote:

> On Wed, May 03, 2017 at 08:30:31AM +0800, Eli Qiao wrote:
> > hi all,
> >  
> > Thanks for helping reviewing for CAT support in the past days.
> >  
> > I writing this email to ask for the plan in libvirt support.
> >  
> > I think we’v discussed this early this year, and I’v proposed a patch set 
> > [1].
> > But don’t get merged because of some performance reason ?
> >  
> > Then I proposed a redesign RFC[2] based on Martin’s cache branch,
> > thans Martin for the reviewing, I can address them but the question here
> > is it depends on Martin’s `cache` branch, which if for exposing host’s 
> > `cache`
> > information in capabilities xml, and it doesn’t get merged ether, I feel 
> > helpless.
> >  
>  
>  
> Martin posted review comments on your latest patches just a couple of days
> ago, and you've not posted any newer version of the patches since then
> that address those comments.
>  
Yes, I see that and response, I will refine my RFC patch.

I just worry about the dependencies. It’s long time and don’t get reviewed 
after the last post.
https://www.redhat.com/archives/libvir-list/2017-April/msg00541.html

And Martin’s `cache` branch was not merged yet, that’s not under my control, 
this
is my concern.  
>  
> > As CAT is a key feature which would be required by many customers and
> > especially the OpenStack integration.
> >  
>  
>  
> Regardless of what/who needs a feature, we're not going to rush to
> merge patches if there are still outstanding issues that need fixing.
>  
Agree.  
I would like to get some advice on which direction should go, with the new 
implementation,  
the dependency is a problem.
>  
> > Would like to know the plan and get the some suggestions.
>  
>  
> Carry on addressing the feedback provided & posting new versions of the
> patches for review.
>  
>  

Sure, I will continue working on that.  

BR,
Eli Qiao  

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] Libvirt CAT support plan

2017-05-03 Thread Daniel P. Berrange
On Wed, May 03, 2017 at 08:30:31AM +0800, Eli Qiao wrote:
> hi all,
> 
> Thanks for helping reviewing for CAT support in the past days.
> 
> I writing this email to ask for the plan in libvirt support.
> 
> I think we’v discussed this early this year, and I’v proposed a patch set [1].
> But don’t get merged because of some performance reason ?
> 
> Then I proposed a redesign RFC[2] based on Martin’s cache branch,
> thans Martin for the reviewing, I can address them but the question here
> is it depends on Martin’s `cache` branch, which if for exposing host’s `cache`
> information in capabilities xml, and it doesn’t get merged ether, I feel 
> helpless.

Martin posted review comments on your latest patches just a couple of days
ago, and you've not posted any newer version of the patches since then
that address those comments.

> As CAT is a key feature which would be required by many customers and
> especially the OpenStack integration.

Regardless of what/who needs a feature, we're not going to rush to
merge patches if there are still outstanding issues that need fixing.

> Would like to know the plan and get the some suggestions.

Carry on addressing the feedback provided & posting new versions of the
patches for review.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/2] news: Add more v3.3.0 entries

2017-05-03 Thread Peter Krempa
On Tue, May 02, 2017 at 18:23:08 +0200, Andrea Bolognani wrote:
> These entries cover a number of features, improvements and
> bug fixes that had not been documented during the development
> cycle.
> ---
>  docs/news.xml | 115 
> ++
>  1 file changed, 115 insertions(+)
> 
> diff --git a/docs/news.xml b/docs/news.xml
> index 36d2ee3..38dc17f 100644
> --- a/docs/news.xml
> +++ b/docs/news.xml

>  
> +  
> +
> +  nss: Don't require a network restart for libvirt_guest
> +
> +
> +  Previously, the libvirt_guest NSS module would only work properly
> +  after the corresponding network had been restarted; now newly
> +  started guests will be reported correctly right away.
> +
> +  
> +  
> +
> +  storage: Remove unavailable transient pools after restart
> +
> +
> +  Solve an issue where transient storage pools would be stuck in an
> +  unmanageable state if the source disappeared and libvirtd was
> +  subsequently restarted.
> +
> +  
> +  
> +
> +  storage: Fix capacity value for LUKS encrypted volumes
> +
> +
> +  The 'capacity' value (e.g. guest logical size) for a LUKS volume is
> +  smaller than the 'physical' value of the file in the file system, 
> so
> +  we need to account for that.
> +

Rather than this I'd mention the bug in the padding of data passed to
qemu: 71890992daf37ec78b00b4ce873369421dc99731

> +  
> +  
> +
> +  qemu: Fix regression when hyperv/vendor_id feature is used
> +
> +
> +  Guests using the feature would not be started at all; it is now
> +  possible to start them as expected.
> +
> +  
> +  
> +
> +  qemu: Do not crash on USB address with no port and invalid bus
> +
> +  
> +  
> +
> +  virsh: Report initialization errors
> +
> +
> +  Sometimes virsh might be unable to start: when that happens, report
> +  useful diagnostics instead of failing silently.

This does not seem to be a bugfix, but rather an improvement.

> +
> +  
>  
>
>

ACK


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/2] news: Tweak existing v3.3.0 entries

2017-05-03 Thread Peter Krempa
On Tue, May 02, 2017 at 18:22:44 +0200, Andrea Bolognani wrote:
> Some of the content was not following the (loosely established)
> style, and some of the XML was not aligned properly.
> ---
>  docs/news.xml | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

ACK


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list