Re: [libvirt] [PATCH] xenconfig: Remove references to my name and email

2018-05-07 Thread Jim Fehlig

On 05/07/2018 08:57 AM, David Kiarie wrote:



On Mon, May 7, 2018 at 5:55 PM, David Kiarie > wrote:




On Mon, May 7, 2018 at 10:29 AM, Peter Krempa mailto:pkre...@redhat.com>> wrote:

On Sat, May 05, 2018 at 12:17:05 +0300, David Kiarie wrote:
> On Sat, May 5, 2018 at 12:15 PM, David Kiarie mailto:davidkiar...@gmail.com>>
> wrote:
> 
> > Replace references to my name and email with a pseudonym

> >
> 
> Sorry, I just want my real name and email off these files and I keep making

> silly mistakes.

How about just deleting them? We don't really support using pseudonyms.


Why is that ? With a person reason I don't want my name of these files. I
wrote the files and it took me a lot of work.

I can still prove I wrote this code with the above email if anyone wants me
to as I still work as a developer.


I initally requested to have my name removed from the files but apparently I 
hadn't signed off the patch so it was rejected.


You could have simply replied to the mail requesting a SOB and one of us would 
have added it your patch and pushed it.


One month later, I figured it might be a bad idea to just give up all the work I 
had done and opted to keep track of it.


I think that is a wise choice, in which case you should leave the authorship as 
is :-).


Regards,
Jim

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


Re: [libvirt] [PATCH] qemu: domain: Replace qemuDomainFilePathIsHostCDROM with virFileIsCDROM

2018-05-07 Thread Laine Stump
On 05/07/2018 11:21 AM, Peter Krempa wrote:
> Use the new helper when checking that the VM needs to be tainted as a
> host-cdrom passthrough.
>
> Signed-off-by: Peter Krempa 
> ---
>  src/qemu/qemu_domain.c | 31 +--
>  1 file changed, 1 insertion(+), 30 deletions(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index b13e6d8ca4..ec865e68c8 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -6483,35 +6483,6 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver,
>  }
>
>
> -/* qemuDomainFilePathIsHostCDROM
> - * @path: Supplied path.
> - *
> - * Determine if the path is a host CD-ROM path. Typically this is
> - * either /dev/cdrom[n] or /dev/srN, so those are easy checks, but
> - * it's also possible that @path resolves to /dev/srN, so check for
> - * those conditions on @path in order to emit the tainted message.
> - *
> - * Returns true if the path is a CDROM, false otherwise or on error.
> - */
> -static bool
> -qemuDomainFilePathIsHostCDROM(const char *path)
> -{
> -bool ret = false;
> -char *linkpath = NULL;
> -
> -if (virFileResolveLink(path, &linkpath) < 0)
> -goto cleanup;
> -
> -if (STRPREFIX(path, "/dev/cdrom") || STRPREFIX(path, "/dev/sr") ||
> -STRPREFIX(linkpath, "/dev/sr"))
> -ret = true;
> -
> - cleanup:
> -VIR_FREE(linkpath);
> -return ret;
> -}
> -
> -
>  void qemuDomainObjTaint(virQEMUDriverPtr driver,
>  virDomainObjPtr obj,
>  virDomainTaintFlags taint,
> @@ -6630,7 +6601,7 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr 
> driver,
>
>  if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
>  virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_BLOCK &&
> -disk->src->path && qemuDomainFilePathIsHostCDROM(disk->src->path))
> +disk->src->path && virFileIsCDROM(disk->src->path))
>  qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,
> logCtxt);
>

Not a 1 for 1 replacement of code, so possible behavior may change in
some odd circumstance, but if it does, that's probably a *good* thing
since the new function is more accurate.

However, virFileIsCDROM() returns different values than
qemuDomainFilePathIsHostCDROM(). In particular, it can fail and return
-1. The other use of virFileCDRom compares with 1 (meaning that
"failure" is the same as "not a CDROM"), but here you're just checking
for T/F, so "failure" == "*is* a CDROM.


I won't attempt to say which is the better behavior, but I'd venture it
should be consistent. Once you've fixed that (or with a short
explanation in the commit message of why you treated the two uses
differently):


Reviewed-by: Laine Stump 


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


Re: [libvirt] [tck PATCH v2 0/3] Remove Test::AutoBuild leftovers

2018-05-07 Thread Laine Stump
On 05/04/2018 10:14 AM, Andrea Bolognani wrote:
> Changes from [v1]:
>
> * rename the script instead of dropping it;
>
> * perform some further clean ups.
>
>
> [v1] https://www.redhat.com/archives/libvir-list/2018-May/msg00218.html
>
> Andrea Bolognani (3):
>   maint: Rename autobuild.sh to prepare-release.sh
>   prepare-release: Drop references to Test::AutoBuild
>   spec: Drop %{extra_release}
>
>  perl-Sys-Virt-TCK.spec.PL  |  3 +--
>  autobuild.sh => prepare-release.sh | 15 ++-
>  2 files changed, 3 insertions(+), 15 deletions(-)
>  rename autobuild.sh => prepare-release.sh (64%)
>

Reviewed-by: Laine Stump 


(for the series).


I'm so glad that you just renamed my cheese instead of removing it :-)

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


Re: [libvirt] [PATCH 1/2] virTypedParamsSerialize: minor fixes

2018-05-07 Thread Marc Hartmayer
On Mon, Apr 30, 2018 at 03:20 PM +0200, John Ferlan  wrote:
> On 04/25/2018 11:55 AM, Marc Hartmayer wrote:
>> 1. Don't allocate if there is nothing that needs to be
>>allocated. Especially as the result of calling calloc(0, ...) is
>>implementation-defined.
>
> Following VIR_ALLOC_N one finds :
>
> VIR_ALLOC_N(params_val, nparams)
>
> which equates to
>
> # define VIR_ALLOC_N(ptr, count) \
>  virAllocN(&(ptr), sizeof(*(ptr)), (count), true, \
>VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
>
> or
>
> virAllocN(¶ms_val, sizeof(params_val), nparams, true, ...)
>
> and eventually/essentially
>
> *params_val = calloc(sizeof(params_val), nparams)
>
> If the returned value is NULL then we error w/ OOM (4th param=true).
>
> So, unless @params_val had no elements, it won't be calloc(0,...) and

I'm talking about the case that nparams == 0 => calloc(sizeof(…), 0).

> thus the question becomes is there a more specific path you are
> referencing here?

It’s a “generic” serializer so it should work for every (valid)
case. What happens, for example, if params == NULL and nparams == 0? In
that case I would expect *remote_params_val = NULL and
*remote_params_len = 0.

>
> FWIW: My f26 man page for calloc says:
>
> "The calloc() function allocates memory for an array of nmemb elements
> of size bytes each and returns a pointer to the allocated memory. The
> memory is set to zero.  If nmemb or size is 0, then calloc() returns
> either NULL, or a unique pointer value that can later be successfully
> passed to free()"
>
> We have so many places in the code that use VIR_ALLOC_N and do not check
> if the sizeof() or count is 0 - which makes me wonder even more about
> the specific case in which you are referencing.

It is not about the general use of VIR_ALLOC_N, but about the result of
the serializer and deserializer.

> I looked through the
> various remote_protocol.x structures that would use this and it seems
> they all use remote_typed_param for the structure being returned, so
> it's not clear how any of them could have a sizeof() returning 0.
>
>> 2. Update the length @remote_params_len only if the related
>>@remote_params_val has also been set.
>
> This one changes the error case as the returned @remote_params_len
> changes from being set to @params_len on input to be undefined.

Hmm, that’s already the case for 'remote_params_val'? But indeed, we can
either initialize both of them to 0 and NULL or add an error label for
this.

“@remote_params_len: the final number of elements in
@remote_params_val.”

[…snip…]

--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


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

[libvirt] [PATCH] qemu: domain: Replace qemuDomainFilePathIsHostCDROM with virFileIsCDROM

2018-05-07 Thread Peter Krempa
Use the new helper when checking that the VM needs to be tainted as a
host-cdrom passthrough.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_domain.c | 31 +--
 1 file changed, 1 insertion(+), 30 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b13e6d8ca4..ec865e68c8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6483,35 +6483,6 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver,
 }


-/* qemuDomainFilePathIsHostCDROM
- * @path: Supplied path.
- *
- * Determine if the path is a host CD-ROM path. Typically this is
- * either /dev/cdrom[n] or /dev/srN, so those are easy checks, but
- * it's also possible that @path resolves to /dev/srN, so check for
- * those conditions on @path in order to emit the tainted message.
- *
- * Returns true if the path is a CDROM, false otherwise or on error.
- */
-static bool
-qemuDomainFilePathIsHostCDROM(const char *path)
-{
-bool ret = false;
-char *linkpath = NULL;
-
-if (virFileResolveLink(path, &linkpath) < 0)
-goto cleanup;
-
-if (STRPREFIX(path, "/dev/cdrom") || STRPREFIX(path, "/dev/sr") ||
-STRPREFIX(linkpath, "/dev/sr"))
-ret = true;
-
- cleanup:
-VIR_FREE(linkpath);
-return ret;
-}
-
-
 void qemuDomainObjTaint(virQEMUDriverPtr driver,
 virDomainObjPtr obj,
 virDomainTaintFlags taint,
@@ -6630,7 +6601,7 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,

 if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
 virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_BLOCK &&
-disk->src->path && qemuDomainFilePathIsHostCDROM(disk->src->path))
+disk->src->path && virFileIsCDROM(disk->src->path))
 qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,
logCtxt);

-- 
2.16.2

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


[libvirt] [PATCH] util: file: Fix usage of STRPREFIX in virFileIsCDROM

2018-05-07 Thread Peter Krempa
STRPREFIX takes only two arguments, but the code it was adapted from
used function with 3 arguments.

Signed-off-by: Peter Krempa 
---
Pushed under the build-breaker rule.t

 src/util/virfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index ea2a3ea731..523241f64f 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1982,8 +1982,8 @@ virFileIsCDROM(const char *path)
 int
 virFileIsCDROM(const char *path)
 {
-if (STRPREFIX(path, "/dev/cd", NULL) ||
-STRPREFIX(path, "/dev/acd", NULL))
+if (STRPREFIX(path, "/dev/cd") ||
+STRPREFIX(path, "/dev/acd"))
 return 1;

 return 0;
-- 
2.16.2

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


Re: [libvirt] [tck PATCH] maint: Drop autobuild.sh

2018-05-07 Thread Andrea Bolognani
On Mon, 2018-05-07 at 10:25 -0400, Laine Stump wrote:
> On 05/03/2018 11:47 AM, Daniel P. Berrangé wrote:
> > On Thu, May 03, 2018 at 05:42:27PM +0200, Andrea Bolognani wrote:
> > > The Test-AutoBuild project, that this script is supposed
> > > to be used with, hasn't seen any activity in ~7 years;
> > > these days, libvirt-tck CI builds are happening on the
> > > Jenkins-based CentOS CI environment under the libvirt
> > > umbrella[1], and in that context the script is not used
> > > at all.
> > > 
> > > [1] https://ci.centos.org/view/libvirt/
> > > 
> > > Signed-off-by: Andrea Bolognani 
> > > ---
> > >  autobuild.sh | 59 
> > > ---
> > >  1 file changed, 59 deletions(-)
> > >  delete mode 100755 autobuild.sh
> > 
> > I used this one for cutting releases too.
> 
> And it's the only way I know how to build it for testing. Please don't
> move my cheese! :-)

I posted a [v2] that renames the script rather than dropping it:
patches that implement the same approach in libvirt-perl have
already been merged, while patches for virt-viewer, libvirt-tck,
libvirt-sandbox, libosinfo and osinfo-db are on the respective
mailing lists waiting for review.


[v2] https://www.redhat.com/archives/libvir-list/2018-May/msg00341.html
-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH] xenconfig: Remove references to my name and email

2018-05-07 Thread David Kiarie
On Mon, May 7, 2018 at 5:55 PM, David Kiarie  wrote:

>
>
> On Mon, May 7, 2018 at 10:29 AM, Peter Krempa  wrote:
>
>> On Sat, May 05, 2018 at 12:17:05 +0300, David Kiarie wrote:
>> > On Sat, May 5, 2018 at 12:15 PM, David Kiarie 
>> > wrote:
>> >
>> > > Replace references to my name and email with a pseudonym
>> > >
>> >
>> > Sorry, I just want my real name and email off these files and I keep
>> making
>> > silly mistakes.
>>
>> How about just deleting them? We don't really support using pseudonyms.
>>
>
> Why is that ? With a person reason I don't want my name of these files. I
> wrote the files and it took me a lot of work.
>
> I can still prove I wrote this code with the above email if anyone wants
> me to as I still work as a developer.
>

I initally requested to have my name removed from the files but apparently
I hadn't signed off the patch so it was rejected.

One month later, I figured it might be a bad idea to just give up all the
work I had done and opted to keep track of it.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] xenconfig: Remove references to my name and email

2018-05-07 Thread David Kiarie
On Mon, May 7, 2018 at 10:29 AM, Peter Krempa  wrote:

> On Sat, May 05, 2018 at 12:17:05 +0300, David Kiarie wrote:
> > On Sat, May 5, 2018 at 12:15 PM, David Kiarie 
> > wrote:
> >
> > > Replace references to my name and email with a pseudonym
> > >
> >
> > Sorry, I just want my real name and email off these files and I keep
> making
> > silly mistakes.
>
> How about just deleting them? We don't really support using pseudonyms.
>

Why is that ? With a person reason I don't want my name of these files. I
wrote the files and it took me a lot of work.

I can still prove I wrote this code with the above email if anyone wants me
to as I still work as a developer.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH libvirt v2 4/9] remote: Use domainClientEventCallbacks for remoteReplayConnectionClosedEvent

2018-05-07 Thread Marc Hartmayer
On Fri, Apr 27, 2018 at 02:19 AM +0200, John Ferlan  wrote:
> On 04/26/2018 12:27 PM, Marc Hartmayer wrote:
>> On Thu, Apr 26, 2018 at 05:07 PM +0200, John Ferlan  
>> wrote:
>>> On 04/12/2018 08:40 AM, Marc Hartmayer wrote:
 This allows us to get rid of another usage of the global variable
 remoteProgram.

 Signed-off-by: Marc Hartmayer 
 Reviewed-by: Boris Fiuczynski 
 ---
  src/remote/remote_daemon_dispatch.c | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

 diff --git a/src/remote/remote_daemon_dispatch.c 
 b/src/remote/remote_daemon_dispatch.c
 index b4c0e01b0832..cf2cd0add7d6 100644
 --- a/src/remote/remote_daemon_dispatch.c
 +++ b/src/remote/remote_daemon_dispatch.c
 @@ -1661,12 +1661,12 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr 
 conn,
  static
  void remoteRelayConnectionClosedEvent(virConnectPtr conn 
 ATTRIBUTE_UNUSED, int reason, void *opaque)
  {
 -virNetServerClientPtr client = opaque;
 +daemonClientEventCallbackPtr callback = opaque;

  VIR_DEBUG("Relaying connection closed event, reason %d", reason);

  remote_connect_event_connection_closed_msg msg = { reason };
 -remoteDispatchObjectEventSend(client, remoteProgram,
 +remoteDispatchObjectEventSend(callback->client, callback->program,

 REMOTE_PROC_CONNECT_EVENT_CONNECTION_CLOSED,

 (xdrproc_t)xdr_remote_connect_event_connection_closed_msg,
&msg);
 @@ -3836,6 +3836,7 @@ 
 remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server 
 ATTRIBUTE_UNUS
 virNetMessageErrorPtr rerr)
  {
  int rv = -1;
 +daemonClientEventCallbackPtr callback = NULL;
  struct daemonClientPrivate *priv =
  virNetServerClientGetPrivateData(client);

 @@ -3846,9 +3847,16 @@ 
 remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server 
 ATTRIBUTE_UNUS
  goto cleanup;
  }

 +if (VIR_ALLOC(callback) < 0)
 +goto cleanup;
 +callback->client = virObjectRef(client);
>>>
>>> Oh and this would seem to fix a problem with the callback possibly using
>>> @client after it had been freed!
>>
>> The problem is more of a theoretical nature as Nikolay had explained:
>>
>> “Refcounting was here originally but then removed in [1] as it conflicts with
>> virConnectRegisterCloseCallback returns 0 in case 
>> connectRegisterCloseCallback
>> is not implemented. This is safe though (at least nobody touch this place :).
>>
>> [1] ce35122cfe: "daemon: fixup refcounting in close callback handling"”
>>
>>>
 +callback->program = virObjectRef(remoteProgram);
 +/* eventID, callbackID, and legacy are not used */
 +callback->eventID = -1;
 +callback->callbackID = -1;
  if (virConnectRegisterCloseCallback(priv->conn,
  remoteRelayConnectionClosedEvent,
 -client, NULL) < 0)
 +callback, 
 remoteEventCallbackFree) < 0)
  goto cleanup;

>>>
>>> @callback would be leaked in the normal path...
>>
>> By normal path, you mean without the first patch?
>>
>
> I was following how the other register functions proceeded and they
> saved the callback in a list to be freed at unregister.  So if Register
> succeeds, rv == 0 and the removeEventCallbackFree(callback) isn't called
> and we leak callback.  At least that's how I read it

First - sorry for the late response!

The unregister/free’ing is either done within the
'remoteClientFreePrivateCallbacks' call or by an explicit call of
'remoteDispatchConnectUnregisterCloseCallback'. Do we agree on this? If
yes: the function 'remoteClientFreePrivateCallbacks' calls the
virConnectUnregisterCloseCallback -> remoteEventCallbackFree => no
memory leak.

There will be only a memory leak if the virConnectRegisterCloseCallback
call succeeds but the used driver had no support for registering a close
callback (conn->driver->connectRegisterCloseCallback was NULL) AND the
first patch of this series were not applied.

Did I miss something?

>

[…snip…]

>
--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


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

Re: [libvirt] [PATCH libvirt v2 6/9] remote/rpc: Use virNetServerGetProgram() to determine the program

2018-05-07 Thread Marc Hartmayer
On Thu, Apr 26, 2018 at 05:08 PM +0200, John Ferlan  wrote:
> On 04/12/2018 08:41 AM, Marc Hartmayer wrote:
>> Use virNetServerGetProgram() to determine the virNetServerProgram
>> instead of using hard coded global variables. This allows us to remove
>> the global variables @remoteProgram and @qemuProgram as they're now no
>> longer necessary.
>>
>> Signed-off-by: Marc Hartmayer 
>> Reviewed-by: Boris Fiuczynski 
>> ---
>>
>> Note: I'm not 100% sure that there is no case where the lock for
>> @client is already held by the thread which is calling
>> virNetServerGetProgram and thus the lock order would be violated (the
>> lock order has to be @server -> @client in the violating case it would
>> be @client -> @server and therefore a deadlock might occur).
>>
>
> Well the way I read virNetServerProgramDispatchCall it would seem both
> @server and @client must be unlocked:
>
> /*
>  * When the RPC handler is called:
>  *
>  *  - Server object is unlocked
>  *  - Client object is unlocked
>  *
>  * Without locking, it is safe to use:
>  *
>  *   'args and 'ret'
>  */
> rv = (dispatcher->func)(server, client, msg, &rerr, arg, ret);

Thanks for digging into that.

>
>> ---
>>  src/libvirt_remote.syms |   1 +
>>  src/remote/remote_daemon.c  |   4 +-
>>  src/remote/remote_daemon.h  |   3 -
>>  src/remote/remote_daemon_dispatch.c | 116 
>> +++-
>>  src/rpc/gendispatch.pl  |   6 ++
>>  src/rpc/virnetserver.c  |  23 +++
>>  src/rpc/virnetserver.h  |   2 +
>>  7 files changed, 122 insertions(+), 33 deletions(-)
>>
>
> Reviewed-by: John Ferlan 

…and thanks for the review.

>
> John
>
--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


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

[libvirt] [PATCH v2 7/8] docs: documentation for vfio-ccw passthrough

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 docs/drvnodedev.html.in   | 21 -
 docs/formatdomain.html.in | 20 +++-
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in
index 885904d..71a8a57 100644
--- a/docs/drvnodedev.html.in
+++ b/docs/drvnodedev.html.in
@@ -335,8 +335,27 @@
 $ ls /sys/class/mdev_bus//mdev_supported_types
 
 
+  Before creating a mediated device, unbind the device from the respective
+  device driver, eg. subchannel I/O driver for a CCW device. Then bind the
+  device to the respective VFIO driver. For a CCW device, also unbind the
+  corresponding subchannel of the CCW device from the subchannel I/O driver
+  and then bind the subchannel (instead of the CCW device) to the vfio_ccw
+  driver. The below example shows the unbinding and binding steps for a CCW
+  device.
+
+
+
+device="0.0.1234"
+subchannel="0.0.0123"
+echo $device > /sys/bus/ccw/devices/$device/driver/unbind
+echo $subchannel > /sys/bus/css/devices/$subchannel/driver/unbind
+echo $subchannel > /sys/bus/css/drivers/vfio_ccw/bind
+
+
+
   To manually instantiate a mediated device, use one of the following as a
-  reference:
+  reference. For a CCW device, use the subchannel ID instead of the device
+  ID.
 
 
 
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index caeb14e..bcae85e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4311,6 +4311,12 @@
   
+ + +
+ +
+ ... @@ -4362,10 +4368,13 @@ For mediated devices (Since 3.2.0) the model attribute specifies the device API which determines how the host's vfio driver will expose the device to the - guest. Currently, only model='vfio-pci' is supported. - There are also some implications on the usage of guest's address type - depending on the model attribute, see the - address element below. + guest. Currently, model='vfio-pci' and + model='vfio-ccw' (Since 4.4.0) + is supported. Refer MDEV to create + a mediated device on the host. There are also some implications on the + usage of guest's address type depending on the model + attribute, see the address element below. + Note: The managed attribute is only used with @@ -4497,7 +4506,8 @@ devices defining an allocation of resources on the physical parent device, the address type used must conform to the model attribute of element hostdev, e.g. any address type other than PCI for - vfio-pci device API will result in an error. + vfio-pci device API or any address type other than CCW for + vfio-ccw device API will result in an error. See above for more details on the address element. driver -- 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 6/8] tests: tests for vfio-ccw passthrough

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Let us test the following functionalities of vfio-ccw in libvirt
1. Generation of QEMU command line from domain xml file
2. Generation of dump xml from domain xml file
3. Checks duplicate/invalid addresses for vfio-ccw devices.

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
Reviewed-by: Marc Hartmayer 
Reviewed-by: Stefan Zimmermann 
---
 ...tdev-subsys-mdev-vfio-ccw-duplicate-address.xml | 29 ++
 ...ostdev-subsys-mdev-vfio-ccw-invalid-address.xml | 23 +
 .../hostdev-subsys-mdev-vfio-ccw.args  | 26 +++
 .../hostdev-subsys-mdev-vfio-ccw.xml   | 22 
 tests/qemuxml2argvtest.c   | 16 
 .../hostdev-subsys-mdev-vfio-ccw.xml   | 28 +
 tests/qemuxml2xmltest.c|  5 
 7 files changed, 149 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
 create mode 100644 
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
 create mode 100644 tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
 create mode 100644 tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
 create mode 100644 tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml

diff --git 
a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml 
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
new file mode 100644
index 000..4b95fe2
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
@@ -0,0 +1,29 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  524288
+  524288
+  2
+  
+hvm
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-s390x
+
+  
+
+  
+  
+
+
+  
+
+  
+  
+
+  
+
diff --git 
a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml 
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
new file mode 100644
index 000..680090e
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
@@ -0,0 +1,23 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  524288
+  524288
+  2
+  
+hvm
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-s390x
+
+  
+
+  
+  
+
+  
+
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args 
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
new file mode 100644
index 000..56ebf9a
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 512 \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev 
socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-device vfio-ccw,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627,\
+devno=fe.0. \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml 
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
new file mode 100644
index 000..96f30f5
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
@@ -0,0 +1,22 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  524288
+  524288
+  2
+  
+hvm
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-s390x
+
+  
+
+  
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9a05803..bd8d1b4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1539,6 +1539,22 @@ mymain(void)
 DO_TEST("pci-rom-disabled", NONE);
 DO_TEST("pci-rom-disabled-invalid", NONE);
 
+DO_TEST("hostdev-subsys-mdev-vfio-ccw",
+QEMU_CAPS_CCW,
+QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+QEMU_CAPS_DEVICE_VFIO_CCW);
+DO_TEST_FAILURE("hostdev-subsys-mdev-vfio-ccw",
+QEMU_CAPS_CCW,
+QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
+DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-duplicate-address",
+QEMU_CAPS_CCW,
+QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+QEMU_CAPS_DEVICE_VFIO_CCW);
+DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-invalid-address",
+QEMU_CAPS_CCW,
+QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+QEMU_CAPS_DEVICE_VFIO_CCW);
+
 DO_TEST_FULL("restore-v2

[libvirt] [PATCH v2 2/8] qemu: introduce vfio-ccw capability

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Let us introduce the capability vfio-ccw for supporting the basic
channel I/O passthrough, which have been introduced in QEMU 2.10. The
current focus is to support dasd-eckd (cu_type/dev_type = 0x3990/0x3390)
as the target device.

Let us also introduce the capability QEMU_CAPS_CCW_CSSID_UNRESTRICTED
for virtual-css-bridge. This capability is based on the
cssid-unrestricted property which exists if QEMU no longer enforces
cssid restrictions based on ccw device types.

Vfio-ccw capability is dependent on the hidden virtual-css-bridge, so
that we are able to probe for the cssid-unrestriced property to make
sure the devices are visible to non-mcss-e enabled guests.

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/qemu/qemu_capabilities.c   | 14 ++
 src/qemu/qemu_capabilities.h   |  4 +++
 .../qemucapabilitiesdata/caps_2.10.0.s390x.replies | 28 ---
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   |  2 +-
 .../qemucapabilitiesdata/caps_2.11.0.s390x.replies | 28 ---
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml   |  2 +-
 .../qemucapabilitiesdata/caps_2.12.0.s390x.replies | 31 --
 tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml   |  3 +++
 .../qemucapabilitiesdata/caps_2.7.0.s390x.replies  | 24 -
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|  2 +-
 .../qemucapabilitiesdata/caps_2.8.0.s390x.replies  | 28 ---
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|  2 +-
 .../qemucapabilitiesdata/caps_2.9.0.s390x.replies  | 28 ---
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml|  2 +-
 14 files changed, 142 insertions(+), 56 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ae3d2a6..b2e1fab 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -476,6 +476,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "nbd-tls",
   "tpm-crb",
   "virtual-css-bridge",
+
+  /* 295 */
+  "virtual-css-bridge.cssid-unrestricted",
+  "vfio-ccw",
 );
 
 
@@ -1103,6 +1107,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
 { "virtio-tablet-ccw", QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW },
 { "pcie-pci-bridge", QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE },
 { "virtual-css-bridge", QEMU_CAPS_CCW },
+{ "vfio-ccw", QEMU_CAPS_DEVICE_VFIO_CCW },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
@@ -1244,6 +1249,10 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsDevicePropsIntelIOMMU[] = {
 { "device-iotlb", QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB },
 };
 
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtualCSSBridge[] 
= {
+{ "cssid-unrestricted", QEMU_CAPS_CCW_CSSID_UNRESTRICTED },
+};
+
 /* see documentation for virQEMUQAPISchemaPathGet for the query format */
 static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
 { "blockdev-add/arg-type/options/+gluster/debug-level", 
QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
@@ -1369,6 +1378,9 @@ static virQEMUCapsObjectTypeProps 
virQEMUCapsDeviceProps[] = {
 { "virtio-gpu-ccw", virQEMUCapsDevicePropsVirtioGpu,
   ARRAY_CARDINALITY(virQEMUCapsDevicePropsVirtioGpu),
   QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW },
+{ "virtual-css-bridge", virQEMUCapsObjectPropsVirtualCSSBridge,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtualCSSBridge),
+  QEMU_CAPS_CCW },
 };
 
 
@@ -3913,6 +3925,8 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
 if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW) &&
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW))
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_CCW);
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW_CSSID_UNRESTRICTED))
+virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW);
 }
 
 ret = 0;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e8a916c..74ac41d 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -461,6 +461,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
 QEMU_CAPS_DEVICE_TPM_CRB, /* -device tpm-crb */
 QEMU_CAPS_CCW, /* -device virtual-css-bridge */
 
+/* 295 */
+QEMU_CAPS_CCW_CSSID_UNRESTRICTED, /* 
virtual-css-bridge.cssid-unrestricted= */
+QEMU_CAPS_DEVICE_VFIO_CCW, /* -device vfio-ccw */
+
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
 
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.replies 
b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.replies
index 534756f..3e19ac6 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.replies
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.replies
@@ -3405,6 +3405,16 @@
 {
   "return": [
 {
+  "name": "css_dev_

[libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
devices such that CCW address will be generated.

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
Reviewed-by: Marc Hartmayer 
Reviewed-by: Stefan Zimmermann 
---
 docs/schemas/domaincommon.rng  |  5 -
 src/qemu/qemu_domain_address.c | 20 
 src/util/virmdev.c |  3 ++-
 src/util/virmdev.h |  1 +
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 0a6b29b..bea2bc0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4478,7 +4478,10 @@
   mdev
 
 
-  vfio-pci
+  
+vfio-pci
+vfio-ccw
+  
 
 
   
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 50f815c..be0424d 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -282,6 +282,23 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
 
 
 static void
+qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def,
+  virDomainDeviceAddressType type)
+{
+size_t i;
+
+for (i = 0; i < def->nhostdevs; i++) {
+virDomainHostdevSubsysPtr subsys = &def->hostdevs[i]->source.subsys;
+
+if (virHostdevIsMdevDevice(def->hostdevs[i]) &&
+subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
+def->hostdevs[i]->info->type == 
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+def->hostdevs[i]->info->type = type;
+}
+}
+
+
+static void
 qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
  virDomainDeviceAddressType type)
 {
@@ -397,6 +414,9 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
 
 if (qemuDomainIsS390CCW(def) &&
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW))
+qemuDomainPrimeVfioDeviceAddresses(
+def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
 qemuDomainPrimeVirtioDeviceAddresses(
 def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
 
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 536ddbe..6c51388 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -48,7 +48,8 @@ struct _virMediatedDeviceList {
 };
 
 VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST,
-  "vfio-pci")
+  "vfio-pci",
+  "vfio-ccw")
 
 static virClassPtr virMediatedDeviceListClass;
 
diff --git a/src/util/virmdev.h b/src/util/virmdev.h
index 01ab02e..cfda2ca 100644
--- a/src/util/virmdev.h
+++ b/src/util/virmdev.h
@@ -25,6 +25,7 @@
 
 typedef enum {
 VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
+VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
 
 VIR_MDEV_MODEL_TYPE_LAST
 } virMediatedDeviceModelType;
-- 
2.9.4

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


[libvirt] [dbus PATCH 17/19] Implement Refresh method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Test will should be added when
VIR_STORAGE_POOL_EVENT_ID_REFRESH signal will be implemented.

Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 25 +
 2 files changed, 30 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 31abd34..8ebab33 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -55,5 +55,10 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRefresh"/>
+  
+
   
 
diff --git a/src/storagepool.c b/src/storagepool.c
index c38e029..aa0e280 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -280,6 +280,30 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs,
 *outArgs = g_variant_new("(s)", xml);
 }
 
+static void
+virtDBusStoragePoolRefresh(GVariant *inArgs,
+   GUnixFDList *inFDs G_GNUC_UNUSED,
+   const gchar *objectPath,
+   gpointer userData,
+   GVariant **outArgs G_GNUC_UNUSED,
+   GUnixFDList **outFDs G_GNUC_UNUSED,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+guint flags;
+
+g_variant_get(inArgs, "(u)", &flags);
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolRefresh(storagePool, flags) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { "Active", virtDBusStoragePoolGetActive, NULL },
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
@@ -296,6 +320,7 @@ static virtDBusGDBusMethodTable 
virtDBusStoragePoolMethodTable[] = {
 { "Destroy", virtDBusStoragePoolDestroy },
 { "GetInfo", virtDBusStoragePoolGetInfo },
 { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc },
+{ "Refresh", virtDBusStoragePoolRefresh },
 { 0 }
 };
 
-- 
2.15.0

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


[libvirt] [PATCH v2 0/8] vfio-ccw passthrough support

2018-05-07 Thread Boris Fiuczynski
Let us support the basic channel I/O passthrough infrastructure based on
vfio, which have been introduced in QEMU 2.10. The current focus is to
support dasd-eckd (cu_type/dev_type = 0x3990/0x3390) as the target
device.

Shalini Chellathurai Saroja (8):
  qemu: introduce capability for virtual-css-bridge
  qemu: introduce vfio-ccw capability
  util: virhostdev: add virHostdevIsMdevDevice()
  qemu: vfio-ccw device address generation
  qemu: command line generation for vfio-ccw device
  tests: tests for vfio-ccw passthrough
  docs: documentation for vfio-ccw passthrough
  news: documentation of new feature

 docs/drvnodedev.html.in|  21 -
 docs/formatdomain.html.in  |  20 +++-
 docs/news.xml  |   9 ++
 docs/schemas/domaincommon.rng  |   5 +-
 src/libvirt_private.syms   |   1 +
 src/qemu/qemu_capabilities.c   |  23 +
 src/qemu/qemu_capabilities.h   |   5 +
 src/qemu/qemu_command.c|  37 ++--
 src/qemu/qemu_domain.c |   2 +-
 src/qemu/qemu_domain_address.c |  32 +--
 src/qemu/qemu_hostdev.c|   3 +-
 src/qemu/qemu_hotplug.c|   4 +-
 src/util/virhostdev.c  |  26 --
 src/util/virhostdev.h  |   3 +
 src/util/virmdev.c |   3 +-
 src/util/virmdev.h |   1 +
 .../qemucapabilitiesdata/caps_2.10.0.s390x.replies |  28 --
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   |   3 +-
 .../qemucapabilitiesdata/caps_2.11.0.s390x.replies |  28 --
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml   |   3 +-
 .../qemucapabilitiesdata/caps_2.12.0.s390x.replies |  31 +--
 tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml   |   3 +
 .../qemucapabilitiesdata/caps_2.7.0.s390x.replies  |  24 +++--
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|   3 +-
 .../qemucapabilitiesdata/caps_2.8.0.s390x.replies  |  28 --
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|   3 +-
 .../qemucapabilitiesdata/caps_2.9.0.s390x.replies  |  28 --
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml|   3 +-
 tests/qemuhotplugtest.c|   2 +-
 ...tdev-subsys-mdev-vfio-ccw-duplicate-address.xml |  29 ++
 ...ostdev-subsys-mdev-vfio-ccw-invalid-address.xml |  23 +
 .../hostdev-subsys-mdev-vfio-ccw.args  |  26 ++
 .../hostdev-subsys-mdev-vfio-ccw.xml   |  22 +
 tests/qemuxml2argvtest.c   | 102 -
 .../hostdev-subsys-mdev-vfio-ccw.xml   |  28 ++
 tests/qemuxml2xmltest.c|  31 ---
 36 files changed, 494 insertions(+), 149 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
 create mode 100644 
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
 create mode 100644 tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
 create mode 100644 tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
 create mode 100644 tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml

-- 
2.9.4

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


[libvirt] [dbus PATCH 19/19] Implement Undefine method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  4 
 src/storagepool.c| 22 ++
 tests/test_storage.py| 18 ++
 3 files changed, 44 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 9d59818..d7e19d0 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -61,5 +61,9 @@
 value="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRefresh"/>
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolUndefine"/>
+
   
 
diff --git a/src/storagepool.c b/src/storagepool.c
index a40db14..c8b6467 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -325,6 +325,27 @@ virtDBusStoragePoolRefresh(GVariant *inArgs,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolUndefine(GVariant *inArgs G_GNUC_UNUSED,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath,
+gpointer userData,
+GVariant **outArgs G_GNUC_UNUSED,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolUndefine(storagePool) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { "Active", virtDBusStoragePoolGetActive, NULL },
 { "Autostart", virtDBusStoragePoolGetAutostart,
@@ -343,6 +364,7 @@ static virtDBusGDBusMethodTable 
virtDBusStoragePoolMethodTable[] = {
 { "GetInfo", virtDBusStoragePoolGetInfo },
 { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc },
 { "Refresh", virtDBusStoragePoolRefresh },
+{ "Undefine", virtDBusStoragePoolUndefine },
 { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 2d87e08..d2cbbb5 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -89,6 +89,24 @@ class TestStoragePool(libvirttest.BaseTestClass):
 assert isinstance(props['Persistent'], dbus.Boolean)
 assert isinstance(props['UUID'], dbus.String)
 
+def test_storage_pool_undefine(self):
+def storage_pool_undefined(path, event, _detail):
+if event != libvirttest.StoragePoolEvent.UNDEFINED:
+return
+assert isinstance(path, dbus.ObjectPath)
+self.loop.quit()
+
+self.connect.connect_to_signal('StoragePoolEvent',
+   storage_pool_undefined)
+
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+interface_obj.Destroy()
+interface_obj.Undefine()
+
+self.main_loop()
+
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

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


[libvirt] [dbus PATCH 10/19] Implement Name property for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  4 
 src/storagepool.c| 23 +++
 tests/test_storage.py|  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 29d501b..8bc90b7 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -8,6 +8,10 @@
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index a7bcc94..f81a670 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -45,6 +45,28 @@ virtDBusStoragePoolGetAutostart(const gchar *objectPath,
 *value = g_variant_new("b", !!autostart);
 }
 
+static void
+virtDBusStoragePoolGetName(const gchar *objectPath,
+   gpointer userData,
+   GVariant **value,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+const gchar *name;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+name = virStoragePoolGetName(storagePool);
+if (!name)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", name);
+}
+
 static void
 virtDBusStoragePoolBuild(GVariant *inArgs,
  GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -167,6 +189,7 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED,
 
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
+{ "Name", virtDBusStoragePoolGetName, NULL },
 { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 116385b..8e73228 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -64,6 +64,7 @@ class TestStoragePool(libvirttest.BaseTestClass):
 props = obj.GetAll('org.libvirt.StoragePool',
dbus_interface=dbus.PROPERTIES_IFACE)
 assert isinstance(props['Autostart'], dbus.Boolean)
+assert isinstance(props['Name'], dbus.String)
 
 
 if __name__ == '__main__':
-- 
2.15.0

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


[libvirt] [dbus PATCH 06/19] Implement Create method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 25 +
 tests/test_storage.py| 17 +
 3 files changed, 47 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index f96e676..7e837c0 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -8,6 +8,11 @@
 value="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolCreate"/>
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index d23c847..d4cd7a7 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -48,6 +48,30 @@ virtDBusStoragePoolBuild(GVariant *inArgs,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolCreate(GVariant *inArgs,
+  GUnixFDList *inFDs G_GNUC_UNUSED,
+  const gchar *objectPath,
+  gpointer userData,
+  GVariant **outArgs G_GNUC_UNUSED,
+  GUnixFDList **outFDs G_GNUC_UNUSED,
+  GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+guint flags;
+
+g_variant_get(inArgs, "(u)", &flags);
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolCreate(storagePool, flags) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -75,6 +99,7 @@ static virtDBusGDBusPropertyTable 
virtDBusStoragePoolPropertyTable[] = {
 
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
 { "Build", virtDBusStoragePoolBuild },
+{ "Create", virtDBusStoragePoolCreate },
 { "Destroy", virtDBusStoragePoolDestroy },
 { 0 }
 };
diff --git a/tests/test_storage.py b/tests/test_storage.py
index cf13024..b1927cb 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -11,6 +11,23 @@ class TestStoragePool(libvirttest.BaseTestClass):
 interface_obj.Destroy()
 interface_obj.Build(libvirttest.StoragePoolBuildFlags.NEW)
 
+def test_storage_pool_create(self):
+def storage_pool_started(path, event, _detail):
+if event != libvirttest.StoragePoolEvent.STARTED:
+return
+assert isinstance(path, dbus.ObjectPath)
+self.loop.quit()
+
+self.connect.connect_to_signal('StoragePoolEvent', 
storage_pool_started)
+
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+interface_obj.Destroy()
+interface_obj.Create(0)
+
+self.main_loop()
+
 def test_storage_pool_destroy(self):
 def storage_pool_destroyed(path, event, _detail):
 if event != libvirttest.StoragePoolEvent.STOPPED:
-- 
2.15.0

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


[libvirt] [dbus PATCH 07/19] Implement Delete method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
VIR_STORAGE_POOL_EVENT_DELETED event was added in 3.1.
Test should be fixed later on to use signal handler.

Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 25 +
 tests/test_storage.py|  7 +++
 3 files changed, 37 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 7e837c0..fb21e59 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -13,6 +13,11 @@
 value="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolCreate"/>
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDelete"/>
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index d4cd7a7..bf1fd3f 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -72,6 +72,30 @@ virtDBusStoragePoolCreate(GVariant *inArgs,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolDelete(GVariant *inArgs,
+  GUnixFDList *inFDs G_GNUC_UNUSED,
+  const gchar *objectPath,
+  gpointer userData,
+  GVariant **outArgs G_GNUC_UNUSED,
+  GUnixFDList **outFDs G_GNUC_UNUSED,
+  GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+guint flags;
+
+g_variant_get(inArgs, "(u)", &flags);
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolDelete(storagePool, flags) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -100,6 +124,7 @@ static virtDBusGDBusPropertyTable 
virtDBusStoragePoolPropertyTable[] = {
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
 { "Build", virtDBusStoragePoolBuild },
 { "Create", virtDBusStoragePoolCreate },
+{ "Delete", virtDBusStoragePoolDelete },
 { "Destroy", virtDBusStoragePoolDestroy },
 { 0 }
 };
diff --git a/tests/test_storage.py b/tests/test_storage.py
index b1927cb..c4c7cf1 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -28,6 +28,13 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
 self.main_loop()
 
+def test_storage_pool_delete(self):
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+interface_obj.Destroy()
+interface_obj.Delete(0)
+
 def test_storage_pool_destroy(self):
 def storage_pool_destroyed(path, event, _detail):
 if event != libvirttest.StoragePoolEvent.STOPPED:
-- 
2.15.0

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


[libvirt] [dbus PATCH 00/19] StoragePool APIs till libvirt 3.0

2018-05-07 Thread Katerina Koukiou
Katerina Koukiou (19):
  Introduce StoragePool Interface
  Implement ListStoragePools method for Connect Interface
  Register StoragePool Lifecycle Events
  Implement Destroy method for StoragePool Interface
  Implement Build method for StoragePool Interface
  Implement Create method for StoragePool Interface
  Implement Delete method for StoragePool Interface
  Implement getter for Autostart property for StoragePool Interface
  Implement GetInfo method for StoragePool Interface
  Implement Name property for StoragePool Interface
  Implement UUID property for StoragePool Interface
  Implement GetXMLDesc method for StoragePool Interface
  Implement Active property for StoragePool Interface
  Implement Persistent property for StoragePool Interface
  Implement StoragePoolLookupByName method for Connect Interface
  Implement StoragePoolLookupByUUID method for Connect Interface
  Implement Refresh method for StoragePool Interface
  Implement setter for Autostart property for StoragePool Interface
  Implement Undefine method for StoragePool Interface

 data/Makefile.am |   3 +-
 data/org.libvirt.Connect.xml |  24 +++
 data/org.libvirt.StoragePool.xml |  69 +++
 src/Makefile.am  |   3 +-
 src/connect.c| 120 +++
 src/connect.h|   2 +
 src/events.c |  43 
 src/storagepool.c| 422 +++
 src/storagepool.h|   9 +
 src/util.c   |  33 +++
 src/util.h   |  15 ++
 tests/libvirttest.py |  29 +++
 tests/test_connect.py|  28 +++
 tests/test_storage.py| 112 +++
 14 files changed, 910 insertions(+), 2 deletions(-)
 create mode 100644 data/org.libvirt.StoragePool.xml
 create mode 100644 src/storagepool.c
 create mode 100644 src/storagepool.h
 create mode 100755 tests/test_storage.py

-- 
2.15.0

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


[libvirt] [dbus PATCH 03/19] Register StoragePool Lifecycle Events

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  7 +++
 src/connect.c| 13 +
 src/connect.h|  1 +
 src/events.c | 43 +++
 4 files changed, 64 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 9207295..6b156d1 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -230,5 +230,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virConnectStoragePoolEventLifecycleCallback"/>
+  
+  
+  
+
   
 
diff --git a/src/connect.c b/src/connect.c
index 858db43..97c4857 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -60,6 +60,16 @@ virtDBusConnectClose(virtDBusConnect *connect,
 }
 }
 
+for (gint i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) {
+if (connect->storagePoolCallbackIds[i] >= 0) {
+if (deregisterEvents) {
+virConnectStoragePoolEventDeregisterAny(connect->connection,
+
connect->storagePoolCallbackIds[i]);
+}
+connect->storagePoolCallbackIds[i] = -1;
+}
+}
+
 virConnectClose(connect->connection);
 connect->connection = NULL;
 }
@@ -1177,6 +1187,9 @@ virtDBusConnectNew(virtDBusConnect **connectp,
 for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++)
 connect->networkCallbackIds[i] = -1;
 
+for (gint i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++)
+connect->storagePoolCallbackIds[i] = -1;
+
 connect->bus = bus;
 connect->uri = uri;
 connect->connectPath = connectPath;
diff --git a/src/connect.h b/src/connect.h
index d6c3830..b4df048 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -20,6 +20,7 @@ struct virtDBusConnect {
 
 gint domainCallbackIds[VIR_DOMAIN_EVENT_ID_LAST];
 gint networkCallbackIds[VIR_NETWORK_EVENT_ID_LAST];
+gint storagePoolCallbackIds[VIR_STORAGE_POOL_EVENT_ID_LAST];
 };
 typedef struct virtDBusConnect virtDBusConnect;
 
diff --git a/src/events.c b/src/events.c
index ea55180..04967c2 100644
--- a/src/events.c
+++ b/src/events.c
@@ -143,6 +143,30 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connection 
G_GNUC_UNUSED,
 return 0;
 }
 
+static gint
+virtDBusEventsStoragePoolLifecycle(virConnectPtr connection G_GNUC_UNUSED,
+   virStoragePoolPtr storagePool,
+   gint event,
+   gint detail,
+   gpointer opaque)
+{
+virtDBusConnect *connect = opaque;
+g_autofree gchar *path = NULL;
+
+path = virtDBusUtilBusPathForVirStoragePool(storagePool,
+connect->storagePoolPath);
+
+g_dbus_connection_emit_signal(connect->bus,
+  NULL,
+  connect->connectPath,
+  VIRT_DBUS_CONNECT_INTERFACE,
+  "StoragePoolEvent",
+  g_variant_new("(ouu)", path, event, detail),
+  NULL);
+
+return 0;
+}
+
 static void
 virtDBusEventsRegisterDomainEvent(virtDBusConnect *connect,
   gint id,
@@ -173,6 +197,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect 
*connect,
 NULL);
 }
 
+static void
+virtDBusEventsRegisterStoragePoolEvent(virtDBusConnect *connect,
+   gint id,
+   
virConnectStoragePoolEventGenericCallback callback)
+{
+g_assert(connect->storagePoolCallbackIds[id] == -1);
+
+connect->storagePoolCallbackIds[id] = 
virConnectStoragePoolEventRegisterAny(connect->connection,
+   
 NULL,
+   
 id,
+   
 VIR_STORAGE_POOL_EVENT_CALLBACK(callback),
+   
 connect,
+   
 NULL);
+}
+
 void
 virtDBusEventsRegister(virtDBusConnect *connect)
 {
@@ -199,4 +238,8 @@ virtDBusEventsRegister(virtDBusConnect *connect)
 virtDBusEventsRegisterNetworkEvent(connect,
VIR_NETWORK_EVENT_ID_LIFECYCLE,

VIR_NETWORK_EVENT_CALLBACK(virtDBusEventsNetworkLifecycle));
+
+virtDBusEventsRegisterStoragePoolEvent(connect,
+   VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
+   
VIR_STORAGE_POOL_EVENT_CALLBACK(vi

[libvirt] [dbus PATCH 01/19] Introduce StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/Makefile.am |  3 +-
 data/org.libvirt.StoragePool.xml |  7 +
 src/Makefile.am  |  3 +-
 src/connect.c|  6 
 src/connect.h|  1 +
 src/storagepool.c| 65 
 src/storagepool.h|  9 ++
 src/util.c   | 33 
 src/util.h   | 16 ++
 9 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 data/org.libvirt.StoragePool.xml
 create mode 100644 src/storagepool.c
 create mode 100644 src/storagepool.h

diff --git a/data/Makefile.am b/data/Makefile.am
index 61702df..4d2af45 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -21,7 +21,8 @@ polkit_DATA = $(polkit_files:.rules.in=.rules)
 interfaces_files = \
org.libvirt.Connect.xml \
org.libvirt.Domain.xml \
-   org.libvirt.Network.xml
+   org.libvirt.Network.xml \
+   org.libvirt.StoragePool.xml
 interfacesdir = $(DBUS_INTERFACES_DIR)
 interfaces_DATA = $(interfaces_files)
 
diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
new file mode 100644
index 000..504a166
--- /dev/null
+++ b/data/org.libvirt.StoragePool.xml
@@ -0,0 +1,7 @@
+http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+
+
+  
+  
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 158398a..5e082da 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,8 @@ DAEMON_SOURCES = \
domain.c domain.h \
events.c events.h \
gdbus.c gdbus.h \
-   network.c network.h
+   network.c network.h \
+   storagepool.c storagepool.h
 
 EXTRA_DIST = \
$(DAEMON_SOURCES)
diff --git a/src/connect.c b/src/connect.c
index fd335e3..e838e98 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -2,6 +2,7 @@
 #include "domain.h"
 #include "events.h"
 #include "network.h"
+#include "storagepool.h"
 #include "util.h"
 
 #include 
@@ -1105,6 +1106,7 @@ virtDBusConnectFree(virtDBusConnect *connect)
 
 g_free(connect->domainPath);
 g_free(connect->networkPath);
+g_free(connect->storagePoolPath);
 g_free(connect);
 }
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virtDBusConnect, virtDBusConnectFree);
@@ -1154,6 +1156,10 @@ virtDBusConnectNew(virtDBusConnect **connectp,
 if (error && *error)
 return;
 
+virtDBusStoragePoolRegister(connect, error);
+if (error && *error)
+return;
+
 *connectp = connect;
 connect = NULL;
 }
diff --git a/src/connect.h b/src/connect.h
index f89bc9d..d6c3830 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -14,6 +14,7 @@ struct virtDBusConnect {
 const gchar *connectPath;
 gchar *domainPath;
 gchar *networkPath;
+gchar *storagePoolPath;
 virConnectPtr connection;
 GMutex lock;
 
diff --git a/src/storagepool.c b/src/storagepool.c
new file mode 100644
index 000..f1421ef
--- /dev/null
+++ b/src/storagepool.c
@@ -0,0 +1,65 @@
+#include "storagepool.h"
+#include "util.h"
+
+#include 
+
+static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
+{ 0 }
+};
+
+static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
+{ 0 }
+};
+
+static gchar **
+virtDBusStoragePoolEnumerate(gpointer userData)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePoolPtr) storagePools = NULL;
+gint num = 0;
+gchar **ret = NULL;
+
+if (!virtDBusConnectOpen(connect, NULL))
+return NULL;
+
+num = virConnectListAllStoragePools(connect->connection, &storagePools, 0);
+if (num < 0)
+return NULL;
+
+if (num == 0)
+return NULL;
+
+ret = g_new0(gchar *, num + 1);
+
+for (gint i = 0; i < num; i++) {
+ret[i] = virtDBusUtilBusPathForVirStoragePool(storagePools[i],
+  
connect->storagePoolPath);
+}
+
+return ret;
+}
+
+static GDBusInterfaceInfo *interfaceInfo;
+
+void
+virtDBusStoragePoolRegister(virtDBusConnect *connect,
+GError **error)
+{
+connect->storagePoolPath = g_strdup_printf("%s/storagepool",
+   connect->connectPath);
+
+if (!interfaceInfo) {
+interfaceInfo = 
virtDBusGDBusLoadIntrospectData(VIRT_DBUS_STORAGEPOOL_INTERFACE,
+error);
+if (!interfaceInfo)
+return;
+}
+
+virtDBusGDBusRegisterSubtree(connect->bus,
+ connect->storagePoolPath,
+ interfaceInfo,
+ virtDBusStoragePoolEnumerate,
+ virtDBusStoragePoolMethodTable,
+ virtDBusStoragePoolPropertyTable,
+ connect);
+}
diff --git a/src/storagepool.h b/src/storagepool.h
new file mode 100644
index 0

[libvirt] [PATCH v2 8/8] news: documentation of new feature

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Boris Fiuczynski 
---
 docs/news.xml | 9 +
 1 file changed, 9 insertions(+)

diff --git a/docs/news.xml b/docs/news.xml
index 8018141..2d6fcf6 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -35,6 +35,15 @@
 
   
 
+  
+
+  qemu: Provide VFIO channel I/O passthrough support
+
+
+  Support passthrough devices that use channel I/O based mechanism in
+  a QEMU virtual machine.
+
+  
 
 
 
-- 
2.9.4

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


[libvirt] [PATCH v2 3/8] util: virhostdev: add virHostdevIsMdevDevice()

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Add the function virHostdevIsMdevDevice() which detects whether a
hostdev is a mediated device or not. Also, replace all existing
conditionals.

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/libvirt_private.syms   |  1 +
 src/qemu/qemu_command.c|  4 +---
 src/qemu/qemu_domain_address.c |  8 
 src/qemu/qemu_hostdev.c|  3 +--
 src/util/virhostdev.c  | 26 +-
 src/util/virhostdev.h  |  3 +++
 6 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 92b5e0f..36150a3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1925,6 +1925,7 @@ virHostCPUStatsAssign;
 
 # util/virhostdev.h
 virHostdevFindUSBDevice;
+virHostdevIsMdevDevice;
 virHostdevIsSCSIDevice;
 virHostdevManagerGetDefault;
 virHostdevPCINodeDeviceDetach;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 50b0ffc..df1c046 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5294,9 +5294,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
 }
 
 /* MDEV */
-if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
-subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
-
+if (virHostdevIsMdevDevice(hostdev)) {
 if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("VFIO PCI device assignment is not "
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 8a5ff74..50f815c 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -655,10 +655,10 @@ 
qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
 virPCIDevicePtr pciDev;
 virPCIDeviceAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr;
 
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
-(hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI 
&&
- hostdev->source.subsys.type != 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
- hostdev->source.subsys.type != 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST)) {
+if (!virHostdevIsMdevDevice(hostdev) &&
+(hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+ (hostdev->source.subsys.type != 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+  hostdev->source.subsys.type != 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST))) {
 return 0;
 }
 
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index d2b5460..955b5df 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -339,8 +339,7 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr driver,
 supportsVFIO = virFileExists("/dev/vfio/vfio");
 
 for (i = 0; i < nhostdevs; i++) {
-if (hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
-hostdevs[i]->source.subsys.type == 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
+if (virHostdevIsMdevDevice(hostdevs[i])) {
 if (!supportsVFIO) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Mediated host device assignment requires "
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index db10b7a..f4bd19d 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -372,6 +372,20 @@ virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev)
 }
 
 
+/**
+ * virHostdevIsMdevDevice:
+ * @hostdev: host device to check
+ *
+ * Returns true if @hostdev is a Mediated device, false otherwise.
+ */
+bool
+virHostdevIsMdevDevice(virDomainHostdevDefPtr hostdev)
+{
+return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV;
+}
+
+
 static int
 virHostdevNetConfigVirtPortProfile(const char *linkdev, int vf,
virNetDevVPortProfilePtr virtPort,
@@ -1330,10 +1344,8 @@ 
virHostdevUpdateActiveMediatedDevices(virHostdevManagerPtr mgr,
 
 mdevsrc = &hostdev->source.subsys.u.mdev;
 
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
-hostdev->source.subsys.type != 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
+if (!virHostdevIsMdevDevice(hostdev))
 continue;
-}
 
 if (!(mdev = virMediatedDeviceNew(mdevsrc->uuidstr, mdevsrc->model)))
 goto cleanup;
@@ -1828,9 +1840,7 @@ virHostdevPrepareMediatedDevices(virHostdevManagerPtr mgr,
 virDomainHostdevSubsysMediatedDevPtr src = 
&hostdev->source.subsys.u.mdev;
 virMediatedDevicePtr mdev;
 
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
-continue;
-if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV)
+if (!virHostdevIsMdevDevice(hostdev

[libvirt] [dbus PATCH 18/19] Implement setter for Autostart property for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +++--
 src/storagepool.c| 24 +++-
 tests/test_storage.py| 13 +
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 8ebab33..9d59818 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -8,9 +8,10 @@
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsActive"/>
 
-
+
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart"/>
+  value="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart
+ 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolSetAutostart"/>
 
 
   https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 11/19] Implement UUID property for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 22 ++
 tests/test_storage.py|  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 8bc90b7..a60ef84 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -12,6 +12,11 @@
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetUUIDString"/>
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index f81a670..43e8040 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -67,6 +67,27 @@ virtDBusStoragePoolGetName(const gchar *objectPath,
 *value = g_variant_new("s", name);
 }
 
+static void
+virtDBusStoragePoolGetUUID(const gchar *objectPath,
+   gpointer userData,
+   GVariant **value,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+gchar uuid[VIR_UUID_STRING_BUFLEN] = "";
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolGetUUIDString(storagePool, uuid) < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", uuid);
+}
+
 static void
 virtDBusStoragePoolBuild(GVariant *inArgs,
  GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -190,6 +211,7 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED,
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
 { "Name", virtDBusStoragePoolGetName, NULL },
+{ "UUID", virtDBusStoragePoolGetUUID, NULL },
 { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 8e73228..3e67633 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -65,6 +65,7 @@ class TestStoragePool(libvirttest.BaseTestClass):
dbus_interface=dbus.PROPERTIES_IFACE)
 assert isinstance(props['Autostart'], dbus.Boolean)
 assert isinstance(props['Name'], dbus.String)
+assert isinstance(props['UUID'], dbus.String)
 
 
 if __name__ == '__main__':
-- 
2.15.0

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


[libvirt] [dbus PATCH 05/19] Implement Build method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
VIR_STORAGE_POOL_EVENT_CREATED event was added in 3.1.
Test should be fixed later on to use signal handler.

Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 25 +
 tests/libvirttest.py |  8 
 tests/test_storage.py|  8 +++-
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index ac628d9..f96e676 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -3,6 +3,11 @@
 
 
   
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index 5202f9e..d23c847 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -24,6 +24,30 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect 
*connect,
 return storagePool;
 }
 
+static void
+virtDBusStoragePoolBuild(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath,
+ gpointer userData,
+ GVariant **outArgs G_GNUC_UNUSED,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+guint flags;
+
+g_variant_get(inArgs, "(u)", &flags);
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolBuild(storagePool, flags) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -50,6 +74,7 @@ static virtDBusGDBusPropertyTable 
virtDBusStoragePoolPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
+{ "Build", virtDBusStoragePoolBuild },
 { "Destroy", virtDBusStoragePoolDestroy },
 { 0 }
 };
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index e88484f..3cd02ef 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -187,6 +187,14 @@ class NetworkEvent(IntEnum):
 STOPPED = 3
 
 
+class StoragePoolBuildFlags(IntEnum):
+NEW = 0
+REPAIR = 1
+RESIZE = 2
+NO_OVERWRITE = 4
+OVERWRITE = 8
+
+
 class StoragePoolEvent(IntEnum):
 DEFINED = 0
 UNDEFINED = 1
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 8c5d75f..cf13024 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -4,6 +4,13 @@ import dbus
 import libvirttest
 
 class TestStoragePool(libvirttest.BaseTestClass):
+def test_storage_pool_build(self):
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+interface_obj.Destroy()
+interface_obj.Build(libvirttest.StoragePoolBuildFlags.NEW)
+
 def test_storage_pool_destroy(self):
 def storage_pool_destroyed(path, event, _detail):
 if event != libvirttest.StoragePoolEvent.STOPPED:
@@ -13,7 +20,6 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
 self.connect.connect_to_signal('StoragePoolEvent',
storage_pool_destroyed)
-
 _, test_storage_pool = self.test_storage_pool()
 interface_obj = dbus.Interface(test_storage_pool,
'org.libvirt.StoragePool')
-- 
2.15.0

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


[libvirt] [dbus PATCH 04/19] Implement Destroy method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  4 
 src/storagepool.c| 43 
 tests/libvirttest.py | 21 
 tests/test_storage.py| 26 
 4 files changed, 94 insertions(+)
 create mode 100755 tests/test_storage.py

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 504a166..ac628d9 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -3,5 +3,9 @@
 
 
   
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/>
+
   
 
diff --git a/src/storagepool.c b/src/storagepool.c
index f1421ef..5202f9e 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -3,11 +3,54 @@
 
 #include 
 
+static virStoragePoolPtr
+virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *connect,
+ const gchar *objectPath,
+ GError **error)
+{
+virStoragePoolPtr storagePool;
+
+if (virtDBusConnectOpen(connect, error) < 0)
+return NULL;
+
+storagePool = virtDBusUtilVirStoragePoolFromBusPath(connect->connection,
+objectPath,
+
connect->storagePoolPath);
+if (!storagePool) {
+virtDBusUtilSetLastVirtError(error);
+return NULL;
+}
+
+return storagePool;
+}
+
+static void
+virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
+   GUnixFDList *inFDs G_GNUC_UNUSED,
+   const gchar *objectPath,
+   gpointer userData,
+   GVariant **outArgs G_GNUC_UNUSED,
+   GUnixFDList **outFDs G_GNUC_UNUSED,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolDestroy(storagePool) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { 0 }
 };
 
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
+{ "Destroy", virtDBusStoragePoolDestroy },
 { 0 }
 };
 
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index eee67a0..e88484f 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -87,6 +87,19 @@ class BaseTestClass():
 obj = self.bus.get_object('org.libvirt', path)
 return path, obj
 
+def test_storage_pool(self):
+"""Fetch information for the test storage pool from test driver
+
+Returns:
+(dbus.proxies.ProxyObject, dbus.proxies.ProxyObject):
+Test StoragePool Object, Local proxy for the test StoragePool
+Object.
+
+"""
+path = self.connect.ListStoragePools(0)[0]
+obj = self.bus.get_object('org.libvirt', path)
+return path, obj
+
 
 class DomainEvent(IntEnum):
 DEFINED = 0
@@ -172,3 +185,11 @@ class NetworkEvent(IntEnum):
 UNDEFINED = 1
 STARTED = 2
 STOPPED = 3
+
+
+class StoragePoolEvent(IntEnum):
+DEFINED = 0
+UNDEFINED = 1
+STARTED = 2
+STOPPED = 3
+LAST = 4
diff --git a/tests/test_storage.py b/tests/test_storage.py
new file mode 100755
index 000..8c5d75f
--- /dev/null
+++ b/tests/test_storage.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+import dbus
+import libvirttest
+
+class TestStoragePool(libvirttest.BaseTestClass):
+def test_storage_pool_destroy(self):
+def storage_pool_destroyed(path, event, _detail):
+if event != libvirttest.StoragePoolEvent.STOPPED:
+return
+assert isinstance(path, dbus.ObjectPath)
+self.loop.quit()
+
+self.connect.connect_to_signal('StoragePoolEvent',
+   storage_pool_destroyed)
+
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+interface_obj.Destroy()
+
+self.main_loop()
+
+
+if __name__ == '__main__':
+libvirttest.run()
-- 
2.15.0

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


[libvirt] [PATCH v2 5/8] qemu: command line generation for vfio-ccw device

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Generates the QEMU command line for the vfio-ccw device.

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
Reviewed-by: Marc Hartmayer 
---
 src/qemu/qemu_command.c | 33 -
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index df1c046..ea545b3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5071,11 +5071,17 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
 virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
 char *ret = NULL;
 char *mdevPath = NULL;
+const char *dev_str = NULL;
 
 if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)))
 goto cleanup;
 
-virBufferAddLit(&buf, "vfio-pci");
+dev_str = virMediatedDeviceModelTypeToString(mdevsrc->model);
+
+if (!dev_str)
+goto cleanup;
+
+virBufferAdd(&buf, dev_str, -1);
 virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias, mdevPath);
 
 if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
@@ -5295,11 +5301,28 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
 
 /* MDEV */
 if (virHostdevIsMdevDevice(hostdev)) {
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("VFIO PCI device assignment is not "
- "supported by this version of qemu"));
+switch ((virMediatedDeviceModelType) subsys->u.mdev.model) {
+case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("VFIO PCI device assignment is not "
+ "supported by this version of QEMU"));
+return -1;
+}
+break;
+case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("VFIO CCW device assignment is not "
+ "supported by this version of QEMU"));
+return -1;
+}
+break;
+case VIR_MDEV_MODEL_TYPE_LAST:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("unexpected vfio type '%d'"), 
subsys->u.mdev.model);
 return -1;
+break;
 }
 
 virCommandAddArg(cmd, "-device");
-- 
2.9.4

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


[libvirt] [dbus PATCH 15/19] Implement StoragePoolLookupByName method for Connect Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 ++
 src/connect.c| 30 ++
 tests/test_connect.py| 15 +++
 3 files changed, 51 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 6b156d1..55c0883 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -217,6 +217,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByName"/>
+  
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
diff --git a/src/connect.c b/src/connect.c
index 97c4857..fa4078f 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1104,6 +1104,35 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inArgs,
 }
 }
 
+static void
+virtDBusConnectStoragePoolLookupByName(GVariant *inArgs,
+   GUnixFDList *inFDs G_GNUC_UNUSED,
+   const gchar *objectPath G_GNUC_UNUSED,
+   gpointer userData,
+   GVariant **outArgs,
+   GUnixFDList **outFDs G_GNUC_UNUSED,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+g_autofree gchar *path = NULL;
+const gchar *name;
+
+g_variant_get(inArgs, "(s)", &name);
+
+if (!virtDBusConnectOpen(connect, error))
+return;
+
+storagePool = virStoragePoolLookupByName(connect->connection, name);
+if (!storagePool)
+return virtDBusUtilSetLastVirtError(error);
+
+path = virtDBusUtilBusPathForVirStoragePool(storagePool,
+connect->storagePoolPath);
+
+*outArgs = g_variant_new("(o)", path);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
 { "Encrypted", virtDBusConnectGetEncrypted, NULL },
 { "Hostname", virtDBusConnectGetHostname, NULL },
@@ -1143,6 +1172,7 @@ static virtDBusGDBusMethodTable 
virtDBusConnectMethodTable[] = {
 { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats },
 { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel },
 { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters },
+{ "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
 { 0 }
 };
 
diff --git a/tests/test_connect.py b/tests/test_connect.py
index d8f05e8..2e0cd7f 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -190,6 +190,21 @@ class TestConnect(libvirttest.BaseTestClass):
 info = self.connect.NodeGetCPUMap(0)
 assert isinstance(info, dbus.Array)
 
+@pytest.mark.parametrize("lookup_method_name,lookup_item", [
+("StoragePoolLookupByName", 'Name'),
+])
+def test_connect_network_lookup_by_property(
+self,
+lookup_method_name,
+lookup_item):
+"""Parameterized test for all StoragePoolLookupBy* API calls of 
Connect interface
+"""
+original_path, obj = self.test_storage_pool()
+prop = obj.Get('org.libvirt.StoragePool', lookup_item,
+   dbus_interface=dbus.PROPERTIES_IFACE)
+path = getattr(self.connect, lookup_method_name)(prop)
+assert original_path == path
+
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

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


[libvirt] [PATCH v2 1/8] qemu: introduce capability for virtual-css-bridge

2018-05-07 Thread Boris Fiuczynski
From: Shalini Chellathurai Saroja 

Let us introduce the capability QEMU_CAPS_CCW for virtual-css-bridge
and replace QEMU_CAPS_VIRTIO_CCW with QEMU_CAPS_CCW in code segments
which identify support for ccw devices.

The virtual-css-bridge is part of the ccw support introduced in QEMU 2.7.
The QEMU_CAPS_CCW capability is based on the existence of the QEMU type.

Let us also add the capability QEMU_CAPS_CCW to the tests which
require support for ccw devices.

Signed-off-by: Shalini Chellathurai Saroja 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/qemu/qemu_capabilities.c |  9 +++
 src/qemu/qemu_capabilities.h |  1 +
 src/qemu/qemu_domain.c   |  2 +-
 src/qemu/qemu_domain_address.c   |  4 +-
 src/qemu/qemu_hotplug.c  |  4 +-
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml |  1 +
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml |  1 +
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml  |  1 +
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml  |  1 +
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml  |  1 +
 tests/qemuhotplugtest.c  |  2 +-
 tests/qemuxml2argvtest.c | 86 
 tests/qemuxml2xmltest.c  | 26 +++
 13 files changed, 77 insertions(+), 62 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 920a596..ae3d2a6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -475,6 +475,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "disk-write-cache",
   "nbd-tls",
   "tpm-crb",
+  "virtual-css-bridge",
 );
 
 
@@ -1101,6 +1102,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
 { "virtio-mouse-ccw", QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW },
 { "virtio-tablet-ccw", QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW },
 { "pcie-pci-bridge", QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE },
+{ "virtual-css-bridge", QEMU_CAPS_CCW },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
@@ -3906,6 +3908,13 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
 
+if (ARCH_IS_S390(qemuCaps->arch)) {
+/* Legacy assurance for QEMU_CAPS_CCW */
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW) &&
+virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW))
+virQEMUCapsSet(qemuCaps, QEMU_CAPS_CCW);
+}
+
 ret = 0;
  cleanup:
 return ret;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index abd6eff..e8a916c 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -459,6 +459,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
 QEMU_CAPS_DISK_WRITE_CACHE, /* qemu block frontends support write-cache 
param */
 QEMU_CAPS_NBD_TLS, /* NBD server supports TLS transport */
 QEMU_CAPS_DEVICE_TPM_CRB, /* -device tpm-crb */
+QEMU_CAPS_CCW, /* -device virtual-css-bridge */
 
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 727ea33..fcf95b1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11782,7 +11782,7 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainDef 
*def,
  "'%s' using machine type '%s'"),
devicename, def->os.machine);
 return false;
-} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
+} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("CCW address type is not supported by "
  "this QEMU"));
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index ce2b079..8a5ff74 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -396,7 +396,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
 virDomainCCWAddressSetPtr addrs = NULL;
 
 if (qemuDomainIsS390CCW(def) &&
-virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
+virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
 qemuDomainPrimeVirtioDeviceAddresses(
 def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
 
@@ -2985,7 +2985,7 @@ qemuDomainEnsureVirtioAddress(bool *releaseAddr,
 
 if (!info->type) {
 if (qemuDomainIsS390CCW(vm->def) &&
-virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
+virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW))
 info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
 else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
 info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE

[libvirt] [dbus PATCH 16/19] Implement StoragePoolLookupByUUID method for Connect Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 ++
 src/connect.c| 31 +++
 tests/test_connect.py|  1 +
 3 files changed, 38 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 55c0883..0c009cd 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -223,6 +223,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByUUIDString"/>
+  
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
diff --git a/src/connect.c b/src/connect.c
index fa4078f..43013a2 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1133,6 +1133,36 @@ virtDBusConnectStoragePoolLookupByName(GVariant *inArgs,
 *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusConnectStoragePoolLookupByUUID(GVariant *inArgs,
+   GUnixFDList *inFDs G_GNUC_UNUSED,
+   const gchar *objectPath G_GNUC_UNUSED,
+   gpointer userData,
+   GVariant **outArgs,
+   GUnixFDList **outFDs G_GNUC_UNUSED,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+g_autofree gchar *path = NULL;
+const gchar *uuidstr;
+
+g_variant_get(inArgs, "(s)", &uuidstr);
+
+if (!virtDBusConnectOpen(connect, error))
+return;
+
+storagePool = virStoragePoolLookupByUUIDString(connect->connection,
+   uuidstr);
+if (!storagePool)
+return virtDBusUtilSetLastVirtError(error);
+
+path = virtDBusUtilBusPathForVirStoragePool(storagePool,
+connect->storagePoolPath);
+
+*outArgs = g_variant_new("(o)", path);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
 { "Encrypted", virtDBusConnectGetEncrypted, NULL },
 { "Hostname", virtDBusConnectGetHostname, NULL },
@@ -1173,6 +1203,7 @@ static virtDBusGDBusMethodTable 
virtDBusConnectMethodTable[] = {
 { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel },
 { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters },
 { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
+{ "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
 { 0 }
 };
 
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 2e0cd7f..c0365ae 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -192,6 +192,7 @@ class TestConnect(libvirttest.BaseTestClass):
 
 @pytest.mark.parametrize("lookup_method_name,lookup_item", [
 ("StoragePoolLookupByName", 'Name'),
+("StoragePoolLookupByUUID", 'UUID'),
 ])
 def test_connect_network_lookup_by_property(
 self,
-- 
2.15.0

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


[libvirt] [dbus PATCH 12/19] Implement GetXMLDesc method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  6 ++
 src/storagepool.c| 29 +
 tests/test_storage.py|  7 +++
 3 files changed, 42 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index a60ef84..50550ee 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -41,5 +41,11 @@
 value="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetInfo"/>
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetXMLDesc"/>
+  
+  
+
   
 
diff --git a/src/storagepool.c b/src/storagepool.c
index 43e8040..628ad17 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -208,6 +208,34 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED,
  info->available);
 }
 
+static void
+virtDBusStoragePoolGetXMLDesc(GVariant *inArgs,
+  GUnixFDList *inFDs G_GNUC_UNUSED,
+  const gchar *objectPath,
+  gpointer userData,
+  GVariant **outArgs,
+  GUnixFDList **outFDs G_GNUC_UNUSED,
+  GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+g_autofree gchar *xml = NULL;
+guint flags;
+
+g_variant_get(inArgs, "(u)", &flags);
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+xml = virStoragePoolGetXMLDesc(storagePool, flags);
+if (!xml)
+return virtDBusUtilSetLastVirtError(error);
+
+*outArgs = g_variant_new("(s)", xml);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
 { "Name", virtDBusStoragePoolGetName, NULL },
@@ -221,6 +249,7 @@ static virtDBusGDBusMethodTable 
virtDBusStoragePoolMethodTable[] = {
 { "Delete", virtDBusStoragePoolDelete },
 { "Destroy", virtDBusStoragePoolDestroy },
 { "GetInfo", virtDBusStoragePoolGetInfo },
+{ "GetXMLDesc", virtDBusStoragePoolGetXMLDesc },
 { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 3e67633..1afae2a 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -58,6 +58,13 @@ class TestStoragePool(libvirttest.BaseTestClass):
 info = interface_obj.GetInfo()
 assert isinstance(info, dbus.Struct)
 
+def test_storage_pool_get_xml_description(self):
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+info = interface_obj.GetXMLDesc(0)
+assert isinstance(info, dbus.String)
+
 def test_storage_pool_properties_type(self):
 _, obj = self.test_storage_pool()
 
-- 
2.15.0

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


[libvirt] [dbus PATCH 14/19] Implement Persistent property for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  4 
 src/storagepool.c| 23 +++
 tests/test_storage.py|  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index b739841..31abd34 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -16,6 +16,10 @@
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsPersistent"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetUUIDString"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index 834e1c5..c38e029 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -89,6 +89,28 @@ virtDBusStoragePoolGetName(const gchar *objectPath,
 *value = g_variant_new("s", name);
 }
 
+static void
+virtDBusStoragePoolGetPersistent(const gchar *objectPath,
+ gpointer userData,
+ GVariant **value,
+ GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+gint persistent;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+persistent = virStoragePoolIsPersistent(storagePool);
+if (persistent < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("b", !!persistent);
+}
+
 static void
 virtDBusStoragePoolGetUUID(const gchar *objectPath,
gpointer userData,
@@ -262,6 +284,7 @@ static virtDBusGDBusPropertyTable 
virtDBusStoragePoolPropertyTable[] = {
 { "Active", virtDBusStoragePoolGetActive, NULL },
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
 { "Name", virtDBusStoragePoolGetName, NULL },
+{ "Persistent", virtDBusStoragePoolGetPersistent, NULL },
 { "UUID", virtDBusStoragePoolGetUUID, NULL },
 { 0 }
 };
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 34838fc..b872c3d 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -73,6 +73,7 @@ class TestStoragePool(libvirttest.BaseTestClass):
 assert isinstance(props['Active'], dbus.Boolean)
 assert isinstance(props['Autostart'], dbus.Boolean)
 assert isinstance(props['Name'], dbus.String)
+assert isinstance(props['Persistent'], dbus.Boolean)
 assert isinstance(props['UUID'], dbus.String)
 
 
-- 
2.15.0

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


[libvirt] [dbus PATCH 13/19] Implement Active property for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  4 
 src/storagepool.c| 23 +++
 tests/test_storage.py|  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 50550ee..b739841 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -4,6 +4,10 @@
 
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsActive"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index 628ad17..834e1c5 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -24,6 +24,28 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect 
*connect,
 return storagePool;
 }
 
+static void
+virtDBusStoragePoolGetActive(const gchar *objectPath,
+ gpointer userData,
+ GVariant **value,
+ GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+gint active;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+active = virStoragePoolIsActive(storagePool);
+if (active < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("b", !!active);
+}
+
 static void
 virtDBusStoragePoolGetAutostart(const gchar *objectPath,
 gpointer userData,
@@ -237,6 +259,7 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs,
 }
 
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
+{ "Active", virtDBusStoragePoolGetActive, NULL },
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
 { "Name", virtDBusStoragePoolGetName, NULL },
 { "UUID", virtDBusStoragePoolGetUUID, NULL },
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 1afae2a..34838fc 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -70,6 +70,7 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
 props = obj.GetAll('org.libvirt.StoragePool',
dbus_interface=dbus.PROPERTIES_IFACE)
+assert isinstance(props['Active'], dbus.Boolean)
 assert isinstance(props['Autostart'], dbus.Boolean)
 assert isinstance(props['Name'], dbus.String)
 assert isinstance(props['UUID'], dbus.String)
-- 
2.15.0

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


Re: [libvirt] [PATCHv1 1/7] qemu_monitor_json: Properties optional in QMP JSON for CPUModelInfo

2018-05-07 Thread Collin Walling
I'd recommend including this patch with your other qemu_monitor_json patch 
series.

Let's wait until we see Jiri's patches before moving forward with discussion.

On 05/05/2018 01:48 PM, Chris Venteicher wrote:
> Allow case where props not present in JSON for CPUModelInfo.
> Check for NULL input.
> Update comments to show JSON examples for more typical S390x usecase.
> ---
>  src/qemu/qemu_monitor_json.c | 34 +++---
>  1 file changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index cb17cf53bc..92db267353 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -5358,7 +5358,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key,
>  }
>  
>  
> -/* model_json: {"name": "IvyBridge", "props": {}}
> +/* model_json: {"name": "z13-base", "props": {}}
>   */
>  static virJSONValuePtr
>  qemuMonitorJSONBuildCPUModelInfoToJSON(qemuMonitorCPUModelInfoPtr model)
> @@ -5367,6 +5367,9 @@ 
> qemuMonitorJSONBuildCPUModelInfoToJSON(qemuMonitorCPUModelInfoPtr model)
>  virJSONValuePtr model_json = NULL;
>  size_t i;
>  
> +if (!model)
> +goto cleanup;
> +
>  if (!(cpu_props = virJSONValueNewObject()))
>  goto cleanup;
>  
> @@ -5408,7 +5411,7 @@ 
> qemuMonitorJSONBuildCPUModelInfoToJSON(qemuMonitorCPUModelInfoPtr model)
>  }
>  
>  
> -/* model_json: {"name": "IvyBridge", "props": {}}
> +/* model_json: {"name": "z13-base", "props": {}}
>   */
>  static qemuMonitorCPUModelInfoPtr
>  qemuMonitorJSONBuildCPUModelInfoFromJSON(virJSONValuePtr cpu_model)
> @@ -5424,26 +5427,22 @@ 
> qemuMonitorJSONBuildCPUModelInfoFromJSON(virJSONValuePtr cpu_model)
>  goto cleanup;
>  }
>  
> -if (!(cpu_props = virJSONValueObjectGetObject(cpu_model, "props"))) {
> -virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -   _("Parsed JSON reply missing 'props'"));
> -goto cleanup;
> -}
> -
>  if (VIR_ALLOC(machine_model) < 0)
>  goto cleanup;
>  
>  if (VIR_STRDUP(machine_model->name, cpu_name) < 0)
>  goto cleanup;
>  
> -if (VIR_ALLOC_N(machine_model->props,
> -virJSONValueObjectKeysNumber(cpu_props)) < 0)
> -goto cleanup;
> +if ((cpu_props = virJSONValueObjectGetObject(cpu_model, "props"))) {
> +if (VIR_ALLOC_N(machine_model->props,
> +virJSONValueObjectKeysNumber(cpu_props)) < 0)
> +goto cleanup;
>  
> -if (virJSONValueObjectForeachKeyValue(cpu_props,
> -  
> qemuMonitorJSONParseCPUModelProperty,
> -  machine_model) < 0)
> -goto cleanup;
> +if (virJSONValueObjectForeachKeyValue(cpu_props,
> +  
> qemuMonitorJSONParseCPUModelProperty,
> +  machine_model) < 0)
> +goto cleanup;
> +}
>  
>  VIR_STEAL_PTR(model, machine_model);
>  
> @@ -5586,11 +5585,8 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
>  if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
>  goto cleanup;
>  
> -/* Urgh, some QEMU architectures have query-cpu-model-baseline
> - * command but return 'GenericError' with string "Not supported",
> - * instead of simply omitting the command entirely
> - */
>  if (qemuMonitorJSONHasError(reply, "GenericError")) {
> +/* QEMU does not support query-cpu-model-baseline or cpu model */
>  ret = 0;
>  goto cleanup;
>  }
> 


-- 
Respectfully,
- Collin Walling

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


[libvirt] [dbus PATCH 09/19] Implement GetInfo method for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 28 
 tests/test_storage.py|  7 +++
 3 files changed, 40 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index ed03474..29d501b 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -27,5 +27,10 @@
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetInfo"/>
+  
+
   
 
diff --git a/src/storagepool.c b/src/storagepool.c
index 515b38c..a7bcc94 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -138,6 +138,33 @@ virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED,
+   GUnixFDList *inFDs G_GNUC_UNUSED,
+   const gchar *objectPath,
+   gpointer userData,
+   GVariant **outArgs,
+   GUnixFDList **outFDs G_GNUC_UNUSED,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+g_autofree virStoragePoolInfoPtr info = NULL;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+info = g_new0(virStoragePoolInfo, 1);
+if (virStoragePoolGetInfo(storagePool, info) < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*outArgs = g_variant_new("((uttt))", info->state,
+ info->capacity, info->allocation,
+ info->available);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
 { 0 }
@@ -148,6 +175,7 @@ static virtDBusGDBusMethodTable 
virtDBusStoragePoolMethodTable[] = {
 { "Create", virtDBusStoragePoolCreate },
 { "Delete", virtDBusStoragePoolDelete },
 { "Destroy", virtDBusStoragePoolDestroy },
+{ "GetInfo", virtDBusStoragePoolGetInfo },
 { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 0aa75e3..116385b 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -51,6 +51,13 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
 self.main_loop()
 
+def test_storage_pool_get_info(self):
+_, test_storage_pool = self.test_storage_pool()
+interface_obj = dbus.Interface(test_storage_pool,
+   'org.libvirt.StoragePool')
+info = interface_obj.GetInfo()
+assert isinstance(info, dbus.Struct)
+
 def test_storage_pool_properties_type(self):
 _, obj = self.test_storage_pool()
 
-- 
2.15.0

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


[libvirt] [dbus PATCH 08/19] Implement getter for Autostart property for StoragePool Interface

2018-05-07 Thread Katerina Koukiou
Most of the properties will not emit signals when changed, thus making
the annotation EmitsChangedSignal->false global for this Interface.
Properties with different behavior will overwrite it.

Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.StoragePool.xml |  5 +
 src/storagepool.c| 22 ++
 tests/test_storage.py|  7 +++
 3 files changed, 34 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index fb21e59..ed03474 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -3,6 +3,11 @@
 
 
   
+
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index bf1fd3f..515b38c 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -24,6 +24,27 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect 
*connect,
 return storagePool;
 }
 
+static void
+virtDBusStoragePoolGetAutostart(const gchar *objectPath,
+gpointer userData,
+GVariant **value,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePool) storagePool = NULL;
+gint autostart = 0;
+
+storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+   error);
+if (!storagePool)
+return;
+
+if (virStoragePoolGetAutostart(storagePool, &autostart) < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("b", !!autostart);
+}
+
 static void
 virtDBusStoragePoolBuild(GVariant *inArgs,
  GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -118,6 +139,7 @@ virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
 }
 
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
+{ "Autostart", virtDBusStoragePoolGetAutostart, NULL },
 { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index c4c7cf1..0aa75e3 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -51,6 +51,13 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
 self.main_loop()
 
+def test_storage_pool_properties_type(self):
+_, obj = self.test_storage_pool()
+
+props = obj.GetAll('org.libvirt.StoragePool',
+   dbus_interface=dbus.PROPERTIES_IFACE)
+assert isinstance(props['Autostart'], dbus.Boolean)
+
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

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


[libvirt] [dbus PATCH 02/19] Implement ListStoragePools method for Connect Interface

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 ++
 src/connect.c| 40 
 tests/test_connect.py| 12 
 3 files changed, 58 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index a235872..9207295 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -145,6 +145,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virConnectListAllStoragePools"/>
+  
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkCreateXML"/>
diff --git a/src/connect.c b/src/connect.c
index e838e98..858db43 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -709,6 +709,45 @@ virtDBusConnectListNetworks(GVariant *inArgs,
 *outArgs = g_variant_new_tuple(&gnetworks, 1);
 }
 
+static void
+virtDBusConnectListStoragePools(GVariant *inArgs,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath G_GNUC_UNUSED,
+gpointer userData,
+GVariant **outArgs,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStoragePoolPtr) storagePools = NULL;
+guint flags;
+GVariantBuilder builder;
+GVariant *gstoragePools;
+
+g_variant_get(inArgs, "(u)", &flags);
+
+if (!virtDBusConnectOpen(connect, error))
+return;
+
+if (virConnectListAllStoragePools(connect->connection, &storagePools,
+  flags) < 0) {
+return virtDBusUtilSetLastVirtError(error);
+}
+
+g_variant_builder_init(&builder, G_VARIANT_TYPE("ao"));
+
+for (gint i = 0; storagePools[i]; i++) {
+g_autofree gchar *path = NULL;
+path = virtDBusUtilBusPathForVirStoragePool(storagePools[i],
+connect->storagePoolPath);
+
+g_variant_builder_add(&builder, "o", path);
+}
+
+gstoragePools = g_variant_builder_end(&builder);
+*outArgs = g_variant_new_tuple(&gstoragePools, 1);
+}
+
 static void
 virtDBusConnectNetworkCreateXML(GVariant *inArgs,
 GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1082,6 +1121,7 @@ static virtDBusGDBusMethodTable 
virtDBusConnectMethodTable[] = {
 { "GetSysinfo", virtDBusConnectGetSysinfo },
 { "ListDomains", virtDBusConnectListDomains },
 { "ListNetworks", virtDBusConnectListNetworks },
+{ "ListStoragePools", virtDBusConnectListStoragePools },
 { "NetworkCreateXML", virtDBusConnectNetworkCreateXML },
 { "NetworkDefineXML", virtDBusConnectNetworkDefineXML },
 { "NetworkLookupByName", virtDBusConnectNetworkLookupByName },
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 3eeecb9..d8f05e8 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -126,6 +126,18 @@ class TestConnect(libvirttest.BaseTestClass):
 arch = "x86_64"
 assert isinstance(self.connect.GetCPUModelNames(arch, 0), dbus.Array)
 
+def test_connect_list_storage_pools(self):
+storage_pools = self.connect.ListStoragePools(0)
+assert isinstance(storage_pools, dbus.Array)
+assert len(storage_pools) == 1
+
+for path in storage_pools:
+assert isinstance(path, dbus.ObjectPath)
+storage_pool = self.bus.get_object('org.libvirt', path)
+
+# ensure the path exists by calling Introspect on it
+storage_pool.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)
+
 def test_connect_network_create_xml(self):
 def network_started(path, event):
 if event != libvirttest.NetworkEvent.STARTED:
-- 
2.15.0

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


Re: [libvirt] [tck PATCH] maint: Drop autobuild.sh

2018-05-07 Thread Laine Stump
On 05/03/2018 11:47 AM, Daniel P. Berrangé wrote:
> On Thu, May 03, 2018 at 05:42:27PM +0200, Andrea Bolognani wrote:
>> The Test-AutoBuild project, that this script is supposed
>> to be used with, hasn't seen any activity in ~7 years;
>> these days, libvirt-tck CI builds are happening on the
>> Jenkins-based CentOS CI environment under the libvirt
>> umbrella[1], and in that context the script is not used
>> at all.
>>
>> [1] https://ci.centos.org/view/libvirt/
>>
>> Signed-off-by: Andrea Bolognani 
>> ---
>>  autobuild.sh | 59 
>> ---
>>  1 file changed, 59 deletions(-)
>>  delete mode 100755 autobuild.sh
> I used this one for cutting releases too.

And it's the only way I know how to build it for testing. Please don't
move my cheese! :-)

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

[libvirt] [sandbox PATCH v2 2/4] prepare-release: Drop references to MinGW builds

2018-05-07 Thread Andrea Bolognani
The MinGW spec file was never included in the git repository
to begin with.

Signed-off-by: Andrea Bolognani 
---
 prepare-release.sh | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/prepare-release.sh b/prepare-release.sh
index c176fea..1fee11f 100755
--- a/prepare-release.sh
+++ b/prepare-release.sh
@@ -46,26 +46,3 @@ if [ -f /usr/bin/rpmbuild ]; then
 fi
 
 exit 0
-if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
-  make distclean
-
-  
PKG_CONFIG_PATH="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig"
 \
-  CC="i686-pc-mingw32-gcc" \
-  ../configure \
---build=$(uname -m)-pc-linux \
---host=i686-pc-mingw32 \
---prefix="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw"
-
-  make
-  make install
-
-  #set -o pipefail
-  #make check 2>&1 | tee "$RESULTS"
-
-  if [ -f /usr/bin/rpmbuild ]; then
-rpmbuild --nodeps \
-   --define "extra_release $EXTRA_RELEASE" \
-   --define "_sourcedir `pwd`" \
-   -ba --clean mingw32-libvirt-sandbox.spec
-  fi
-fi
-- 
2.17.0

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


[libvirt] [sandbox PATCH v2 1/4] maint: Rename autobuild.sh to prepare-release.sh

2018-05-07 Thread Andrea Bolognani
The script was originally used by the Test::AutoBuild
project to perform periodic automatic builds; however, that
effort has been abandoned a long time ago, and these days
libvirt-sandbox CI builds are happening on the Jenkins-based
CentOS CI environment under the libvirt umbrella[1], where
build recipes are maintained separately from the projects
themselves.

The script is still used to prepare releases, so it can't
be dropped from the repository: rename it so that its
purpose is more clearly communicated instead.

[1] https://ci.centos.org/view/libvirt/

Signed-off-by: Andrea Bolognani 
---
 autobuild.sh => prepare-release.sh | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename autobuild.sh => prepare-release.sh (100%)

diff --git a/autobuild.sh b/prepare-release.sh
similarity index 100%
rename from autobuild.sh
rename to prepare-release.sh
-- 
2.17.0

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


[libvirt] [sandbox PATCH v2 0/4] Remove Test::AutoBuild leftovers

2018-05-07 Thread Andrea Bolognani
Changes from [v1]:

* rename the script instead of dropping it;

* perform some further clean ups.


[v1] https://www.redhat.com/archives/libvir-list/2018-May/msg00220.html

Andrea Bolognani (4):
  maint: Rename autobuild.sh to prepare-release.sh
  prepare-release: Drop references to MinGW builds
  prepare-release: Drop references to Test::AutoBuild
  spec: Drop %{extra_release}

 autobuild.sh| 71 -
 libvirt-sandbox.spec.in |  2 +-
 prepare-release.sh  | 39 ++
 3 files changed, 40 insertions(+), 72 deletions(-)
 delete mode 100755 autobuild.sh
 create mode 100755 prepare-release.sh

-- 
2.17.0

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


[libvirt] [sandbox PATCH v2 3/4] prepare-release: Drop references to Test::AutoBuild

2018-05-07 Thread Andrea Bolognani
They are misleading, and no longer relevant anyway.

Signed-off-by: Andrea Bolognani 
---
 prepare-release.sh | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/prepare-release.sh b/prepare-release.sh
index 1fee11f..c8fd2b5 100755
--- a/prepare-release.sh
+++ b/prepare-release.sh
@@ -5,7 +5,6 @@ set -v
 
 # Make things clean.
 test -n "$1" && RESULTS=$1 || RESULTS=results.log
-: ${AUTOBUILD_INSTALL_ROOT=$HOME/builder}
 
 test -f Makefile && make -k distclean || :
 
@@ -13,7 +12,7 @@ rm -rf build
 mkdir build
 cd build
 
-../autogen.sh --prefix=$AUTOBUILD_INSTALL_ROOT \
+../autogen.sh --prefix=$HOME/builder \
 --enable-gtk-doc
 
 make
@@ -31,12 +30,8 @@ test "$st" = 0
 rm -f *.tar.gz
 make dist
 
-if [ -n "$AUTOBUILD_COUNTER" ]; then
-  EXTRA_RELEASE=".auto$AUTOBUILD_COUNTER"
-else
-  NOW=`date +"%s"`
-  EXTRA_RELEASE=".$USER$NOW"
-fi
+NOW=`date +"%s"`
+EXTRA_RELEASE=".$USER$NOW"
 
 if [ -f /usr/bin/rpmbuild ]; then
   rpmbuild --nodeps \
-- 
2.17.0

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


[libvirt] [sandbox PATCH v2 4/4] spec: Drop %{extra_release}

2018-05-07 Thread Andrea Bolognani
It was mainly meant to be used for automatic builds through
Test::AutoBuild, so it can be removed now.

Signed-off-by: Andrea Bolognani 
---
 libvirt-sandbox.spec.in | 2 +-
 prepare-release.sh  | 4 
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/libvirt-sandbox.spec.in b/libvirt-sandbox.spec.in
index 0374d9e..4e020de 100644
--- a/libvirt-sandbox.spec.in
+++ b/libvirt-sandbox.spec.in
@@ -16,7 +16,7 @@
 
 Name: @PACKAGE@
 Version: @VERSION@
-Release: 1%{?dist}%{?extra_release}
+Release: 1%{?dist}
 Summary: libvirt application sandbox framework
 Group: Development/Tools
 License: LGPLv2+
diff --git a/prepare-release.sh b/prepare-release.sh
index c8fd2b5..2be25c2 100755
--- a/prepare-release.sh
+++ b/prepare-release.sh
@@ -30,12 +30,8 @@ test "$st" = 0
 rm -f *.tar.gz
 make dist
 
-NOW=`date +"%s"`
-EXTRA_RELEASE=".$USER$NOW"
-
 if [ -f /usr/bin/rpmbuild ]; then
   rpmbuild --nodeps \
- --define "extra_release $EXTRA_RELEASE" \
  --define "_sourcedir `pwd`" \
  -ba --clean libvirt-sandbox.spec
 fi
-- 
2.17.0

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


Re: [libvirt] [dbus PATCH] "foo* [bar]" should be "foo *[bar]"

2018-05-07 Thread Pavel Hrdina
On Mon, May 07, 2018 at 04:00:12PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
> We forgot to include this in the last code style fixes.
> 
>  src/connect.c | 6 +++---
>  src/domain.c  | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Pavel Hrdina 


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

Re: [libvirt] [PATCH REBASE 3/5] utils: export virCopyError

2018-05-07 Thread John Ferlan


On 05/07/2018 04:33 AM, Nikolay Shirokovskiy wrote:
> 
> 
> On 04.05.2018 16:58, John Ferlan wrote:
>>
>>
>> On 05/03/2018 03:39 AM, Nikolay Shirokovskiy wrote:
>>>
>>>
>>> On 01.05.2018 01:03, John Ferlan wrote:


 On 04/18/2018 10:44 AM, Nikolay Shirokovskiy wrote:
> Signed-off-by: Nikolay Shirokovskiy 
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virerror.c  | 12 +---
>  src/util/virerror.h  |  1 +
>  3 files changed, 11 insertions(+), 3 deletions(-)
>

 NACK, you should be using virErrorCopyNew

 John
>>>
>>> I introduced monError in qemuDomainObjPrivatePtr in next patch and it is 
>>> not a pointer so
>>> I need this function. I did not make monError pointer for the same reason 
>>> it is not pointer
>>> in monitor object - I use monError both as flag and as error message.
>>>
>>
>> I saw what you did - the fact is virCopyError is coded as private to the
>> module. Just making it global because you have a use for it is I believe
>> incorrect.
> 
> But why?
> 

Because virErrorCopyNew is designated to "externally" use virCopyError.

>>
>> Ironically in the next patch you have:
>>
>> +virErrorPtr err = qemuMonitorLastError(mon);
>> +
>> +virCopyError(err, &priv->monError);
>>
>>
>> The first call isn't guaranteed to set @err and all you're essentially
>> doing is wanting to copy from mon->lastError to priv->monError or
>> perhaps similar to virCopyLastError.
> 
> It is ok that error can turn from non-NULL to NULL on copy due to OOM
> conditions or whaever. It is just as in previous patch. We use priv->monError
> for 2 purpuses. And thus qemuProcessNotifyMonitorError sets 
> priv->monError.code
> explicitly if it still set to VIR_ERR_OK after copy.
> 

It's "possible" from the above code that @priv->monError would have
nothing filled in based on virCopyError logic, so how is that better
than what's being done now?

That's why I figured that changing the innards of virCopyLastError would
be more beneficial in the long run.

>>
>> Maybe some new API in virerror.c should handle that.
>>
> 
> Not sure we need it at this point. But may be I miss something, please
> share your vision in more detail then.
> 

It's not my patch - I'll review whatever comes next. I've provided
suggestions and comments.

John

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


[libvirt] [dbus PATCH] "foo* [bar]" should be "foo *[bar]"

2018-05-07 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
We forgot to include this in the last code style fixes.

 src/connect.c | 6 +++---
 src/domain.c  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index fd335e3..1c87bf2 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -227,7 +227,7 @@ virtDBusConnectBaselineCPU(GVariant *inArgs,
 
 ncpus = g_variant_iter_n_children(iter);
 if (ncpus > 0) {
-xmlCPUs = g_new0(const gchar*, ncpus);
+xmlCPUs = g_new0(const gchar *, ncpus);
 tmp = xmlCPUs;
 while (g_variant_iter_next(iter, "&s", tmp))
 tmp++;
@@ -517,7 +517,7 @@ virtDBusConnectGetAllDomainStats(GVariant *inArgs,
 g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sa{sv})"));
 
 for (gint i = 0; i < nstats; i++) {
-const gchar* name;
+const gchar *name;
 GVariant *grecords;
 
 g_variant_builder_open(&builder, G_VARIANT_TYPE("(sa{sv})"));
@@ -582,7 +582,7 @@ virtDBusConnectGetDomainCapabilities(GVariant *inArgs,
 const gchar *machine;
 const gchar *virttype;
 guint flags;
-g_autofree gchar* domCapabilities = NULL;
+g_autofree gchar *domCapabilities = NULL;
 
 g_variant_get(inArgs, "(&s&s&s&su)", &emulatorbin, &arch, &machine,
   &virttype, &flags);
diff --git a/src/domain.c b/src/domain.c
index 2ba58e0..3127f6c 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -118,7 +118,7 @@ virtDBusDomainGVariantToMountpoints(GVariantIter *iter,
 
 *nmountpoints = g_variant_iter_n_children(iter);
 if (*nmountpoints > 0) {
-*mountpoints = g_new0(const gchar*, *nmountpoints);
+*mountpoints = g_new0(const gchar *, *nmountpoints);
 tmp = *mountpoints;
 while (g_variant_iter_next(iter, "&s", tmp))
 tmp++;
-- 
2.15.0

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


Re: [libvirt] [PATCH 09/12] virsh: Enable multiple --event flags to 'event' command

2018-05-07 Thread Lin Ma



On 05/04/2018 06:44 PM, Peter Krempa wrote:

On Fri, May 04, 2018 at 17:25:30 +0800, Lin Ma wrote:

Signed-off-by: Lin Ma
---
  tools/virsh-domain.c | 76 +++-
  1 file changed, 39 insertions(+), 37 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 89aefbf86a..b35c9adaaa 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13347,10 +13347,6 @@ static const vshCmdInfo info_event[] = {
  static const vshCmdOptDef opts_event[] = {
  VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
0),
-{.name = "event",
- .type = VSH_OT_STRING,
- .help = N_("which event type to wait for")
-},
  {.name = "all",
   .type = VSH_OT_BOOL,
   .help = N_("wait for all events instead of just one type") @@ -13371,6 +13367,10 @@ static const vshCmdOptDef opts_event[] = 
{ .type = VSH_OT_BOOL, .help = N_("show timestamp for each printed event")

  },
+{.name = "event",
+ .type = VSH_OT_ARGV,
+ .help = N_("which event type to wait for")
+},
  {.name = NULL}
  };
  
@@ -13382,12 +13382,14 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)

  int timeout = 0;
  virshDomEventData *data = NULL;
  size_t i;
-const char *eventName = NULL;
+int *eventIdxList = NULL;
+size_t nevents = 0;
  int event = -1;
  bool all = vshCommandOptBool(cmd, "all");
  bool loop = vshCommandOptBool(cmd, "loop");
  bool timestamp = vshCommandOptBool(cmd, "timestamp");
  int count = 0;
+const vshCmdOpt *opt = NULL;
  virshControlPtr priv = ctl->privData;
  
  if (vshCommandOptBool(cmd, "list")) {

@@ -13396,15 +13398,25 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
  return true;
  }
  
-if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)

-return false;
-if (eventName) {
-for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
-if (STREQ(eventName, vshEventCallbacks[event].name))
-break;
-if (event == VIR_DOMAIN_EVENT_ID_LAST) {
-vshError(ctl, _("unknown event type %s"), eventName);
-return false;
+if (vshCommandOptBool(cmd, "event")) {
+if (VIR_ALLOC_N(eventIdxList, 1) < 0)
+goto cleanup;

This is not necessary, VIR_APPEND_ELEMENT does that

will remove it.



+nevents = 1;
+while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
+if (opt->data) {
+for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
+if (STREQ(opt->data, vshEventCallbacks[event].name))
+break;
+if (event == VIR_DOMAIN_EVENT_ID_LAST) {
+vshError(ctl, _("unknown event type %s"), opt->data);
+return false;

This leaks the eventIdxList array.

ok, will fix it through using 'goto cleanup' instead of 'return false'



Also it would be preferrable just to
use one array for the case when events are enumerated and when all are
used ...
Do you mean that the code logical should not go '--all' but '--event A' 
in the case 'virsh event --event A --all'?




+}
+if (VIR_INSERT_ELEMENT(eventIdxList,

Use VIR_APPEND_ELEMENT instead.

will do.



+   nevents - 1,
+   nevents,
+   event) < 0)
+goto cleanup;
+}
  }
  } else if (!all) {
  vshError(ctl, "%s",
@@ -13412,26 +13424,15 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
  return false;
  }
  
-if (all) {

-if (VIR_ALLOC_N(data, VIR_DOMAIN_EVENT_ID_LAST) < 0)
-goto cleanup;
-for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
-data[i].ctl = ctl;
-data[i].loop = loop;
-data[i].count = &count;
-data[i].timestamp = timestamp;
-data[i].cb = &vshEventCallbacks[i];
-data[i].id = -1;
-}
-} else {
-if (VIR_ALLOC_N(data, 1) < 0)
-goto cleanup;
-data[0].ctl = ctl;
-data[0].loop = vshCommandOptBool(cmd, "loop");
-data[0].count = &count;
-data[0].timestamp = timestamp;
-data[0].cb = &vshEventCallbacks[event];
-data[0].id = -1;
+if (VIR_ALLOC_N(data, all ? VIR_DOMAIN_EVENT_ID_LAST : nevents - 1) < 0)
+goto cleanup;
+for (i = 0; i < (all ? VIR_DOMAIN_EVENT_ID_LAST : nevents - 1); i++) {
+data[i].ctl = ctl;
+data[i].loop = loop;
+data[i].count = &count;
+data[i].timestamp = timestamp;
+data[i].cb = &vshEventCallbacks[all ? i : eventIdxList[i]];

No ternaries,

ok



please use the same array, just fill it differently.

do you mean that
whatever in 'all' or 'not all', I should fill 'eventIdxList' differently

Re: [libvirt] [PATCH 0/1] Bug: Sandbox: libvirt breakdowns qemu guest

2018-05-07 Thread Christian Borntraeger


On 05/07/2018 02:02 PM, Ján Tomko wrote:
> On Mon, May 07, 2018 at 12:33:20PM +0200, Eduardo Otubo wrote:
>> On 07/05/2018 - 11:29:57, Christian Borntraeger wrote:
>>> On 05/07/2018 05:32 AM, Yi Min Zhao wrote:
>>> > 1. Problem Description
>>> > ==
>>> > If QEMU is built without seccomp support, 'elevatorprivileges' remains 
>>> > compiled.
>>> > This option of sandbox is treated as an indication for seccomp blacklist 
>>> > support
>>> > in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and
>>> > 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the 
>>> > guest
>>> > startup would fail.
>>>
>>> Adding libvirt list.
>>>
>>> This would still fail with older QEMUs, so the question is if we should 
>>> also OR instead
>>> change something in libvirt.
>>
>> Perhaps I'm missing something here, but libvirt can differentiate between
>> different versions of QEMU, therefore not calling it with wrong or outdated
>> arguments.
>>
> 
> The code introduced in libvirt commit 31ca6a5 specifically looks for
> 'elevateprivileges' in 'parameters' of the 'sandbox' option through
> query-command-line-options.
> 
> Outdated QEMUs should not have this option there.
> 
> However, libvirtd does add the option by default not knowing whether it
> can fail for other reasons, e.g. SECCOMP not being enabled in the
> running kernel. I wonder if that is worth addressing.

So you prefer the qemu patch (with cc stable) as the best solution?

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


Re: [libvirt] [PATCH 0/1] Bug: Sandbox: libvirt breakdowns qemu guest

2018-05-07 Thread Ján Tomko

On Mon, May 07, 2018 at 12:33:20PM +0200, Eduardo Otubo wrote:

On 07/05/2018 - 11:29:57, Christian Borntraeger wrote:

On 05/07/2018 05:32 AM, Yi Min Zhao wrote:
> 1. Problem Description
> ==
> If QEMU is built without seccomp support, 'elevatorprivileges' remains 
compiled.
> This option of sandbox is treated as an indication for seccomp blacklist 
support
> in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and
> 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the guest
> startup would fail.

Adding libvirt list.

This would still fail with older QEMUs, so the question is if we should also OR 
instead
change something in libvirt.


Perhaps I'm missing something here, but libvirt can differentiate between
different versions of QEMU, therefore not calling it with wrong or outdated
arguments.



The code introduced in libvirt commit 31ca6a5 specifically looks for
'elevateprivileges' in 'parameters' of the 'sandbox' option through
query-command-line-options.

Outdated QEMUs should not have this option there.

However, libvirtd does add the option by default not knowing whether it
can fail for other reasons, e.g. SECCOMP not being enabled in the
running kernel. I wonder if that is worth addressing.

Jano



>
> 2. Libvirt Log
> ==
> qemu-system-s390x: -sandbox 
on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
> resourcecontrol=deny: seccomp support is disabled
>
> 3. Fixup
> 
> Wrap the options except 'enable' for qemu_sandbox_opts by CONFIG_SECCOMP.
>
> Yi Min Zhao (1):
>   sandbox: avoid to compile options if CONFIG_SECCOMP undefined
>
>  vl.c | 2 ++
>  1 file changed, 2 insertions(+)
>



--
Eduardo Otubo

--
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] [dbus PATCH 2/9] Use ++ operator instead of += in for loop

2018-05-07 Thread Ján Tomko

On Mon, May 07, 2018 at 12:06:29PM +0200, Pavel Hrdina wrote:

Signed-off-by: Pavel Hrdina 
---
src/connect.c | 10 +-
src/main.c|  2 +-
src/network.c |  2 +-
src/util.c|  4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index 3d2be96..e96294d 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -39,7 +39,7 @@ virtDBusConnectClose(virtDBusConnect *connect,
 gboolean deregisterEvents)
{

-for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1) {
+for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
if (connect->domainCallbackIds[i] >= 0) {
if (deregisterEvents) {
virConnectDomainEventDeregisterAny(connect->connection,


Thank you!

Jano


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

Re: [libvirt] [PATCH 0/8] vfio-ccw passthrough support

2018-05-07 Thread John Ferlan
[...]

>> Someone may also want to consider creating a s390 specific version of
>> what Peter did for x86_64 for VIR_TEST_CAPS_LATEST in order to then
>> have/use the "latest" capabilities instead of adding bits to xml2argv
>> tests. I'm curious why the xml2xml test needed the bit adjustment - did
>> something fail?  Since there were no xml output data changes, that would
>> seem to indicate there isn't a need to modify the xml2xml test source.
> I am not sure if I understood you correctly. Are you referring to patch
> 1? If so the changes are caused by a new QEMU_CAPS_CCW capability
> replacing the QEMU_CAPS_VIRTIO_CCW capability. More is explained in the
> commit message of the patch. In short: With support of vfio-ccw it
> became apparent that the existence of the ccw bus is not well sourced by
> observing virtio-ccw and therefore we replaced it with the detection of
> the virtual-css-bridge. Let me know if I understood you wrong.
> 

Sorry it wasn't clear enough - changes were recently made to
tests/qemuxml2argvtest.c in order to run the tests using the latest
capabilities rather than needing to pass each capability through the
test. The macros also have a version specific macro which allows for
checking/output from "previous" QEMU releases.

However, the changes only modified macros for x86_64 - so my comment was
if someone felt so inclined to avoid needing/checking specific/certain
caps and only cared that the latest caps did something a certain way,
then adjusting those macros/tests to handle s390* specific things would
perhaps helps achieve that. Furthermore, if previous QEMU versions would
produce different results, then using the version specific checks/output
would provide that support.

John

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

Re: [libvirt] [dbus PATCH 0/9] random fixes

2018-05-07 Thread Katerina Koukiou
On Mon, 2018-05-07 at 12:06 +0200, Pavel Hrdina wrote:
> *** BLURB HERE ***
> 
> Pavel Hrdina (9):
>   Process input arguments before getting libvirt object
>   Use ++ operator instead of += in for loop
>   connect: Fix List* methods to return empty array for empty list
>   connect: Pass error into virtDBusConnectOpen function
>   domain: There is no need to check ret again
>   domain: Return error if libvirt API fails
>   domain: Introduce virtDBusDomainGVariantToMountpoints helper
>   domain: Introduce virtDBusDomainGVariantToCpumap helper
>   util: Use spaces around operators
> 
>  src/connect.c |  28 ++-
>  src/domain.c  | 110 --
> 
>  src/main.c|   2 +-
>  src/network.c |   2 +-
>  src/util.c|   6 ++--
>  5 files changed, 70 insertions(+), 78 deletions(-)
> 
Thanks for the fixes. ACK whole patchset.

Katerina

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


Re: [libvirt] [PATCH 0/1] Bug: Sandbox: libvirt breakdowns qemu guest

2018-05-07 Thread Eduardo Otubo
On 07/05/2018 - 11:29:57, Christian Borntraeger wrote:
> On 05/07/2018 05:32 AM, Yi Min Zhao wrote:
> > 1. Problem Description
> > ==
> > If QEMU is built without seccomp support, 'elevatorprivileges' remains 
> > compiled.
> > This option of sandbox is treated as an indication for seccomp blacklist 
> > support
> > in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and
> > 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the guest
> > startup would fail.
> 
> Adding libvirt list.
> 
> This would still fail with older QEMUs, so the question is if we should also 
> OR instead
> change something in libvirt.

Perhaps I'm missing something here, but libvirt can differentiate between
different versions of QEMU, therefore not calling it with wrong or outdated
arguments.

> 
> > 
> > 2. Libvirt Log
> > ==
> > qemu-system-s390x: -sandbox 
> > on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
> > resourcecontrol=deny: seccomp support is disabled
> > 
> > 3. Fixup
> > 
> > Wrap the options except 'enable' for qemu_sandbox_opts by CONFIG_SECCOMP.
> > 
> > Yi Min Zhao (1):
> >   sandbox: avoid to compile options if CONFIG_SECCOMP undefined
> > 
> >  vl.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> 

-- 
Eduardo Otubo

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


[libvirt] [dbus PATCH 4/9] connect: Pass error into virtDBusConnectOpen function

2018-05-07 Thread Pavel Hrdina
We need to pass the error pointer in order to report proper error.

Signed-off-by: Pavel Hrdina 
---
 src/connect.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index cd90939..fd335e3 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -342,7 +342,7 @@ virtDBusConnectDomainLookupByID(GVariant *inArgs,
 
 g_variant_get(inArgs, "(u)", &id);
 
-if (!virtDBusConnectOpen(connect, NULL))
+if (!virtDBusConnectOpen(connect, error))
 return;
 
 domain = virDomainLookupByID(connect->connection, id);
@@ -370,7 +370,7 @@ virtDBusConnectDomainLookupByName(GVariant *inArgs,
 
 g_variant_get(inArgs, "(s)", &name);
 
-if (!virtDBusConnectOpen(connect, NULL))
+if (!virtDBusConnectOpen(connect, error))
 return;
 
 domain = virDomainLookupByName(connect->connection, name);
@@ -398,7 +398,7 @@ virtDBusConnectDomainLookupByUUID(GVariant *inArgs,
 
 g_variant_get(inArgs, "(s)", &uuidstr);
 
-if (!virtDBusConnectOpen(connect, NULL))
+if (!virtDBusConnectOpen(connect, error))
 return;
 
 domain = virDomainLookupByUUIDString(connect->connection, uuidstr);
-- 
2.14.3

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


[libvirt] [dbus PATCH 5/9] domain: There is no need to check ret again

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/domain.c b/src/domain.c
index 17231bd..20d41fe 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -938,7 +938,8 @@ virtDBusDomainGetBlockIOTune(GVariant *inArgs,
 ret = virDomainGetBlockIoTune(domain, disk, NULL, ¶ms.nparams, flags);
 if (ret < 0)
 return virtDBusUtilSetLastVirtError(error);
-if (ret == 0 && params.nparams != 0) {
+
+if (params.nparams != 0) {
 params.params = g_new0(virTypedParameter, params.nparams);
 if (virDomainGetBlockIoTune(domain, disk, params.params,
 ¶ms.nparams, flags) < 0) {
-- 
2.14.3

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


[libvirt] [dbus PATCH 7/9] domain: Introduce virtDBusDomainGVariantToMountpoints helper

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/domain.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/domain.c b/src/domain.c
index b361aa6..c6dc744 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -109,6 +109,22 @@ virtDBusDomainMemoryStatsToGVariant(virDomainMemoryStatPtr 
stats,
 return g_variant_builder_end(&builder);
 }
 
+static void
+virtDBusDomainGVariantToMountpoints(GVariantIter *iter,
+const gchar ***mountpoints,
+guint *nmountpoints)
+{
+const gchar **tmp;
+
+*nmountpoints = g_variant_iter_n_children(iter);
+if (*nmountpoints > 0) {
+*mountpoints = g_new0(const gchar*, *nmountpoints);
+tmp = *mountpoints;
+while (g_variant_iter_next(iter, "&s", tmp))
+tmp++;
+}
+}
+
 static virDomainPtr
 virtDBusDomainGetVirDomain(virtDBusConnect *connect,
const gchar *objectPath,
@@ -783,21 +799,14 @@ virtDBusDomainFSFreeze(GVariant *inArgs,
 virtDBusConnect *connect = userData;
 g_autoptr(virDomain) domain = NULL;
 g_autofree const gchar **mountpoints = NULL;
-const gchar **tmp;
 g_autoptr(GVariantIter) iter;
-gsize nmountpoints = 0;
+guint nmountpoints;
 guint flags;
 gint ret;
 
 g_variant_get(inArgs, "(asu)", &iter, &flags);
 
-nmountpoints = g_variant_iter_n_children(iter);
-if (nmountpoints > 0) {
-mountpoints = g_new0(const gchar*, nmountpoints);
-tmp = mountpoints;
-while (g_variant_iter_next(iter, "&s", tmp))
-tmp++;
-}
+virtDBusDomainGVariantToMountpoints(iter, &mountpoints, &nmountpoints);
 
 domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
 if (!domain)
@@ -822,7 +831,6 @@ virtDBusDomainFSThaw(GVariant *inArgs,
 virtDBusConnect *connect = userData;
 g_autoptr(virDomain) domain = NULL;
 g_autofree const gchar **mountpoints = NULL;
-const gchar **tmp;
 g_autoptr(GVariantIter) iter;
 guint nmountpoints;
 guint flags;
@@ -830,13 +838,7 @@ virtDBusDomainFSThaw(GVariant *inArgs,
 
 g_variant_get(inArgs, "(asu)", &iter, &flags);
 
-nmountpoints = g_variant_iter_n_children(iter);
-if (nmountpoints > 0) {
-mountpoints = g_new0(const gchar*, nmountpoints);
-tmp = mountpoints;
-while (g_variant_iter_next(iter, "&s", tmp))
-tmp++;
-}
+virtDBusDomainGVariantToMountpoints(iter, &mountpoints, &nmountpoints);
 
 domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
 if (!domain)
-- 
2.14.3

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


[libvirt] [dbus PATCH 1/9] Process input arguments before getting libvirt object

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/connect.c |  6 +++---
 src/domain.c  | 24 
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index 0025023..3d2be96 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1046,14 +1046,14 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inArgs,
 
 g_variant_get(inArgs, "(a{sv}u)", &iter, &flags);
 
-if (!virtDBusConnectOpen(connect, error))
-return;
-
 if (!virtDBusUtilGVariantToTypedParams(iter, ¶ms.params,
¶ms.nparams, error)) {
 return;
 }
 
+if (!virtDBusConnectOpen(connect, error))
+return;
+
 if (virNodeSetMemoryParameters(connect->connection, params.params,
params.nparams, flags) < 0) {
 virtDBusUtilSetLastVirtError(error);
diff --git a/src/domain.c b/src/domain.c
index 262ebe2..17231bd 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -1995,10 +1995,6 @@ virtDBusDomainPinEmulator(GVariant *inArgs,
 
 g_variant_get(inArgs, "(abu)", &iter, &flags);
 
-domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
-if (!domain)
-return;
-
 cpus = g_variant_iter_n_children(iter);
 cpumaplen = VIR_CPU_MAPLEN(cpus);
 cpumap = g_new0(guchar, cpumaplen);
@@ -2008,6 +2004,10 @@ virtDBusDomainPinEmulator(GVariant *inArgs,
 cnt++;
 }
 
+domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+if (!domain)
+return;
+
 if (virDomainPinEmulator(domain, cpumap, cpumaplen, flags) < 0)
 virtDBusUtilSetLastVirtError(error);
 }
@@ -2035,10 +2035,6 @@ virtDBusDomainPinIOThread(GVariant *inArgs,
 
 g_variant_get(inArgs, "(uabu)", &iothreadId, &iter, &flags);
 
-domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
-if (!domain)
-return;
-
 cpus = g_variant_iter_n_children(iter);
 cpumaplen = VIR_CPU_MAPLEN(cpus);
 cpumap = g_new0(guchar, cpumaplen);
@@ -2048,6 +2044,10 @@ virtDBusDomainPinIOThread(GVariant *inArgs,
 cnt++;
 }
 
+domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+if (!domain)
+return;
+
 if (virDomainPinIOThread(domain, iothreadId, cpumap, cpumaplen, flags) < 0)
 virtDBusUtilSetLastVirtError(error);
 }
@@ -2075,10 +2075,6 @@ virtDBusDomainPinVcpu(GVariant *inArgs,
 
 g_variant_get(inArgs, "(uabu)", &vcpu, &iter, &flags);
 
-domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
-if (!domain)
-return;
-
 cpus = g_variant_iter_n_children(iter);
 cpumaplen = VIR_CPU_MAPLEN(cpus);
 cpumap = g_new0(guchar, cpumaplen);
@@ -2088,6 +2084,10 @@ virtDBusDomainPinVcpu(GVariant *inArgs,
 cnt++;
 }
 
+domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+if (!domain)
+return;
+
 if (virDomainPinVcpuFlags(domain, vcpu, cpumap, cpumaplen, flags) < 0)
 virtDBusUtilSetLastVirtError(error);
 }
-- 
2.14.3

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


[libvirt] [dbus PATCH 6/9] domain: Return error if libvirt API fails

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/domain.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/domain.c b/src/domain.c
index 20d41fe..b361aa6 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -1339,7 +1339,10 @@ virtDBusDomainGetMemoryParameters(GVariant *inArgs,
 return;
 
 ret = virDomainGetMemoryParameters(domain, NULL, ¶ms.nparams, flags);
-if (ret == 0 && params.nparams != 0) {
+if (ret < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+if (params.nparams != 0) {
 params.params = g_new0(virTypedParameter, params.nparams);
 if (virDomainGetMemoryParameters(domain, params.params,
  ¶ms.nparams, flags) < 0) {
@@ -1475,7 +1478,10 @@ virtDBusDomainGetSchedulerParameters(GVariant *inArgs,
 return;
 
 ret = virDomainGetSchedulerType(domain, ¶ms.nparams);
-if (ret && params.nparams != 0) {
+if (!ret)
+return virtDBusUtilSetLastVirtError(error);
+
+if (params.nparams != 0) {
 params.params = g_new0(virTypedParameter, params.nparams);
 if (virDomainGetSchedulerParametersFlags(domain, params.params,
  ¶ms.nparams, 0))
-- 
2.14.3

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


[libvirt] [dbus PATCH 9/9] util: Use spaces around operators

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util.c b/src/util.c
index 8b28496..548fac8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -177,7 +177,7 @@ virtDBusUtilEncodeUUID(const gchar *uuid)
 static gchar *
 virtDBusUtilDecodeUUID(const gchar *uuid)
 {
-gchar *ret = g_strdup(uuid+1);
+gchar *ret = g_strdup(uuid + 1);
 return g_strdelimit(ret, "_", '-');
 }
 
-- 
2.14.3

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


[libvirt] [dbus PATCH 0/9] random fixes

2018-05-07 Thread Pavel Hrdina
*** BLURB HERE ***

Pavel Hrdina (9):
  Process input arguments before getting libvirt object
  Use ++ operator instead of += in for loop
  connect: Fix List* methods to return empty array for empty list
  connect: Pass error into virtDBusConnectOpen function
  domain: There is no need to check ret again
  domain: Return error if libvirt API fails
  domain: Introduce virtDBusDomainGVariantToMountpoints helper
  domain: Introduce virtDBusDomainGVariantToCpumap helper
  util: Use spaces around operators

 src/connect.c |  28 ++-
 src/domain.c  | 110 --
 src/main.c|   2 +-
 src/network.c |   2 +-
 src/util.c|   6 ++--
 5 files changed, 70 insertions(+), 78 deletions(-)

-- 
2.14.3

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


[libvirt] [dbus PATCH 3/9] connect: Fix List* methods to return empty array for empty list

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/connect.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index e96294d..cd90939 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -657,9 +657,6 @@ virtDBusConnectListDomains(GVariant *inArgs,
 if (virConnectListAllDomains(connect->connection, &domains, flags) < 0)
 return virtDBusUtilSetLastVirtError(error);
 
-if (!*domains)
-return;
-
 g_variant_builder_init(&builder, G_VARIANT_TYPE("ao"));
 
 for (gint i = 0; domains[i]; i++) {
@@ -697,9 +694,6 @@ virtDBusConnectListNetworks(GVariant *inArgs,
 if (virConnectListAllNetworks(connect->connection, &networks, flags) < 0)
 return virtDBusUtilSetLastVirtError(error);
 
-if (!*networks)
-return;
-
 g_variant_builder_init(&builder, G_VARIANT_TYPE("ao"));
 
 for (gint i = 0; networks[i]; i++) {
-- 
2.14.3

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


[libvirt] [dbus PATCH 2/9] Use ++ operator instead of += in for loop

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/connect.c | 10 +-
 src/main.c|  2 +-
 src/network.c |  2 +-
 src/util.c|  4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index 3d2be96..e96294d 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -39,7 +39,7 @@ virtDBusConnectClose(virtDBusConnect *connect,
  gboolean deregisterEvents)
 {
 
-for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1) {
+for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
 if (connect->domainCallbackIds[i] >= 0) {
 if (deregisterEvents) {
 virConnectDomainEventDeregisterAny(connect->connection,
@@ -49,7 +49,7 @@ virtDBusConnectClose(virtDBusConnect *connect,
 }
 }
 
-for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i += 1) {
+for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) {
 if (connect->networkCallbackIds[i] >= 0) {
 if (deregisterEvents) {
 virConnectNetworkEventDeregisterAny(connect->connection,
@@ -1135,10 +1135,10 @@ virtDBusConnectNew(virtDBusConnect **connectp,
 
 g_mutex_init(&connect->lock);
 
-for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1)
+for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++)
 connect->domainCallbackIds[i] = -1;
 
-for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i += 1)
+for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++)
 connect->networkCallbackIds[i] = -1;
 
 connect->bus = bus;
@@ -1170,7 +1170,7 @@ virtDBusConnectListFree(virtDBusConnect **connectList)
 if (!connectList)
 return;
 
-for (gint i = 0; connectList[i]; i += 1)
+for (gint i = 0; connectList[i]; i++)
 virtDBusConnectFree(connectList[i]);
 
 g_free(connectList);
diff --git a/src/main.c b/src/main.c
index eb30ef8..c953726 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,7 +54,7 @@ virtDBusAcquired(GDBusConnection *connection,
 virtDBusRegisterData *data = opaque;
 g_autoptr(GError) error = NULL;
 
-for (gsize i = 0; i < data->ndrivers; i += 1) {
+for (gsize i = 0; i < data->ndrivers; i++) {
 virtDBusConnectNew(&data->connectList[i], connection,
data->drivers[i].uri, data->drivers[i].object,
&error);
diff --git a/src/network.c b/src/network.c
index 2fb5ec6..1763eca 100644
--- a/src/network.c
+++ b/src/network.c
@@ -6,7 +6,7 @@
 static void
 virtDBusNetworkDHCPLeaseListFree(virNetworkDHCPLeasePtr *leases)
 {
-for (gint i = 0; leases[i] != NULL; i += 1)
+for (gint i = 0; leases[i] != NULL; i++)
 virNetworkDHCPLeaseFree(leases[i]);
 
 g_free(leases);
diff --git a/src/util.c b/src/util.c
index 4efa3ec..8b28496 100644
--- a/src/util.c
+++ b/src/util.c
@@ -208,7 +208,7 @@ virtDBusUtilVirDomainFromBusPath(virConnectPtr connection,
 void
 virtDBusUtilVirDomainListFree(virDomainPtr *domains)
 {
-for (gint i = 0; domains[i] != NULL; i += 1)
+for (gint i = 0; domains[i] != NULL; i++)
 virDomainFree(domains[i]);
 
 g_free(domains);
@@ -241,7 +241,7 @@ virtDBusUtilBusPathForVirNetwork(virNetworkPtr network,
 void
 virtDBusUtilVirNetworkListFree(virNetworkPtr *networks)
 {
-for (gint i = 0; networks[i] != NULL; i += 1)
+for (gint i = 0; networks[i] != NULL; i++)
 virNetworkFree(networks[i]);
 
 g_free(networks);
-- 
2.14.3

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


[libvirt] [dbus PATCH 8/9] domain: Introduce virtDBusDomainGVariantToCpumap helper

2018-05-07 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/domain.c | 55 ++-
 1 file changed, 22 insertions(+), 33 deletions(-)

diff --git a/src/domain.c b/src/domain.c
index c6dc744..2ba58e0 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -125,6 +125,25 @@ virtDBusDomainGVariantToMountpoints(GVariantIter *iter,
 }
 }
 
+static void
+virtDBusDomainGVariantToCpumap(GVariantIter *iter,
+   guchar **cpumap,
+   guint *cpumaplen)
+{
+gboolean usable;
+guint cpus = g_variant_iter_n_children(iter);
+guint cnt = 0;
+
+*cpumaplen = VIR_CPU_MAPLEN(cpus);
+*cpumap = g_new0(guchar, cpumaplen);
+
+while (g_variant_iter_loop(iter, "b", &usable)) {
+if (usable)
+VIR_USE_CPU(*cpumap, cnt);
+cnt++;
+}
+}
+
 static virDomainPtr
 virtDBusDomainGetVirDomain(virtDBusConnect *connect,
const gchar *objectPath,
@@ -1996,22 +2015,12 @@ virtDBusDomainPinEmulator(GVariant *inArgs,
 g_autoptr(virDomain) domain = NULL;
 g_autoptr(GVariantIter) iter = NULL;
 guint flags;
-guint cpus;
 guint cpumaplen;
 g_autofree guchar *cpumap = NULL;
-gboolean usable;
-guint cnt = 0;
 
 g_variant_get(inArgs, "(abu)", &iter, &flags);
 
-cpus = g_variant_iter_n_children(iter);
-cpumaplen = VIR_CPU_MAPLEN(cpus);
-cpumap = g_new0(guchar, cpumaplen);
-while (g_variant_iter_loop(iter, "b", &usable)) {
-if (usable)
-VIR_USE_CPU(cpumap, cnt);
-cnt++;
-}
+virtDBusDomainGVariantToCpumap(iter, &cpumap, &cpumaplen);
 
 domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
 if (!domain)
@@ -2036,22 +2045,12 @@ virtDBusDomainPinIOThread(GVariant *inArgs,
 guint iothreadId;
 g_autoptr(GVariantIter) iter = NULL;
 guint flags;
-guint cpus;
 guint cpumaplen;
 g_autofree guchar *cpumap = NULL;
-gboolean usable;
-guint cnt = 0;
 
 g_variant_get(inArgs, "(uabu)", &iothreadId, &iter, &flags);
 
-cpus = g_variant_iter_n_children(iter);
-cpumaplen = VIR_CPU_MAPLEN(cpus);
-cpumap = g_new0(guchar, cpumaplen);
-while (g_variant_iter_loop(iter, "b", &usable)) {
-if (usable)
-VIR_USE_CPU(cpumap, cnt);
-cnt++;
-}
+virtDBusDomainGVariantToCpumap(iter, &cpumap, &cpumaplen);
 
 domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
 if (!domain)
@@ -2076,22 +2075,12 @@ virtDBusDomainPinVcpu(GVariant *inArgs,
 guint vcpu;
 g_autoptr(GVariantIter) iter = NULL;
 guint flags;
-guint cpus;
 guint cpumaplen;
 g_autofree guchar *cpumap = NULL;
-gboolean usable;
-guint cnt = 0;
 
 g_variant_get(inArgs, "(uabu)", &vcpu, &iter, &flags);
 
-cpus = g_variant_iter_n_children(iter);
-cpumaplen = VIR_CPU_MAPLEN(cpus);
-cpumap = g_new0(guchar, cpumaplen);
-while (g_variant_iter_loop(iter, "b", &usable)) {
-if (usable)
-VIR_USE_CPU(cpumap, cnt);
-cnt++;
-}
+virtDBusDomainGVariantToCpumap(iter, &cpumap, &cpumaplen);
 
 domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
 if (!domain)
-- 
2.14.3

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


Re: [libvirt] [PATCH 0/1] Bug: Sandbox: libvirt breakdowns qemu guest

2018-05-07 Thread Christian Borntraeger
On 05/07/2018 05:32 AM, Yi Min Zhao wrote:
> 1. Problem Description
> ==
> If QEMU is built without seccomp support, 'elevatorprivileges' remains 
> compiled.
> This option of sandbox is treated as an indication for seccomp blacklist 
> support
> in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and
> 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the guest
> startup would fail.

Adding libvirt list.

This would still fail with older QEMUs, so the question is if we should also OR 
instead
change something in libvirt.

> 
> 2. Libvirt Log
> ==
> qemu-system-s390x: -sandbox 
> on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
> resourcecontrol=deny: seccomp support is disabled
> 
> 3. Fixup
> 
> Wrap the options except 'enable' for qemu_sandbox_opts by CONFIG_SECCOMP.
> 
> Yi Min Zhao (1):
>   sandbox: avoid to compile options if CONFIG_SECCOMP undefined
> 
>  vl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

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


Re: [libvirt] [PATCH 0/8] vfio-ccw passthrough support

2018-05-07 Thread Boris Fiuczynski

On 05/04/2018 05:07 PM, John Ferlan wrote:



On 04/26/2018 03:59 AM, Bjoern Walk wrote:

Shalini Chellathurai Saroja  [2018-04-11, 05:49PM 
+0200]:

Let us support the basic channel I/O passthrough infrastructure based on
vfio, which have been introduced in QEMU 2.10. The current focus is to
support dasd-eckd (cu_type/dev_type = 0x3990/0x3390) as the target
device.

Shalini Chellathurai Saroja (8):
   qemu: introduce capability for virtual-css-bridge
   qemu: introduce vfio-ccw capability
   util: virhostdev: add virHostdevIsMdevDevice()
   qemu: vfio-ccw device address generation
   qemu: command line generation for vfio-ccw device
   tests: tests for vfio-ccw passthrough
   docs: documentation for vfio-ccw passthrough
   news: documentation of new feature


Any chance, we get at least a review before 4.3 hits? Would be
appreciated.




So obviously this did not make the 4.3.0 and the series will need a
refresh due to the volume of change in qemu_capabilities.{c,h}.

I've reviewed a number of patches recently and made a similar comment in
all of them - when changing qemu_capabilities.{c,h} and updating the
various qemucapabilitiesdata/caps_*.xml files - do so in a separate
patch. That way if someone doesn't review the code right away, it's
actually fairly simple to recreate at least the capability for a
reviewer. Having it mixed in one patch with other qemu, conf, test, etc.
changes causes git am -3 to fail and thus makes review harder especially
when you don't get to reviews as soon as patches hit the list.

I am going to send out a new rebased version shortly.



Someone may also want to consider creating a s390 specific version of
what Peter did for x86_64 for VIR_TEST_CAPS_LATEST in order to then
have/use the "latest" capabilities instead of adding bits to xml2argv
tests. I'm curious why the xml2xml test needed the bit adjustment - did
something fail?  Since there were no xml output data changes, that would
seem to indicate there isn't a need to modify the xml2xml test source.
I am not sure if I understood you correctly. Are you referring to patch 
1? If so the changes are caused by a new QEMU_CAPS_CCW capability 
replacing the QEMU_CAPS_VIRTIO_CCW capability. More is explained in the 
commit message of the patch. In short: With support of vfio-ccw it 
became apparent that the existence of the ccw bus is not well sourced by 
observing virtio-ccw and therefore we replaced it with the detection of 
the virtual-css-bridge. Let me know if I understood you wrong.




John

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




--
Mit freundlichen Grüßen/Kind regards
   Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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

Re: [libvirt] [PATCHv1 7/7] qemu_driver: Baseline CPU model using QEMU

2018-05-07 Thread Jiri Denemark
On Sat, May 05, 2018 at 12:48:49 -0500, Chris Venteicher wrote:
> virsh cpu-baseline determines baseline from QEMU for some architectures
> and libvirt for others.
> 
> Skip the QEMU attempt to save time on architectures QEMU baseline does
> not support.

This is not the right direction. As explained by me and Daniel in
response to Collin, we need a new public API for this functionality. I'm
already working on new CPU related APIs and I hope to send them soon.

Jirka

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


Re: [libvirt] [PATCH REBASE 4/5] qemu: fix domain object wait to handle monitor errors

2018-05-07 Thread Nikolay Shirokovskiy


On 04.05.2018 17:52, John Ferlan wrote:
> 
> 
> On 05/03/2018 03:54 AM, Nikolay Shirokovskiy wrote:
>>
>>
>> On 01.05.2018 01:03, John Ferlan wrote:
>>>
>>>
>>> On 04/18/2018 10:44 AM, Nikolay Shirokovskiy wrote:
 Block job abort operation can not handle properly qemu crashes
 when waiting for abort/pivot completion. Deadlock scenario is next:

 - qemuDomainBlockJobAbort waits for pivot/abort completion
 - qemu crashes, then qemuProcessBeginStopJob broadcasts for VM condition 
 and
   then waits for job condition (taken by qemuDomainBlockJobAbort)
 - qemuDomainBlockJobAbort awakes but nothing really changed, VM is still
   active (vm->def->id != -1) so thread starts waiting for completion again.
   Now two threads are in deadlock.

 First let's add some condition besides domain active status so that waiting
 thread can check it when awakes. Second let's move signalling to the place
 where condition is set, namely monitor eof/error handlers. Having 
 signalling
 in qemuProcessBeginStopJob is not useful.

 The patch copies monitor error to domain state because at time
 waiting thread awakes there can be no monitor and it is useful to
 report monitor error to user.

 The patch has a drawback that on destroying a domain when waiting for
 event from monitor we get not very convinient error message like
>>>
>>> convenient
>>>
 'EOF from monitor' from waiting API. On the other hand if qemu crashes
 this is more useful then 'domain is not running'. The first case
 will be addressed in another patch.

 The patch also fixes other places where we wait for event from qemu.
 Namely handling device removal and tray ejection. Other places which
 used virDomainObjWait (dump, migration, save) were good because of
 async jobs which allow concurrent destroy job.

 Signed-off-by: Nikolay Shirokovskiy 
 ---
  src/conf/domain_conf.c| 43 ---
  src/conf/domain_conf.h|  3 ---
  src/libvirt_private.syms  |  2 --
  src/qemu/qemu_domain.c| 45 
 +
  src/qemu/qemu_domain.h|  5 -
  src/qemu/qemu_driver.c|  6 +++---
  src/qemu/qemu_hotplug.c   |  4 ++--
  src/qemu/qemu_migration.c | 12 ++--
  src/qemu/qemu_process.c   | 27 ++-
  9 files changed, 82 insertions(+), 65 deletions(-)

>>>
>>> This no longer git am -3 applies and based on previous patch reviews, I
>>> think perhaps this needs to be redone.
>>
>> I'll resend as soon as we come to agreement on series. Now I'm not
>> convinced to change much (except for using distinct flag to indicate error
>> as mentioned in 2nd patch discussion, then I don't need 3d patch).
>>
>> See comments below.
>>
>>>
>>> I don't believe moving/renaming virDomainObjWait is good/right, but I'm
>>> sure there would be other opinions on that.  Yes, QEMU is currently the
>>> only consumer... If it were to move, it should move to virdomainobjlist
>>> since that's where innards of virDomainObjPtr are managed. The fact that
>>> we look at ->parent.lock, well, ...
>>
>> I would not move the function without reason. It gets new name 
>> qemuDomainObjWait
>> becase it use qemu specific data, namely monError.
> 
> Today only qemu uses this generic virDomainObjWait which is generic
> without the need to have/use qemu specific things. Other domain
> consumers could use it if they chose.
> 
> I'm not in favor of moving, renaming, repurposing for a very specific
> issue for what is a generically used function. Maybe that's just me - so
> you could try to get a different reviewer if you want.

Sorry.

> 
> 
>>
>>>
>>> Anyway, you're attempting to special case something and perhaps you just
>>> need to create a qemuDomainObjWait that would call the timeout version
>>> of the virDomainObjWait and be able to handle whether some other error
>>> occurred.  Wouldn't the LastError before the current wait return NULL
>>> (as in no error), then during the timeout period if LastError is
>>> something couldn't that indicate the failure you're looking for.
>>
>> I introduced qemuDomainObjWait not to put virDomainObjWait and 
>> virDomainObjWaitUntil
>> in the first place but to check monError. Then rather then keeping too 
>> functions
>> it's look more simple to use only one and branch on given timeout.
>>
> 
> I would think if the goal was to have specific code for a specific
> purpose for specific functions, then introduce the qemuDomainObjWait,
> but have it call virDomainObjWait[Until] based on the need you have.
> Which in this case appears to fiddle with monError in some way.
> 
> Again - that's just my opinion
> 
> John
> 

Ok we can do that way. I just think that as 
virDomainObjWait/virDomainObjWaitUntil
will not be used anywhere in code after the patch then sooner or later somebody 
will
clean them up.

[libvirt] [PATCHv2] Deprecate QEMU_CAPS_NESTING

2018-05-07 Thread Ján Tomko
Unused since commit .

Signed-off-by: Ján Tomko 
---
v2: also delete the hasHwVirt variable as well as the whole 'svm'
checking

 src/qemu/qemu_capabilities.h |  2 +-
 src/qemu/qemu_command.c  | 24 
 2 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index abd6eff14a..b9628b8266 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -105,7 +105,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
 
 /* 40 */
 X_QEMU_CAPS_FSDEV, /* -fstype filesystem passthrough */
-QEMU_CAPS_NESTING, /* -enable-nesting (SVM/VMX) */
+X_QEMU_CAPS_NESTING, /* -enable-nesting (SVM/VMX) */
 X_QEMU_CAPS_NAME_PROCESS, /* Is -name process= available */
 X_QEMU_CAPS_DRIVE_READONLY, /* -drive readonly=on|off */
 X_QEMU_CAPS_SMBIOS_TYPE, /* Is -smbios type= available */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 50b0ffcf94..22c560c67c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6652,7 +6652,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
 {
 virArch hostarch = virArchFromHost();
 char *cpu = NULL, *cpu_flags = NULL;
-bool hasHwVirt = false;
 int ret = -1;
 virBuffer cpu_buf = VIR_BUFFER_INITIALIZER;
 virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -6662,26 +6661,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
 (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) {
 if (qemuBuildCpuModelArgStr(driver, def, &cpu_buf, qemuCaps) < 0)
 goto cleanup;
-
-/* Only 'svm' requires --enable-nesting. The nested 'vmx' patches now
- * simply hook off the CPU features. */
-if (ARCH_IS_X86(def->os.arch) &&
-def->virtType == VIR_DOMAIN_VIRT_KVM) {
-virCPUDefPtr cpuDef = NULL;
-
-if (def->cpu->mode == VIR_CPU_MODE_CUSTOM)
-cpuDef = def->cpu;
-else if (def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH)
-cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType,
- 
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
-
-if (cpuDef) {
-int svm = virCPUCheckFeature(def->os.arch, cpuDef, "svm");
-if (svm < 0)
-goto cleanup;
-hasHwVirt = svm > 0;
-}
-}
 } else {
 /*
  * Need to force a 32-bit guest CPU type if
@@ -6870,9 +6849,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
 if (cpu) {
 virCommandAddArg(cmd, "-cpu");
 virCommandAddArgFormat(cmd, "%s%s", cpu, cpu_flags ? cpu_flags : "");
-
-if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NESTING) && hasHwVirt)
-virCommandAddArg(cmd, "-enable-nesting");
 }
 
 ret = 0;
-- 
2.16.1

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

Re: [libvirt] [PATCH REBASE 3/5] utils: export virCopyError

2018-05-07 Thread Nikolay Shirokovskiy


On 04.05.2018 16:58, John Ferlan wrote:
> 
> 
> On 05/03/2018 03:39 AM, Nikolay Shirokovskiy wrote:
>>
>>
>> On 01.05.2018 01:03, John Ferlan wrote:
>>>
>>>
>>> On 04/18/2018 10:44 AM, Nikolay Shirokovskiy wrote:
 Signed-off-by: Nikolay Shirokovskiy 
 ---
  src/libvirt_private.syms |  1 +
  src/util/virerror.c  | 12 +---
  src/util/virerror.h  |  1 +
  3 files changed, 11 insertions(+), 3 deletions(-)

>>>
>>> NACK, you should be using virErrorCopyNew
>>>
>>> John
>>
>> I introduced monError in qemuDomainObjPrivatePtr in next patch and it is not 
>> a pointer so
>> I need this function. I did not make monError pointer for the same reason it 
>> is not pointer
>> in monitor object - I use monError both as flag and as error message.
>>
> 
> I saw what you did - the fact is virCopyError is coded as private to the
> module. Just making it global because you have a use for it is I believe
> incorrect.

But why?

> 
> Ironically in the next patch you have:
> 
> +virErrorPtr err = qemuMonitorLastError(mon);
> +
> +virCopyError(err, &priv->monError);
> 
> 
> The first call isn't guaranteed to set @err and all you're essentially
> doing is wanting to copy from mon->lastError to priv->monError or
> perhaps similar to virCopyLastError.

It is ok that error can turn from non-NULL to NULL on copy due to OOM
conditions or whaever. It is just as in previous patch. We use priv->monError
for 2 purpuses. And thus qemuProcessNotifyMonitorError sets priv->monError.code
explicitly if it still set to VIR_ERR_OK after copy.

> 
> Maybe some new API in virerror.c should handle that.
> 

Not sure we need it at this point. But may be I miss something, please
share your vision in more detail then.

Nikolay

> 
>>>
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index b31f599..6bbbf77 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1702,6 +1702,7 @@ ebtablesRemoveForwardAllowIn;
  
  
  # util/virerror.h
 +virCopyError;
  virDispatchError;
  virErrorCopyNew;
  virErrorInitialize;
 diff --git a/src/util/virerror.c b/src/util/virerror.c
 index c000b00..2ff8a3e 100644
 --- a/src/util/virerror.c
 +++ b/src/util/virerror.c
 @@ -188,10 +188,16 @@ virErrorGenericFailure(virErrorPtr err)
  }
  
  
 -/*
 - * Internal helper to perform a deep copy of an error
 +/**
 + * virCopyError:
 + * @from: error to copy from
 + * @to: error to copy to
 + *
 + * Copy error fields from @from to @to.
 + *
 + * Returns 0 on success, -1 on failure.
   */
 -static int
 +int
  virCopyError(virErrorPtr from,
   virErrorPtr to)
  {
 diff --git a/src/util/virerror.h b/src/util/virerror.h
 index 760bfa4..90ac619 100644
 --- a/src/util/virerror.h
 +++ b/src/util/virerror.h
 @@ -192,6 +192,7 @@ void virReportOOMErrorFull(int domcode,
  
  int virSetError(virErrorPtr newerr);
  virErrorPtr virErrorCopyNew(virErrorPtr err);
 +int virCopyError(virErrorPtr from, virErrorPtr to);
  void virDispatchError(virConnectPtr conn);
  const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen);
  


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


Re: [libvirt] [PATCH] xenconfig: Remove references to my name and email

2018-05-07 Thread Peter Krempa
On Sat, May 05, 2018 at 12:17:05 +0300, David Kiarie wrote:
> On Sat, May 5, 2018 at 12:15 PM, David Kiarie 
> wrote:
> 
> > Replace references to my name and email with a pseudonym
> >
> 
> Sorry, I just want my real name and email off these files and I keep making
> silly mistakes.

How about just deleting them? We don't really support using pseudonyms.


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