Re: [PATCH 24/24] qemu: backup: Setup TLS environment for pull-mode backup jobs

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Use the configured TLS env to setup encryption of the TLS transport.

https://bugzilla.redhat.com/show_bug.cgi?id=1822631

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_backup.c | 80 +++---
  1 file changed, 76 insertions(+), 4 deletions(-)



Cool!

Testing this will be complicated (having to create keys, configure 
libvirt to use them, as well as an NBD client that can connect using the 
client counterpart), but as all of the pieces have been in libvirt and 
you are just wiring them together, I suspect it should work even if it 
is not a trivial setup.


Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 23/24] conf: backup: Add 'tls' attribute for 'server' element

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Allow enabling TLS for the NBD server used to do pull-mode backups. Note
that documentation already mentions 'tls', so this just implements the
schema and XML bits.

Signed-off-by: Peter Krempa 
---



+++ b/tests/domainbackupxml2xmlin/backup-pull-encrypted.xml
@@ -1,6 +1,6 @@
  
1525889631
-  
+  


So this doesn't say what files are actually feeding the TLS 
configuration; the docs already mentioned 'tls', but do we need to add a 
cross-reference that states when tls='yes' is in effect then the server 
uses the files as configured in qemu.conf?  Knowing how the server is 
keyed is important for writing a client that can connect over TLS to the 
server.


But the overall idea makes sense.

Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 22/24] qemu: conf: Add configuration of TLS environment for NBD transport of pull-backups

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

TLS is required to transport backed-up data securely when using
pull-mode backups.

Signed-off-by: Peter Krempa 
---
  docs/formatbackup.rst  |  4 
  src/qemu/libvirtd_qemu.aug |  5 
  src/qemu/qemu.conf | 37 ++
  src/qemu/qemu_conf.c   | 17 ++
  src/qemu/qemu_conf.h   |  5 
  src/qemu/test_libvirtd_qemu.aug.in |  3 +++
  6 files changed, 71 insertions(+)


Aha - answering my question from 21/24 ;)

Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 21/24] conf: backup: Store 'tlsAlias' and 'tlsSecretAlias' as internals of a backup

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Add fields for storing the aliases necessary to clean up the TLS env for
a backup job after it finishes.

Signed-off-by: Peter Krempa 
---



+++ b/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
@@ -0,0 +1,36 @@
+
+  1525889631
+  


Are you also planning on encrypting the NBD server?  As written, this is 
still a plain-text NBD server.



+  
+
+  
+  
+
+  


It looks like this patch is just encrypting the temporary file (ensuring 
that guest data cannot be read at rest on the host machine).


But even without NBD encryption, this is a nice improvement.

Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 19/24] checkpoint: Mention that VIR_DOMAIN_CHECKPOINT_XML_SIZE is expensive and stale

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Data is valid only when queried as guest writes may increase the backup
size.

Signed-off-by: Peter Krempa 
---
  docs/formatcheckpoint.rst   | 4 
  src/libvirt-domain-checkpoint.c | 3 ++-
  2 files changed, 6 insertions(+), 1 deletion(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 20/24] testCompareBackupXML: Add infrastructure for testing internal fields

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

There are few internal fields of the backup XML. Propagate the
'internal' flag so that the test can verify the XML infrastructure.

Signed-off-by: Peter Krempa 
---
  tests/genericxml2xmltest.c | 30 --
  1 file changed, 24 insertions(+), 6 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 18/24] qemu: checkpoint: Implement VIR_DOMAIN_CHECKPOINT_XML_SIZE

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Introduce code which merges the appropriate bitmaps and queries the
final size of the backup, so that we can print the XML with size
information.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_checkpoint.c | 143 -
  1 file changed, 142 insertions(+), 1 deletion(-)




+/* we need to calculate the merged bitmap to obtain accurate data */
+for (i = 0; i < ndisks; i++) {
+virDomainDiskDefPtr domdisk = diskmap[i].domdisk;
+g_autoptr(virJSONValue) actions = NULL;
+
+/* possibly delete leftovers from previous cases */
+if (qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, 
domdisk->src,
+  "libvirt-tmp-size-xml")) {
+if (!recoveractions)
+recoveractions = virJSONValueNewArray();
+
+if (qemuMonitorTransactionBitmapRemove(recoveractions,
+   domdisk->src->nodeformat,
+   "libvirt-tmp-size-xml") < 0)
+goto endjob;
+}


Odd that we may leave a temporary bitmap in qemu's memory if we fail 
partway through, but not the end of the world, and you handle it nicely 
here.


Nice that we finally got this feature working even across snapshots or 
multiple checkpoints, thanks to your recent refactoring to make 
checkpoints simpler (my original implementation only grabbed this 
information for the most recent checkpoint, because the work to merge 
bitmaps for older bitmaps was tougher).


Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 17/24] conf: checkpoint: Add a flag storing whether disk 'size' is valid

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Avoid printing '0' size in case when we weren't able to determine the
backup size by adding a flag whether the size is valid and interlock
printing of the field according to the flag.

Signed-off-by: Peter Krempa 
---
  src/conf/checkpoint_conf.c  | 2 +-
  src/conf/checkpoint_conf.h  | 1 +
  tests/qemudomaincheckpointxml2xmltest.c | 1 +
  3 files changed, 3 insertions(+), 1 deletion(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 16/24] docs: checkpoint: Convert XML documentation to RST

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Switch to the new format for easier extension.

Signed-off-by: Peter Krempa 
---
  docs/formatcheckpoint.html.in | 198 --
  docs/formatcheckpoint.rst | 162 
  2 files changed, 162 insertions(+), 198 deletions(-)
  delete mode 100644 docs/formatcheckpoint.html.in
  create mode 100644 docs/formatcheckpoint.rst



Again, I'm not strong in .rst, but the conversion seems sane.

Reviewed-by: Eric Blake 


+second full backup would require. Most disk checkpoints are created in
+conjunction with a backup via ``virDomainBackupBegin()``, although a future API
+addition of ``virDomainSnapshotCreateXML2()`` will also make this possible when
+creating external snapshots; however, libvirt also exposes enough support to
+create disk checkpoints independently from a backup operation via
+``virDomainCheckpointCreateXML()`` since 5.6.0. Likewise, the creation of
+checkpoints when external snapshots exist is currently forbidden, although
+future work will make it possible to integrate these two concepts.


Not for this patch (which is just a reformat, not editing), but how 
close are we to getting to these future additions (the notion of 
atomically creating a checkpoint alongside the snapshot creation, as 
well as all the work you did to enable checkpoints and snapshots together)?


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 15/24] qemu: backup: integrate with blockpull

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

Merge the bitmaps when finalizing a block pull job so that backups work
properly afterwards.

https://bugzilla.redhat.com/show_bug.cgi?id=1799010

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_blockjob.c | 37 +
  1 file changed, 37 insertions(+)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 14/24] backup: Allow configuring incremental backup per-disk individually

2020-07-02 Thread Eric Blake

On 7/2/20 9:40 AM, Peter Krempa wrote:

The semantics of the backup operation don't strictly require that all
disks being backed up are part of the same incremental part (when a disk
was checkpointed/backed up separately or in a different VM), or even
they may not have an previous checkpoint at all (e.g. when the disk
was freshly hotplugged to the vm).

In such cases we can still create a common checkpoint for all of them
and backup differences according to configuration.

This patch adds a per-disk configuration of the checkpoint to do the
incremental backup from via the 'incremental' attribute and allows
perform full backups via the 'backupmode' attribute.

Note that no changes to the qemu driver are necessary to take advantage
of this as we already obey the per-disk 'incremental' field.

https://bugzilla.redhat.com/show_bug.cgi?id=1829829

Signed-off-by: Peter Krempa 
---
  docs/formatbackup.rst| 11 
  docs/schemas/domainbackup.rng| 16 ++
  src/conf/backup_conf.c   | 57 +++-
  src/conf/backup_conf.h   | 11 
  tests/domainbackupxml2xmlin/backup-pull.xml  | 12 +
  tests/domainbackupxml2xmlout/backup-pull.xml | 12 +
  6 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/docs/formatbackup.rst b/docs/formatbackup.rst
index 66583f562b..e5b6fc6eb0 100644
--- a/docs/formatbackup.rst
+++ b/docs/formatbackup.rst
@@ -65,6 +65,17 @@ were supplied). The following child elements and attributes 
are supported:
   should take part in the backup and using ``no`` excludes the disk 
from
   the backup.

+  ``backupmode``
+ This attribute overrides the implied backup mode inherited from the
+ definition of the backup itself. Value ``full`` forces a full backup
+ even if the backup calls for an incremental backup and ``incremental``


s/backup and/backup, and/


+ coupled with the attribute ``incremental='CHECKPOINTNAME`` for the 
disk
+ forces an incremental backup from ``CHECKPOINTNAME``.
+
+   ``incremental``
+ An optional attribute giving the name of an existing checkpoint of the
+ domain which overrides the one set by the  element.
+
``exportname``
   Allows modification of the NBD export name for the given disk. By
   default equal to disk target. Valid only for pull mode backups.
diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng
index 5165175152..650f5cd4c3 100644
--- a/docs/schemas/domainbackup.rng
+++ b/docs/schemas/domainbackup.rng
@@ -89,6 +89,20 @@
  


+  
+
+  
+
+  full
+  incremental
+
+  
+
+
+  
+
+  


As written, you validate:

backupmode="full" incremental="blah"

Better might be:


  

  
full
  
  

  
incremental
  


  

  

  


which also has the advantage of allowing the user to omit 
backupmode='incremental' when supplying incremental='name' (since then 
that mode is implied).


Do we need to restrict the set of values that can be supplied for a 
incremental name?  (That's a bigger issue than just this patch: for 
example, do we want to refuse a checkpoint named "../foo"?  As long as 
checkpoint names don't match directly to file names, we aren't at risk 
of a filesystem escape, but starting strict and relaxing later is better 
than starting relaxed and wishing we had limited certain patterns after all)




@@ -465,6 +493,24 @@ virDomainBackupAlignDisks(virDomainBackupDefPtr def,
  return -1;
  }

+if (backupdisk->backupmode == VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_FULL 
&&
+backupdisk->incremental) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("'full' backup mode incompatible with 'incremental' 
for disk '%s'"),
+   backupdisk->name);
+return -1;
+}


You had to check this manually, instead of letting the .rng file enforce 
it for you by the construct I listed above as an alternative.



+
+if (backupdisk->backupmode == VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_INCREMENTAL 
&&
+!backupdisk->incremental &&
+!def->incremental) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("'incremental' backup mode of disk '%s' requires 
setting 'incremental' field for disk or backup"),
+   backupdisk->name);
+return -1;
+}


Do we really need to require that the user provides 
backupmode='incremental', or if they omit it, can we just imply it based 
on the presence of incremental='name'?




+++ b/tests/domainbackupxml2xmlin/backup-pull.xml
@@ -6,5 +6,17 @@

  
  
+
+  
+


So this is a demo of overriding an overall incremental 

Re: [PATCH 13/24] docs: backup: Convert XML documentation to RST

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Switch to the new format for easier extension.

Signed-off-by: Peter Krempa 
---
  docs/formatbackup.html.in | 191 --
  docs/formatbackup.rst | 149 +
  2 files changed, 149 insertions(+), 191 deletions(-)
  delete mode 100644 docs/formatbackup.html.in
  create mode 100644 docs/formatbackup.rst



I'm not an rst expert, but the conversion seems sane enough.

Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 12/24] conf: backup: Don't explicitly forbid backup of read-only disk

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Users may want to use this to create a full backup or even incremental
if the checkpoints are pre existing. We still will not allow to create a


pre-existing


checkpoint on a read-only disk as that makes no sense.

https://bugzilla.redhat.com/show_bug.cgi?id=1840053

Signed-off-by: Peter Krempa 
---
  src/conf/backup_conf.c | 7 ---
  1 file changed, 7 deletions(-)



Reviewed-by: Eric Blake 


diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 92106d8aaa..e9eea5af75 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -411,13 +411,6 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDefPtr 
disk,
 _("disk '%s' has no media"), disk->name);
  return -1;
  }
-} else if (src->readonly) {
-if (disk->store) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("backup of readonly disk '%s' makes no sense"),
-   disk->name);
-return -1;
-}
  } else if (!disk->store) {
  if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_FILE) {
  if (!(disk->store = virStorageSourceNew()))



--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 11/24] tests: qemuxml2argv: Test encrypted TLS key for nbd/vxhs disks

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Add a dummy secret so that we see what command line is generated.

Signed-off-by: Peter Krempa 
---
  .../disk-network-tlsx509.x86_64-2.12.0.args| 15 ---
  .../disk-network-tlsx509.x86_64-latest.args| 18 +++---
  tests/qemuxml2argvtest.c   |  2 ++
  3 files changed, 29 insertions(+), 6 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 06/24] virQEMUDriverConfigLoadSpecificTLSEntry: Split up fetching of server-only config options

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

The '*_tls_x509_verify' options are relevant only when we are going to
expose a server socket as client sockets always enable verification.

Split up the macro to separate the common bits from the server bits so
that when we'll later extend support of 'nbd' and 'vxhs' disks which are
client only we can reuse the existing macros.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_conf.c | 25 -
  1 file changed, 16 insertions(+), 9 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 09/24] qemu: conf: Add configuration of TLS key encryption for 'vxhs' and 'nbd' disks

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Until now libvirt didn't allow using encrypted TLS key for disk clients.

Add fields for configuring the secret and propagate defaults.

Signed-off-by: Peter Krempa 
---
  src/qemu/libvirtd_qemu.aug |  2 ++
  src/qemu/qemu.conf | 19 +++
  src/qemu/qemu_conf.c   | 13 +
  src/qemu/qemu_conf.h   |  2 ++
  src/qemu/test_libvirtd_qemu.aug.in |  2 ++
  5 files changed, 34 insertions(+), 4 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 10/24] qemu: domain: Setup secret for TLS key for nbd/vxhs disks

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Setup the TLS secret when preparing a virStorageSource for use.

https://bugzilla.redhat.com/show_bug.cgi?id=1602328

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


Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 07/24] qemu: domain: Add infrastructure passing in TLS key's decryption key via 'secret'

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Store the required data in the private data of a storage source and
ensure that the 'alias' of the secret is formatted in the status XML.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_domain.c| 10 +-
  src/qemu/qemu_domain.h|  3 +++
  tests/qemustatusxml2xmldata/modern-in.xml |  1 +
  3 files changed, 13 insertions(+), 1 deletion(-)




+++ b/tests/qemustatusxml2xmldata/modern-in.xml
@@ -336,6 +336,7 @@
  
  
  
+


Why to the other elements use '-' but this one uses ' '?

Otherwise,
Reviewed-by: Eric Blake 


  

  



--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 08/24] qemu block: Add internals for handling 'secret' corresponding to TLS key

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Add infrastructure for hot- and cold-plug of the secret object holding
decryption key for the TLS key.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_block.c   | 12 
  src/qemu/qemu_block.h   |  2 ++
  src/qemu/qemu_command.c | 11 ++-
  3 files changed, 24 insertions(+), 1 deletion(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 05/24] virQEMUDriverConfigLoadSpecificTLSEntry: Move fetching of 'chardev_tls' above macro

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Move the extraction of the config value so that it makes more sense
after upcoming refactors.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_conf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 04/24] qemu: conf: Move 'nbd' and 'vxhs' tls config variables together with rest of tls setup

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Signed-off-by: Peter Krempa 
---
  src/qemu/libvirtd_qemu.aug | 12 ++--
  src/qemu/qemu_conf.h   | 12 ++--
  2 files changed, 12 insertions(+), 12 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 03/24] qemu.conf: Remove misleading mention of 'migrate_tls'

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

There's no such parameter. Reword the sentence to account for enabling
TLS-encrypted migration using API flags.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu.conf | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)



Reviewed-by: Eric Blake 


diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index f89dbd2c3a..9b04c8534b 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -340,9 +340,10 @@
  # In order to override the default TLS certificate location for migration
  # certificates, supply a valid path to the certificate directory. If the
  # provided path does not exist, libvirtd will fail to start. If the path is
-# not provided, but migrate_tls = 1, then the default_tls_x509_cert_dir path
-# will be used. Once/if a default certificate is enabled/defined, migration
-# will then be able to use the certificate via migration API flags.
+# not provided, but TLS-encrypted migration is requested, then the
+# default_tls_x509_cert_dir path will be used. Once/if a default certificate is
+# enabled/defined, migration will then be able to use the certificate via
+# migration API flags.
  #
  #migrate_tls_x509_cert_dir = "/etc/pki/libvirt-migrate"



--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 02/24] qemuDomainDiskHasEncryptionSecret: unexport

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_domain.c | 2 +-
  src/qemu/qemu_domain.h | 3 ---
  2 files changed, 1 insertion(+), 4 deletions(-)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 01/24] qemu: domain: Introduce helper for always fetching virStorageSource private data

2020-07-02 Thread Eric Blake

On 7/2/20 9:39 AM, Peter Krempa wrote:

Add a helper which will always return the storage source private data
even if it was not allocated before.

Signed-off-by: Peter Krempa 
---
  src/qemu/qemu_domain.c | 10 ++
  src/qemu/qemu_domain.h |  2 ++
  2 files changed, 12 insertions(+)



Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



Re: [PATCH 00/24] qemu: Incremental backup and TLS handling fixes

2020-07-02 Thread Andrea Bolognani
On Thu, 2020-07-02 at 16:39 +0200, Peter Krempa wrote:
> This series consists of multiple parts fixing the following bugs. Some
> of them depend on previous so I'm sending it as one to prevent
> conflicts.
> 
> - Patches 1 - 11:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1602328
>   [RFE] Add support for encrypted TLS client keys for disks
> 
> - Patch 12:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1840053
>   [incremental_backup] cannot do FULL backup for a READONLY disk
> 
> - Patches 13 - 14:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1829829
>[incremental backup] Creating incremental backup that includes a new VM 
> disk that requires full backup is impossible
> 
> - Patch 15:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1799010
>   incremental-backup: RFE: Handle backup bitmaps during virDomainBlockPull
> 
> - Patches 16 - 24:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1822631
>   [incremental backup] RFE: Support TLS for NBD connections for pull mode 
> backup

Can you please include updates to the release notes in your series?
Based on the summary above, it sounds like most of the changes will
be user-visible. Thanks!

-- 
Andrea Bolognani / Red Hat / Virtualization



Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-02 Thread Peter Xu
On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote:
> So I think we agree that a new notifier is needed?

Good to me, or a new flag should be easier (IOMMU_NOTIFIER_DEV_IOTLB)?

-- 
Peter Xu



[PATCH 14/24] backup: Allow configuring incremental backup per-disk individually

2020-07-02 Thread Peter Krempa
The semantics of the backup operation don't strictly require that all
disks being backed up are part of the same incremental part (when a disk
was checkpointed/backed up separately or in a different VM), or even
they may not have an previous checkpoint at all (e.g. when the disk
was freshly hotplugged to the vm).

In such cases we can still create a common checkpoint for all of them
and backup differences according to configuration.

This patch adds a per-disk configuration of the checkpoint to do the
incremental backup from via the 'incremental' attribute and allows
perform full backups via the 'backupmode' attribute.

Note that no changes to the qemu driver are necessary to take advantage
of this as we already obey the per-disk 'incremental' field.

https://bugzilla.redhat.com/show_bug.cgi?id=1829829

Signed-off-by: Peter Krempa 
---
 docs/formatbackup.rst| 11 
 docs/schemas/domainbackup.rng| 16 ++
 src/conf/backup_conf.c   | 57 +++-
 src/conf/backup_conf.h   | 11 
 tests/domainbackupxml2xmlin/backup-pull.xml  | 12 +
 tests/domainbackupxml2xmlout/backup-pull.xml | 12 +
 6 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/docs/formatbackup.rst b/docs/formatbackup.rst
index 66583f562b..e5b6fc6eb0 100644
--- a/docs/formatbackup.rst
+++ b/docs/formatbackup.rst
@@ -65,6 +65,17 @@ were supplied). The following child elements and attributes 
are supported:
  should take part in the backup and using ``no`` excludes the disk from
  the backup.

+  ``backupmode``
+ This attribute overrides the implied backup mode inherited from the
+ definition of the backup itself. Value ``full`` forces a full backup
+ even if the backup calls for an incremental backup and ``incremental``
+ coupled with the attribute ``incremental='CHECKPOINTNAME`` for the 
disk
+ forces an incremental backup from ``CHECKPOINTNAME``.
+
+   ``incremental``
+ An optional attribute giving the name of an existing checkpoint of the
+ domain which overrides the one set by the  element.
+
   ``exportname``
  Allows modification of the NBD export name for the given disk. By
  default equal to disk target. Valid only for pull mode backups.
diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng
index 5165175152..650f5cd4c3 100644
--- a/docs/schemas/domainbackup.rng
+++ b/docs/schemas/domainbackup.rng
@@ -89,6 +89,20 @@
 
   

+  
+
+  
+
+  full
+  incremental
+
+  
+
+
+  
+
+  
+
   
 
   
@@ -127,6 +141,7 @@
 
   
 
+
 
   
 
@@ -196,6 +211,7 @@
 
   
 
+
 
   
 
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index e9eea5af75..4f28073ab2 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -56,6 +56,13 @@ VIR_ENUM_IMPL(virDomainBackupDiskState,
   "cancelling",
   "cancelled");

+VIR_ENUM_DECL(virDomainBackupDiskBackupMode);
+VIR_ENUM_IMPL(virDomainBackupDiskBackupMode,
+  VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_LAST,
+  "",
+  "full",
+  "incremental");
+
 void
 virDomainBackupDefFree(virDomainBackupDefPtr def)
 {
@@ -96,6 +103,7 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
 g_autofree char *driver = NULL;
 g_autofree char *backup = NULL;
 g_autofree char *state = NULL;
+g_autofree char *backupmode = NULL;
 int tmp;
 xmlNodePtr srcNode;
 unsigned int storageSourceParseFlags = 0;
@@ -133,6 +141,19 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
 def->exportbitmap = virXMLPropString(node, "exportbitmap");
 }

+if ((backupmode = virXMLPropString(node, "backupmode"))) {
+if ((tmp = virDomainBackupDiskBackupModeTypeFromString(backupmode)) < 
0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _("invalid backupmode '%s' of disk '%s'"),
+   backupmode, def->name);
+return -1;
+}
+
+def->backupmode = tmp;
+}
+
+def->incremental = virXMLPropString(node, "incremental");
+
 if (internal) {
 if (!(state = virXMLPropString(node, "state")) ||
 (tmp = virDomainBackupDiskStateTypeFromString(state)) < 0) {
@@ -342,6 +363,13 @@ virDomainBackupDiskDefFormat(virBufferPtr buf,
 if (disk->backup == VIR_TRISTATE_BOOL_YES) {
 virBufferAsprintf(, " type='%s'", 
virStorageTypeToString(disk->store->type));

+if (disk->backupmode != VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_DEFAULT) {
+virBufferAsprintf(, " backupmode='%s'",
+  

Re: [libvirt PATCH 28/31] tests: commandhelper: change how we detect if running as daemon

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

The old code works correctly with make and running directly from shell
but it failed with Meson test suite where session ID and process group
are the same in both cases.

What changes in both cases is parent process ID so use that instead of
session ID.

Signed-off-by: Pavel Hrdina 
---
tests/commandhelper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


[PATCH 22/24] qemu: conf: Add configuration of TLS environment for NBD transport of pull-backups

2020-07-02 Thread Peter Krempa
TLS is required to transport backed-up data securely when using
pull-mode backups.

Signed-off-by: Peter Krempa 
---
 docs/formatbackup.rst  |  4 
 src/qemu/libvirtd_qemu.aug |  5 
 src/qemu/qemu.conf | 37 ++
 src/qemu/qemu_conf.c   | 17 ++
 src/qemu/qemu_conf.h   |  5 
 src/qemu/test_libvirtd_qemu.aug.in |  3 +++
 6 files changed, 71 insertions(+)

diff --git a/docs/formatbackup.rst b/docs/formatbackup.rst
index e5b6fc6eb0..142b8250d2 100644
--- a/docs/formatbackup.rst
+++ b/docs/formatbackup.rst
@@ -42,6 +42,10 @@ were supplied). The following child elements and attributes 
are supported:
necessary to set up an NBD server that exposes the content of each disk at
the time the backup is started.

+   Note that for the QEMU hypervisor the TLS environment in controlled using
+   ``backup_tls_x509_cert_dir``, ``backup_tls_x509_verify``, and
+   ``backup_tls_x509_secret_uuid`` properties in ``/etc/libvirt/qemu.conf``.
+
 ``disks``
An optional listing of instructions for disks participating in the backup 
(if
omitted, all disks participate and libvirt attempts to generate filenames by
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index c19a086c38..abbac549f2 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -59,6 +59,10 @@ module Libvirtd_qemu =
  | bool_entry "migrate_tls_x509_verify"
  | str_entry "migrate_tls_x509_secret_uuid"

+   let backup_entry = str_entry "backup_tls_x509_cert_dir"
+ | bool_entry "backup_tls_x509_verify"
+ | str_entry "backup_tls_x509_secret_uuid"
+
let vxhs_entry = bool_entry "vxhs_tls"
  | str_entry "vxhs_tls_x509_cert_dir"
  | str_entry "vxhs_tls_x509_secret_uuid"
@@ -146,6 +150,7 @@ module Libvirtd_qemu =
  | spice_entry
  | chardev_entry
  | migrate_entry
+ | backup_entry
  | nogfx_entry
  | remote_display_entry
  | security_entry
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index ab403c21ac..a96bedb114 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -395,6 +395,43 @@
 #migrate_tls_x509_secret_uuid = "----"


+# In order to override the default TLS certificate location for backup NBD
+# server certificates, supply a valid path to the certificate directory. If the
+# provided path does not exist, libvirtd will fail to start. If the path is
+# not provided, but TLS-encrypted backup is requested, then the
+# default_tls_x509_cert_dir path will be used.
+#
+#backup_tls_x509_cert_dir = "/etc/pki/libvirt-backup"
+
+
+# The default TLS configuration only uses certificates for the server
+# allowing the client to verify the server's identity and establish
+# an encrypted channel.
+#
+# It is possible to use x509 certificates for authentication too, by
+# issuing an x509 certificate to every client who needs to connect.
+#
+# Enabling this option will reject any client that does not have a
+# ca-cert.pem certificate signed by the CA in the backup_tls_x509_cert_dir
+# (or default_tls_x509_cert_dir) as well as the corresponding client-*.pem
+# files described in default_tls_x509_cert_dir.
+#
+# If this option is not supplied, it will be set to the value of
+# "default_tls_x509_verify".
+#
+#backup_tls_x509_verify = 1
+
+
+# Uncomment and use the following option to override the default secret
+# UUID provided in the default_tls_x509_secret_uuid parameter.
+#
+# NB This default all-zeros UUID will not work. Replace it with the
+# output from the UUID for the TLS secret from a 'virsh secret-list'
+# command and then uncomment the entry
+#
+#backup_tls_x509_secret_uuid = "----"
+
+
 # By default, if no graphical front end is configured, libvirt will disable
 # QEMU audio output since directly talking to alsa/pulseaudio may not work
 # with various security settings. If you know what you're doing, enable
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 6e673e8f62..30d7c61cf9 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -347,6 +347,9 @@ static void virQEMUDriverConfigDispose(void *obj)
 VIR_FREE(cfg->migrateTLSx509certdir);
 VIR_FREE(cfg->migrateTLSx509secretUUID);

+VIR_FREE(cfg->backupTLSx509certdir);
+VIR_FREE(cfg->backupTLSx509secretUUID);
+
 while (cfg->nhugetlbfs) {
 cfg->nhugetlbfs--;
 VIR_FREE(cfg->hugetlbfs[cfg->nhugetlbfs].mnt_dir);
@@ -511,6 +514,9 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
 GET_CONFIG_TLS_CERTINFO_COMMON(migrate);
 GET_CONFIG_TLS_CERTINFO_SERVER(migrate);

+GET_CONFIG_TLS_CERTINFO_COMMON(backup);
+GET_CONFIG_TLS_CERTINFO_SERVER(backup);
+
 GET_CONFIG_TLS_CERTINFO_COMMON(vxhs);

 

[PATCH 20/24] testCompareBackupXML: Add infrastructure for testing internal fields

2020-07-02 Thread Peter Krempa
There are few internal fields of the backup XML. Propagate the
'internal' flag so that the test can verify the XML infrastructure.

Signed-off-by: Peter Krempa 
---
 tests/genericxml2xmltest.c | 30 --
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 74e520522b..cf07f9bb79 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -45,16 +45,27 @@ testCompareXMLToXMLHelper(const void *data)
 }


+struct testCompareBackupXMLData {
+const char *testname;
+bool internal;
+};
+
+
 static int
-testCompareBackupXML(const void *data)
+testCompareBackupXML(const void *opaque)
 {
-const char *testname = data;
+const struct testCompareBackupXMLData *data = opaque;
+const char *testname = data->testname;
 g_autofree char *xml_in = NULL;
 g_autofree char *file_in = NULL;
 g_autofree char *file_out = NULL;
 g_autoptr(virDomainBackupDef) backup = NULL;
 g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 g_autofree char *actual = NULL;
+unsigned int parseFlags = 0;
+
+if (data->internal)
+parseFlags |= VIR_DOMAIN_BACKUP_PARSE_INTERNAL;

 file_in = g_strdup_printf("%s/domainbackupxml2xmlin/%s.xml",
   abs_srcdir, testname);
@@ -64,12 +75,12 @@ testCompareBackupXML(const void *data)
 if (virFileReadAll(file_in, 1024 * 64, _in) < 0)
 return -1;

-if (!(backup = virDomainBackupDefParseString(xml_in, xmlopt, 0))) {
+if (!(backup = virDomainBackupDefParseString(xml_in, xmlopt, parseFlags))) 
{
 VIR_TEST_VERBOSE("failed to parse backup def '%s'", file_in);
 return -1;
 }

-if (virDomainBackupDefFormat(, backup, false) < 0) {
+if (virDomainBackupDefFormat(, backup, data->internal) < 0) {
 VIR_TEST_VERBOSE("failed to format backup def '%s'", file_in);
 return -1;
 }
@@ -185,9 +196,16 @@ mymain(void)

 DO_TEST_DIFFERENT("cputune");

+#define DO_TEST_BACKUP_FULL(name, intrnl) \
+do { \
+const struct testCompareBackupXMLData data = { .testname = name, \
+   .internal = intrnl }; \
+if (virTestRun("QEMU BACKUP XML-2-XML " name, testCompareBackupXML, 
) < 0) \
+  ret = -1; \
+} while (false)
+
 #define DO_TEST_BACKUP(name) \
-if (virTestRun("QEMU BACKUP XML-2-XML " name, testCompareBackupXML, name) 
< 0) \
-ret = -1;
+DO_TEST_BACKUP_FULL(name, false)

 DO_TEST_BACKUP("empty");
 DO_TEST_BACKUP("backup-pull");
-- 
2.26.2



[PATCH 16/24] docs: checkpoint: Convert XML documentation to RST

2020-07-02 Thread Peter Krempa
Switch to the new format for easier extension.

Signed-off-by: Peter Krempa 
---
 docs/formatcheckpoint.html.in | 198 --
 docs/formatcheckpoint.rst | 162 
 2 files changed, 162 insertions(+), 198 deletions(-)
 delete mode 100644 docs/formatcheckpoint.html.in
 create mode 100644 docs/formatcheckpoint.rst

diff --git a/docs/formatcheckpoint.html.in b/docs/formatcheckpoint.html.in
deleted file mode 100644
index ee56194523..00
--- a/docs/formatcheckpoint.html.in
+++ /dev/null
@@ -1,198 +0,0 @@
-
-
-http://www.w3.org/1999/xhtml;>
-  
-Checkpoint XML format
-
-
-
-Checkpoint XML
-
-
-  One method of capturing domain disk backups is via the use of
-  incremental backups. Right now, incremental backups are only
-  supported for the QEMU hypervisor when using qcow2 disks at the
-  active layer; if other disk formats are in use, capturing disk
-  backups requires different libvirt APIs
-  (see domain state
-  capture for a comparison between APIs).
-
-
-  Libvirt is able to facilitate incremental backups by tracking
-  disk checkpoints, which are points in time against which it is
-  easy to compute which portion of the disk has changed. Given a
-  full backup (a backup created from the creation of the disk to a
-  given point in time), coupled with the creation of a disk
-  checkpoint at that time, and an incremental backup (a backup
-  created from just the dirty portion of the disk between the
-  first checkpoint and the second backup operation), it is
-  possible to do an offline reconstruction of the state of the
-  disk at the time of the second backup without having to copy as
-  much data as a second full backup would require. Most disk
-  checkpoints are created in conjunction with a backup
-  via virDomainBackupBegin(), although a future API
-  addition of virDomainSnapshotCreateXML2() will also
-  make this possible when creating external snapshots; however,
-  libvirt also exposes enough support to create disk checkpoints
-  independently from a backup operation
-  via virDomainCheckpointCreateXML() since
-  5.6.0.  Likewise, the creation of checkpoints when
-  external snapshots exist is currently forbidden, although future
-  work will make it possible to integrate these two concepts.
-
-
-  Attributes of libvirt checkpoints are stored as child elements
-  of the domaincheckpoint element. At checkpoint
-  creation time, normally only
-  the name, description,
-  and disks elements are settable. The rest of the
-  fields are ignored on creation and will be filled in by libvirt
-  in for informational purposes
-  by virDomainCheckpointGetXMLDesc(). However, when
-  redefining a checkpoint, with
-  the VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE flag
-  of virDomainCheckpointCreateXML(), all of the XML
-  fields described here are relevant on input, even the fields
-  that are normally described as readonly for output.
-
-
-  The top-level domaincheckpoint element may contain
-  the following elements:
-
-
-  name
-  The optional name for this checkpoint. If the name is
-omitted, libvirt will create a name based on the time of the
-creation.
-  
-  description
-  An optional human-readable description of the checkpoint.
-If the description is omitted when initially creating the
-checkpoint, then this field will be empty.
-  
-  disks
-  On input, this is an optional listing of specific
-instructions for disk checkpoints; it is needed when making a
-checkpoint on only a subset of the disks associated with a
-domain. In particular, since QEMU checkpoints require qcow2
-disks, this element may be needed on input for excluding guest
-disks that are not in qcow2 format. If the entire element was
-omitted on input, then all disks participate in the
-checkpoint, otherwise, only the disks explicitly listed which
-do not also use checkpoint='no' will
-participate. On output, this is the checkpoint state of each
-of the domain's disks.
-
-  disk
-  This sub-element describes the checkpoint properties of
-a specific disk with the following attributes:
-
-  name
-  A mandatory attribute which must match either
-the target dev='name'/ or an
-unambiguous source file='name'/
-of one of
-the disk
-devices specified for the domain at the time of
-the checkpoint.
-  checkpoint
-  An optional attribute; possible values
-are no when the disk does not participate
-in this checkpoint; 

[PATCH 01/24] qemu: domain: Introduce helper for always fetching virStorageSource private data

2020-07-02 Thread Peter Krempa
Add a helper which will always return the storage source private data
even if it was not allocated before.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_domain.c | 10 ++
 src/qemu/qemu_domain.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c5b8d91f9a..74392760b8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -570,6 +570,16 @@ qemuDomainStorageSourcePrivateDispose(void *obj)
 }


+qemuDomainStorageSourcePrivatePtr
+qemuDomainStorageSourcePrivateFetch(virStorageSourcePtr src)
+{
+if (!src->privateData)
+src->privateData = qemuDomainStorageSourcePrivateNew();
+
+return QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
+}
+
+
 static virClassPtr qemuDomainVcpuPrivateClass;
 static void qemuDomainVcpuPrivateDispose(void *obj);

diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 15ffd87cb5..ae3c3bf1da 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -320,6 +320,8 @@ struct _qemuDomainStorageSourcePrivate {
 };

 virObjectPtr qemuDomainStorageSourcePrivateNew(void);
+qemuDomainStorageSourcePrivatePtr
+qemuDomainStorageSourcePrivateFetch(virStorageSourcePtr src);

 typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
 typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
-- 
2.26.2



[PATCH 13/24] docs: backup: Convert XML documentation to RST

2020-07-02 Thread Peter Krempa
Switch to the new format for easier extension.

Signed-off-by: Peter Krempa 
---
 docs/formatbackup.html.in | 191 --
 docs/formatbackup.rst | 149 +
 2 files changed, 149 insertions(+), 191 deletions(-)
 delete mode 100644 docs/formatbackup.html.in
 create mode 100644 docs/formatbackup.rst

diff --git a/docs/formatbackup.html.in b/docs/formatbackup.html.in
deleted file mode 100644
index 9e69d8f7d3..00
--- a/docs/formatbackup.html.in
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-http://www.w3.org/1999/xhtml;>
-  
-Backup XML format
-
-
-
-Backup XML
-
-
-  Creating a backup, whether full or incremental, is done
-  via virDomainBackupBegin(), which takes an XML
-  description of the actions to perform, as well as an optional
-  second XML document describing a
-  checkpoint to create at the same point in time. See
-  also a comparison between
-  the various state capture APIs.
-
-
-  There are two general modes for backups: a push mode (where the
-  hypervisor writes out the data to the destination file, which
-  may be local or remote), and a pull mode (where the hypervisor
-  creates an NBD server that a third-party client can then read as
-  needed, and which requires the use of temporary storage,
-  typically local, until the backup is complete).
-
-
-  The instructions for beginning a backup job are provided as
-  attributes and elements of the
-  top-level domainbackup element. This element
-  includes an optional attribute mode which can be
-  either "push" or "pull" (default
-  push). virDomainBackupGetXMLDesc() can be used to
-  see the actual values selected for elements omitted during
-  creation (for example, learning which port the NBD server is
-  using in the pull model or what file names libvirt generated
-  when none were supplied). The following child elements and attributes
-  are supported:
-
-
-  incremental
-  An optional element giving the name of an existing
-checkpoint of the domain, which will be used to make this
-backup an incremental one. In the push model, only changes
-since the named checkpoint are written to the destination. In
-the pull model, the NBD server uses the
-NBD_OPT_SET_META_CONTEXT extension to advertise to the client
-which portions of the export contain changes since the named
-checkpoint. If omitted, a full backup is performed.
-  
-  server
-  Present only for a pull mode backup. Contains the same
-attributes as
-the protocol
-element of a disk attached via NBD in the domain (such as
-transport, socket, name, port, or tls), necessary to set up an
-NBD server that exposes the content of each disk at the time
-the backup is started.
-  
-  disks
-  An optional listing of instructions for disks participating
-in the backup (if omitted, all disks participate and libvirt
-attempts to generate filenames by appending the current
-timestamp as a suffix). If the entire element was omitted on
-input, then all disks participate in the backup, otherwise,
-only the disks explicitly listed which do not also
-use backup='no' will participate. On output, this
-is the state of each of the domain's disk in relation to the
-backup operation.
-
-  disk
-  This sub-element describes the backup properties of a
-specific disk, with the following attributes and child
-elements:
-
-  name
-  A mandatory attribute which must match
-the target dev='name'/
-of one of
-the disk
-devices specified for the domain at the time of
-the checkpoint.
-  backup
-  Setting this attribute to yes(default) specifies
-that the disk should take part in the backup and using
-no excludes the disk from the backup.
-  exportname
-  Allows modification of the NBD export name for the given 
disk.
-By default equal to disk target.
-Valid only for pull mode backups.
-  exportbitmap
-  Allows modification of the name of the bitmap describing 
dirty
-blocks for an incremental backup exported via NBD export name
-for the given disk.
-Valid only for pull mode backups.
-  type
-  A mandatory attribute to describe the type of the
-disk, except when backup='no' is
-used. Valid values include file, or
-block.
-Similar to a disk declaration for a domain, the choice of type
-

[PATCH 12/24] conf: backup: Don't explicitly forbid backup of read-only disk

2020-07-02 Thread Peter Krempa
Users may want to use this to create a full backup or even incremental
if the checkpoints are pre existing. We still will not allow to create a
checkpoint on a read-only disk as that makes no sense.

https://bugzilla.redhat.com/show_bug.cgi?id=1840053

Signed-off-by: Peter Krempa 
---
 src/conf/backup_conf.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 92106d8aaa..e9eea5af75 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -411,13 +411,6 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDefPtr 
disk,
_("disk '%s' has no media"), disk->name);
 return -1;
 }
-} else if (src->readonly) {
-if (disk->store) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("backup of readonly disk '%s' makes no sense"),
-   disk->name);
-return -1;
-}
 } else if (!disk->store) {
 if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_FILE) {
 if (!(disk->store = virStorageSourceNew()))
-- 
2.26.2



[PATCH 08/24] qemu block: Add internals for handling 'secret' corresponding to TLS key

2020-07-02 Thread Peter Krempa
Add infrastructure for hot- and cold-plug of the secret object holding
decryption key for the TLS key.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_block.c   | 12 
 src/qemu/qemu_block.h   |  2 ++
 src/qemu/qemu_command.c | 11 ++-
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index b00694c96f..36fc6784de 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1542,7 +1542,9 @@ 
qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr data)
 virJSONValueFree(data->httpcookiesecretProps);
 virJSONValueFree(data->encryptsecretProps);
 virJSONValueFree(data->tlsProps);
+virJSONValueFree(data->tlsKeySecretProps);
 VIR_FREE(data->tlsAlias);
+VIR_FREE(data->tlsKeySecretAlias);
 VIR_FREE(data->authsecretAlias);
 VIR_FREE(data->encryptsecretAlias);
 VIR_FREE(data->httpcookiesecretAlias);
@@ -1617,6 +1619,11 @@ 
qemuBlockStorageSourceAttachApplyStorageDeps(qemuMonitorPtr mon,
  >httpcookiesecretAlias) < 0)
 return -1;

+if (data->tlsKeySecretProps &&
+qemuMonitorAddObject(mon, >tlsKeySecretProps,
+ >tlsKeySecretAlias) < 0)
+return -1;
+
 if (data->tlsProps &&
 qemuMonitorAddObject(mon, >tlsProps, >tlsAlias) < 0)
 return -1;
@@ -1766,6 +1773,8 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr mon,
 if (data->tlsAlias)
 ignore_value(qemuMonitorDelObject(mon, data->tlsAlias, false));

+if (data->tlsKeySecretAlias)
+ignore_value(qemuMonitorDelObject(mon, data->tlsKeySecretAlias, 
false));

 virErrorRestore(_err);
 }
@@ -1821,6 +1830,9 @@ qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr 
src,

 if (srcpriv->httpcookie)
 data->httpcookiesecretAlias = 
g_strdup(srcpriv->httpcookie->s.aes.alias);
+
+if (srcpriv->tlsKeySecret)
+data->tlsKeySecretAlias = 
g_strdup(srcpriv->tlsKeySecret->s.aes.alias);
 }

 return g_steal_pointer();
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 24b87e79db..b1bdb39613 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -105,6 +105,8 @@ struct qemuBlockStorageSourceAttachData {

 virJSONValuePtr tlsProps;
 char *tlsAlias;
+virJSONValuePtr tlsKeySecretProps;
+char *tlsKeySecretAlias;
 };


diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6e7fd59561..0c4c77cf8c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2047,6 +2047,7 @@ 
qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
 qemuBuildObjectCommandline(cmd, data->authsecretProps) < 0 ||
 qemuBuildObjectCommandline(cmd, data->encryptsecretProps) < 0 ||
 qemuBuildObjectCommandline(cmd, data->httpcookiesecretProps) < 0 ||
+qemuBuildObjectCommandline(cmd, data->tlsKeySecretProps) < 0 ||
 qemuBuildObjectCommandline(cmd, data->tlsProps) < 0)
 return -1;

@@ -10161,6 +10162,7 @@ 
qemuBuildStorageSourceAttachPrepareCommon(virStorageSourcePtr src,
   virQEMUCapsPtr qemuCaps)
 {
 qemuDomainStorageSourcePrivatePtr srcpriv = 
QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
+const char *tlsKeySecretAlias = NULL;

 if (src->pr &&
 !virStoragePRDefIsManaged(src->pr) &&
@@ -10180,11 +10182,18 @@ 
qemuBuildStorageSourceAttachPrepareCommon(virStorageSourcePtr src,
 if (srcpriv->httpcookie &&
 qemuBuildSecretInfoProps(srcpriv->httpcookie, 
>httpcookiesecretProps) < 0)
 return -1;
+
+if (srcpriv->tlsKeySecret) {
+if (qemuBuildSecretInfoProps(srcpriv->tlsKeySecret, 
>tlsKeySecretProps) < 0)
+return -1;
+
+tlsKeySecretAlias = srcpriv->tlsKeySecret->s.aes.alias;
+}
 }

 if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&
 qemuBuildTLSx509BackendProps(src->tlsCertdir, false, true, 
src->tlsAlias,
- NULL, qemuCaps, >tlsProps) < 0)
+ tlsKeySecretAlias, qemuCaps, 
>tlsProps) < 0)
 return -1;

 return 0;
-- 
2.26.2



[PATCH 05/24] virQEMUDriverConfigLoadSpecificTLSEntry: Move fetching of 'chardev_tls' above macro

2020-07-02 Thread Peter Krempa
Move the extraction of the config value so that it makes more sense
after upcoming refactors.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 33b3989268..2cbff1348a 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -483,6 +483,8 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
 return -1;
 if (virConfGetValueString(conf, "nbd_tls_x509_cert_dir", 
>nbdTLSx509certdir) < 0)
 return -1;
+if (virConfGetValueBool(conf, "chardev_tls", >chardevTLS) < 0)
+return -1;

 #define GET_CONFIG_TLS_CERTINFO(val) \
 do { \
@@ -500,8 +502,6 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
 return -1; \
 } while (0)

-if (virConfGetValueBool(conf, "chardev_tls", >chardevTLS) < 0)
-return -1;
 GET_CONFIG_TLS_CERTINFO(chardev);

 GET_CONFIG_TLS_CERTINFO(migrate);
-- 
2.26.2



[PATCH 04/24] qemu: conf: Move 'nbd' and 'vxhs' tls config variables together with rest of tls setup

2020-07-02 Thread Peter Krempa
Signed-off-by: Peter Krempa 
---
 src/qemu/libvirtd_qemu.aug | 12 ++--
 src/qemu/qemu_conf.h   | 12 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 404498b611..7a6a33c77c 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -59,6 +59,12 @@ module Libvirtd_qemu =
  | bool_entry "migrate_tls_x509_verify"
  | str_entry "migrate_tls_x509_secret_uuid"

+   let vxhs_entry = bool_entry "vxhs_tls"
+ | str_entry "vxhs_tls_x509_cert_dir"
+
+   let nbd_entry = bool_entry "nbd_tls"
+ | str_entry "nbd_tls_x509_cert_dir"
+
let nogfx_entry = bool_entry "nographics_allow_host_audio"

let remote_display_entry = int_entry "remote_display_port_min"
@@ -121,12 +127,6 @@ module Libvirtd_qemu =

let memory_entry = str_entry "memory_backing_dir"

-   let vxhs_entry = bool_entry "vxhs_tls"
- | str_entry "vxhs_tls_x509_cert_dir"
-
-   let nbd_entry = bool_entry "nbd_tls"
-| str_entry "nbd_tls_x509_cert_dir"
-
let swtpm_entry = str_entry "swtpm_user"
 | str_entry "swtpm_group"

diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index b9ef4551a3..4f54c136db 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -144,6 +144,12 @@ struct _virQEMUDriverConfig {
 bool migrateTLSx509verifyPresent;
 char *migrateTLSx509secretUUID;

+bool vxhsTLS;
+char *vxhsTLSx509certdir;
+
+bool nbdTLS;
+char *nbdTLSx509certdir;
+
 unsigned int remotePortMin;
 unsigned int remotePortMax;

@@ -208,12 +214,6 @@ struct _virQEMUDriverConfig {

 char *memoryBackingDir;

-bool vxhsTLS;
-char *vxhsTLSx509certdir;
-
-bool nbdTLS;
-char *nbdTLSx509certdir;
-
 uid_t swtpm_user;
 gid_t swtpm_group;

-- 
2.26.2



[PATCH 19/24] checkpoint: Mention that VIR_DOMAIN_CHECKPOINT_XML_SIZE is expensive and stale

2020-07-02 Thread Peter Krempa
Data is valid only when queried as guest writes may increase the backup
size.

Signed-off-by: Peter Krempa 
---
 docs/formatcheckpoint.rst   | 4 
 src/libvirt-domain-checkpoint.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/docs/formatcheckpoint.rst b/docs/formatcheckpoint.rst
index e45745390a..f159f2a7a3 100644
--- a/docs/formatcheckpoint.rst
+++ b/docs/formatcheckpoint.rst
@@ -86,6 +86,10 @@ The top-level ``domaincheckpoint`` element may contain the 
following elements:
  perform a dynamic query of the estimated size in bytes of the changes
  made since the checkpoint was created.

+ Note that updating the backup ``size`` may be expensive and
+ the actual required size may increase if the guest OS is actively
+ writing to the disk.
+
 ``creationTime``
A readonly representation of the time this checkpoint was created. The time
is specified in seconds since the Epoch, UTC (i.e. Unix time).
diff --git a/src/libvirt-domain-checkpoint.c b/src/libvirt-domain-checkpoint.c
index 50627c486c..8a7b55dcd2 100644
--- a/src/libvirt-domain-checkpoint.c
+++ b/src/libvirt-domain-checkpoint.c
@@ -191,7 +191,8 @@ virDomainCheckpointCreateXML(virDomainPtr domain,
  * VIR_DOMAIN_CHECKPOINT_XML_SIZE, each  listing adds an additional
  * attribute that shows an estimate of the current size in bytes that
  * have been dirtied between the time the checkpoint was created and the
- * current point in time.
+ * current point in time. Note that updating the size may be expensive and
+ * data will be inaccurate once guest OS writes to the disk.
  *
  * Returns a 0 terminated UTF-8 encoded XML instance or NULL in case
  * of error. The caller must free() the returned value.
-- 
2.26.2



[PATCH 24/24] qemu: backup: Setup TLS environment for pull-mode backup jobs

2020-07-02 Thread Peter Krempa
Use the configured TLS env to setup encryption of the TLS transport.

https://bugzilla.redhat.com/show_bug.cgi?id=1822631

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_backup.c | 80 +++---
 1 file changed, 76 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index 8dc9d2504d..b711f8f623 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -18,6 +18,7 @@

 #include 

+#include "qemu_alias.h"
 #include "qemu_block.h"
 #include "qemu_conf.h"
 #include "qemu_capabilities.h"
@@ -642,6 +643,50 @@ qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
 }


+#define QEMU_BACKUP_TLS_ALIAS_BASE "libvirt_backup"
+
+static int
+qemuBackupBeginPrepareTLS(virDomainObjPtr vm,
+  virQEMUDriverConfigPtr cfg,
+  virDomainBackupDefPtr def,
+  virJSONValuePtr *tlsProps,
+  virJSONValuePtr *tlsSecretProps)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+g_autofree char *tlsObjAlias = 
qemuAliasTLSObjFromSrcAlias(QEMU_BACKUP_TLS_ALIAS_BASE);
+g_autoptr(qemuDomainSecretInfo) secinfo = NULL;
+const char *tlsKeySecretAlias = NULL;
+
+if (def->tls != VIR_TRISTATE_BOOL_YES)
+return 0;
+
+if (!cfg->backupTLSx509certdir) {
+virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+   _("backup TLS directory not configured"));
+return -1;
+}
+
+if (cfg->backupTLSx509secretUUID) {
+if (!(secinfo = qemuDomainSecretInfoTLSNew(priv, tlsObjAlias,
+   
cfg->backupTLSx509secretUUID)))
+return -1;
+
+if (qemuBuildSecretInfoProps(secinfo, tlsSecretProps) < 0)
+return -1;
+
+tlsKeySecretAlias = secinfo->s.aes.alias;
+}
+
+if (qemuBuildTLSx509BackendProps(cfg->backupTLSx509certdir, true,
+ cfg->backupTLSx509verify, tlsObjAlias,
+ tlsKeySecretAlias, priv->qemuCaps,
+ tlsProps) < 0)
+return -1;
+
+return 0;
+}
+
+
 int
 qemuBackupBegin(virDomainObjPtr vm,
 const char *backupXML,
@@ -656,6 +701,10 @@ qemuBackupBegin(virDomainObjPtr vm,
 virDomainMomentObjPtr chk = NULL;
 g_autoptr(virDomainCheckpointDef) chkdef = NULL;
 g_autoptr(virJSONValue) actions = NULL;
+g_autoptr(virJSONValue) tlsProps = NULL;
+g_autofree char *tlsAlias = NULL;
+g_autoptr(virJSONValue) tlsSecretProps = NULL;
+g_autofree char *tlsSecretAlias = NULL;
 struct qemuBackupDiskData *dd = NULL;
 ssize_t ndd = 0;
 g_autoptr(virHashTable) blockNamedNodeData = NULL;
@@ -719,6 +768,9 @@ qemuBackupBegin(virDomainObjPtr vm,
 if (qemuBackupPrepare(def) < 0)
 goto endjob;

+if (qemuBackupBeginPrepareTLS(vm, cfg, def, , ) < 
0)
+goto endjob;
+
 if (virDomainBackupAlignDisks(def, vm->def, suffix) < 0)
 goto endjob;

@@ -755,8 +807,16 @@ qemuBackupBegin(virDomainObjPtr vm,

 /* TODO: TLS is a must-have for the modern age */
 if (pull) {
-if ((rc = qemuMonitorNBDServerStart(priv->mon, priv->backup->server, 
NULL)) == 0)
-nbd_running = true;
+if (tlsSecretProps)
+rc = qemuMonitorAddObject(priv->mon, , 
);
+
+if (rc == 0 && tlsProps)
+rc = qemuMonitorAddObject(priv->mon, , );
+
+if (rc == 0) {
+if ((rc = qemuMonitorNBDServerStart(priv->mon, 
priv->backup->server, tlsAlias)) == 0)
+nbd_running = true;
+}
 }

 if (rc == 0)
@@ -789,6 +849,9 @@ qemuBackupBegin(virDomainObjPtr vm,
 }
 }

+priv->backup->tlsAlias = g_steal_pointer();
+priv->backup->tlsSecretAlias = g_steal_pointer();
+
 ret = 0;

  endjob:
@@ -797,9 +860,14 @@ qemuBackupBegin(virDomainObjPtr vm,
 /* if 'chk' is non-NULL here it's a failure and it must be rolled back */
 qemuCheckpointRollbackMetadata(vm, chk);

-if (!job_started && nbd_running &&
+if (!job_started && (nbd_running || tlsAlias || tlsSecretAlias) &&
 qemuDomainObjEnterMonitorAsync(priv->driver, vm, 
QEMU_ASYNC_JOB_BACKUP) == 0) {
-ignore_value(qemuMonitorNBDServerStop(priv->mon));
+if (nbd_running)
+ignore_value(qemuMonitorNBDServerStop(priv->mon));
+if (tlsAlias)
+ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias, false));
+if (tlsSecretAlias)
+ignore_value(qemuMonitorDelObject(priv->mon, tlsSecretAlias, 
false));
 ignore_value(qemuDomainObjExitMonitor(priv->driver, vm));
 }

@@ -862,6 +930,10 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
 if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
 return;
 ignore_value(qemuMonitorNBDServerStop(priv->mon));
+if (backup->tlsAlias)
+

[PATCH 23/24] conf: backup: Add 'tls' attribute for 'server' element

2020-07-02 Thread Peter Krempa
Allow enabling TLS for the NBD server used to do pull-mode backups. Note
that documentation already mentions 'tls', so this just implements the
schema and XML bits.

Signed-off-by: Peter Krempa 
---
 docs/schemas/domainbackup.rng   |  9 -
 src/conf/backup_conf.c  | 17 +
 src/conf/backup_conf.h  |  1 +
 .../backup-pull-encrypted.xml   |  2 +-
 .../backup-pull-internal-invalid.xml|  2 +-
 .../backup-pull-encrypted.xml   |  2 +-
 6 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng
index 650f5cd4c3..c0ca3c3038 100644
--- a/docs/schemas/domainbackup.rng
+++ b/docs/schemas/domainbackup.rng
@@ -51,6 +51,14 @@
 
 
   
+
+  
+
+  yes
+  no
+
+  
+
 
   
 
@@ -69,7 +77,6 @@
 
   
 
-
   
   
 
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 74f6e4b020..59d7e1dfaf 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -260,6 +260,8 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt,
 def->incremental = virXPathString("string(./incremental)", ctxt);

 if ((node = virXPathNode("./server", ctxt))) {
+g_autofree char *tls = NULL;
+
 if (def->type != VIR_DOMAIN_BACKUP_TYPE_PULL) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("use of  requires pull mode backup"));
@@ -284,6 +286,19 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt,
def->server->socket);
 return NULL;
 }
+
+if ((tls = virXMLPropString(node, "tls"))) {
+int tmp;
+
+if ((tmp = virTristateBoolTypeFromString(tls)) <= 0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _("unknown value '%s' of 'tls' attribute"),\
+   tls);
+return NULL;
+}
+
+def->tls = tmp;
+}
 }

 if ((n = virXPathNodeSet("./disks/*", ctxt, )) < 0)
@@ -445,6 +460,8 @@ virDomainBackupDefFormat(virBufferPtr buf,
 if (def->server) {
 virBufferAsprintf(, " transport='%s'",
   
virStorageNetHostTransportTypeToString(def->server->transport));
+if (def->tls != VIR_TRISTATE_BOOL_ABSENT)
+virBufferAsprintf(, " tls='%s'", 
virTristateBoolTypeToString(def->tls));
 virBufferEscapeString(, " name='%s'", def->server->name);
 if (def->server->port)
 virBufferAsprintf(, " port='%u'", def->server->port);
diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h
index a1d1e453c1..bda2bdcfe4 100644
--- a/src/conf/backup_conf.h
+++ b/src/conf/backup_conf.h
@@ -81,6 +81,7 @@ struct _virDomainBackupDef {
 int type; /* virDomainBackupType */
 char *incremental;
 virStorageNetHostDefPtr server; /* only when type == PULL */
+virTristateBool tls; /* use TLS for NBD */

 size_t ndisks; /* should not exceed dom->ndisks */
 virDomainBackupDiskDef *disks;
diff --git a/tests/domainbackupxml2xmlin/backup-pull-encrypted.xml 
b/tests/domainbackupxml2xmlin/backup-pull-encrypted.xml
index 1469189a37..48232aa0fe 100644
--- a/tests/domainbackupxml2xmlin/backup-pull-encrypted.xml
+++ b/tests/domainbackupxml2xmlin/backup-pull-encrypted.xml
@@ -1,6 +1,6 @@
 
   1525889631
-  
+  
   
 
   
diff --git a/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml 
b/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
index 261dec0eea..ba8f7ca3ab 100644
--- a/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
+++ b/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
@@ -1,6 +1,6 @@
 
   1525889631
-  
+  
   
 
   
diff --git a/tests/domainbackupxml2xmlout/backup-pull-encrypted.xml 
b/tests/domainbackupxml2xmlout/backup-pull-encrypted.xml
index 81519bfcb5..ea9dcf72b9 100644
--- a/tests/domainbackupxml2xmlout/backup-pull-encrypted.xml
+++ b/tests/domainbackupxml2xmlout/backup-pull-encrypted.xml
@@ -1,6 +1,6 @@
 
   1525889631
-  
+  
   
 
   
-- 
2.26.2



[PATCH 02/24] qemuDomainDiskHasEncryptionSecret: unexport

2020-07-02 Thread Peter Krempa
Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_domain.c | 2 +-
 src/qemu/qemu_domain.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 74392760b8..697ddab727 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1102,7 +1102,7 @@ qemuDomainStorageSourceHasAuth(virStorageSourcePtr src)
 }


-bool
+static bool
 qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
 {
 if (!virStorageSourceIsEmpty(src) && src->encryption &&
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index ae3c3bf1da..1ddac52092 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -837,9 +837,6 @@ void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
 bool qemuDomainStorageSourceHasAuth(virStorageSourcePtr src)
 ATTRIBUTE_NONNULL(1);

-bool qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
-ATTRIBUTE_NONNULL(1);
-
 qemuDomainSecretInfoPtr
 qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
const char *srcAlias,
-- 
2.26.2



[PATCH 21/24] conf: backup: Store 'tlsAlias' and 'tlsSecretAlias' as internals of a backup

2020-07-02 Thread Peter Krempa
Add fields for storing the aliases necessary to clean up the TLS env for
a backup job after it finishes.

Signed-off-by: Peter Krempa 
---
 src/conf/backup_conf.c| 42 +++
 src/conf/backup_conf.h|  5 +++
 .../backup-pull-internal-invalid.xml  | 36 
 .../backup-pull-internal-invalid.xml  |  1 +
 tests/genericxml2xmltest.c|  2 +
 5 files changed, 86 insertions(+)
 create mode 100644 tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
 create mode 12 
tests/domainbackupxml2xmlout/backup-pull-internal-invalid.xml

diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 4f28073ab2..74f6e4b020 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -86,6 +86,10 @@ virDomainBackupDefFree(virDomainBackupDefPtr def)
 }

 g_free(def->disks);
+
+g_free(def->tlsAlias);
+g_free(def->tlsSecretAlias);
+
 g_free(def);
 }

@@ -213,6 +217,19 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
 }


+static void
+virDomainBackupDefParsePrivate(virDomainBackupDefPtr def,
+   xmlXPathContextPtr ctxt,
+   unsigned int flags)
+{
+if (!(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL))
+return;
+
+def->tlsSecretAlias = 
virXPathString("string(./privateData/objects/secret[@type='tlskey']/@alias)", 
ctxt);
+def->tlsAlias = 
virXPathString("string(./privateData/objects/TLSx509/@alias)", ctxt);
+}
+
+
 static virDomainBackupDefPtr
 virDomainBackupDefParse(xmlXPathContextPtr ctxt,
 virDomainXMLOptionPtr xmlopt,
@@ -282,6 +299,8 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt,
 return NULL;
 }

+virDomainBackupDefParsePrivate(def, ctxt, flags);
+
 return g_steal_pointer();
 }

@@ -388,6 +407,26 @@ virDomainBackupDiskDefFormat(virBufferPtr buf,
 }


+static void
+virDomainBackupDefFormatPrivate(virBufferPtr buf,
+virDomainBackupDefPtr def,
+bool internal)
+{
+g_auto(virBuffer) privChildBuf = VIR_BUFFER_INIT_CHILD(buf);
+g_auto(virBuffer) objectsChildBuf = VIR_BUFFER_INIT_CHILD();
+
+if (!internal)
+return;
+
+virBufferEscapeString(, "\n",
+  def->tlsSecretAlias);
+virBufferEscapeString(, "\n", 
def->tlsAlias);
+
+virXMLFormatElement(, "objects", NULL, );
+virXMLFormatElement(buf, "privateData", NULL, );
+}
+
+
 int
 virDomainBackupDefFormat(virBufferPtr buf,
  virDomainBackupDefPtr def,
@@ -422,6 +461,9 @@ virDomainBackupDefFormat(virBufferPtr buf,
 }

 virXMLFormatElement(, "disks", NULL, );
+
+virDomainBackupDefFormatPrivate(, def, internal);
+
 virXMLFormatElement(buf, "domainbackup", , );

 return 0;
diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h
index 3f8b592b8d..a1d1e453c1 100644
--- a/src/conf/backup_conf.h
+++ b/src/conf/backup_conf.h
@@ -86,6 +86,11 @@ struct _virDomainBackupDef {
 virDomainBackupDiskDef *disks;

 /* internal data */
+
+/* NBD TLS internals */
+char *tlsAlias;
+char *tlsSecretAlias;
+
 /* statistic totals for completed disks */
 unsigned long long push_transferred;
 unsigned long long push_total;
diff --git a/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml 
b/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
new file mode 100644
index 00..261dec0eea
--- /dev/null
+++ b/tests/domainbackupxml2xmlin/backup-pull-internal-invalid.xml
@@ -0,0 +1,36 @@
+
+  1525889631
+  
+  
+
+  
+  
+
+  
+
+  
+
+
+  
+  
+
+  
+
+  
+
+
+  
+  
+
+  
+
+  
+
+  
+  
+
+  
+  
+
+  
+
diff --git a/tests/domainbackupxml2xmlout/backup-pull-internal-invalid.xml 
b/tests/domainbackupxml2xmlout/backup-pull-internal-invalid.xml
new file mode 12
index 00..055ca37a0b
--- /dev/null
+++ b/tests/domainbackupxml2xmlout/backup-pull-internal-invalid.xml
@@ -0,0 +1 @@
+../domainbackupxml2xmlin/backup-pull-internal-invalid.xml
\ No newline at end of file
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index cf07f9bb79..2c1e8616dd 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -215,6 +215,8 @@ mymain(void)
 DO_TEST_BACKUP("backup-push-seclabel");
 DO_TEST_BACKUP("backup-push-encrypted");

+DO_TEST_BACKUP_FULL("backup-pull-internal-invalid", true);
+

 virObjectUnref(caps);
 virObjectUnref(xmlopt);
-- 
2.26.2



[PATCH 10/24] qemu: domain: Setup secret for TLS key for nbd/vxhs disks

2020-07-02 Thread Peter Krempa
Setup the TLS secret when preparing a virStorageSource for use.

https://bugzilla.redhat.com/show_bug.cgi?id=1602328

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

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7f0be22f20..42cc78ac1b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9537,7 +9537,9 @@ qemuDomainPrepareChardevSource(virDomainDefPtr def,

 static int
 qemuProcessPrepareStorageSourceTLSVxhs(virStorageSourcePtr src,
-   virQEMUDriverConfigPtr cfg)
+   virQEMUDriverConfigPtr cfg,
+   qemuDomainObjPrivatePtr priv,
+   const char *parentAlias)
 {
 /* VxHS uses only client certificates and thus has no need for
  * the server-key.pem nor a secret that could be used to decrypt
@@ -9550,9 +9552,19 @@ 
qemuProcessPrepareStorageSourceTLSVxhs(virStorageSourcePtr src,
 src->tlsFromConfig = true;
 }

-if (src->haveTLS == VIR_TRISTATE_BOOL_YES)
+if (src->haveTLS == VIR_TRISTATE_BOOL_YES) {
+src->tlsAlias = qemuAliasTLSObjFromSrcAlias(parentAlias);
 src->tlsCertdir = g_strdup(cfg->vxhsTLSx509certdir);

+if (cfg->vxhsTLSx509secretUUID) {
+qemuDomainStorageSourcePrivatePtr srcpriv = 
qemuDomainStorageSourcePrivateFetch(src);
+
+if (!(srcpriv->tlsKeySecret = qemuDomainSecretInfoTLSNew(priv, 
src->tlsAlias,
+ 
cfg->vxhsTLSx509secretUUID)))
+return -1;
+}
+}
+
 return 0;
 }

@@ -9560,7 +9572,8 @@ 
qemuProcessPrepareStorageSourceTLSVxhs(virStorageSourcePtr src,
 static int
 qemuProcessPrepareStorageSourceTLSNBD(virStorageSourcePtr src,
   virQEMUDriverConfigPtr cfg,
-  virQEMUCapsPtr qemuCaps)
+  qemuDomainObjPrivatePtr priv,
+  const char *parentAlias)
 {
 if (src->haveTLS == VIR_TRISTATE_BOOL_ABSENT) {
 if (cfg->nbdTLS)
@@ -9571,13 +9584,22 @@ 
qemuProcessPrepareStorageSourceTLSNBD(virStorageSourcePtr src,
 }

 if (src->haveTLS == VIR_TRISTATE_BOOL_YES) {
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NBD_TLS)) {
+if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_TLS)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu does not support TLS transport for 
NBD"));
 return -1;
 }

+src->tlsAlias = qemuAliasTLSObjFromSrcAlias(parentAlias);
 src->tlsCertdir = g_strdup(cfg->nbdTLSx509certdir);
+
+if (cfg->nbdTLSx509secretUUID) {
+qemuDomainStorageSourcePrivatePtr srcpriv = 
qemuDomainStorageSourcePrivateFetch(src);
+
+if (!(srcpriv->tlsKeySecret = qemuDomainSecretInfoTLSNew(priv, 
src->tlsAlias,
+ 
cfg->nbdTLSx509secretUUID)))
+return -1;
+}
 }

 return 0;
@@ -9599,19 +9621,19 @@ static int
 qemuDomainPrepareStorageSourceTLS(virStorageSourcePtr src,
   virQEMUDriverConfigPtr cfg,
   const char *parentAlias,
-  virQEMUCapsPtr qemuCaps)
+  qemuDomainObjPrivatePtr priv)
 {
 if (virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_NETWORK)
 return 0;

 switch ((virStorageNetProtocol) src->protocol) {
 case VIR_STORAGE_NET_PROTOCOL_VXHS:
-if (qemuProcessPrepareStorageSourceTLSVxhs(src, cfg) < 0)
+if (qemuProcessPrepareStorageSourceTLSVxhs(src, cfg, priv, 
parentAlias) < 0)
 return -1;
 break;

 case VIR_STORAGE_NET_PROTOCOL_NBD:
-if (qemuProcessPrepareStorageSourceTLSNBD(src, cfg, qemuCaps) < 0)
+if (qemuProcessPrepareStorageSourceTLSNBD(src, cfg, priv, parentAlias) 
< 0)
 return -1;
 break;

@@ -9640,10 +9662,6 @@ qemuDomainPrepareStorageSourceTLS(virStorageSourcePtr 
src,
 return -1;
 }

-if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&
-!(src->tlsAlias = qemuAliasTLSObjFromSrcAlias(parentAlias)))
-return -1;
-
 return 0;
 }

@@ -12128,7 +12146,7 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefPtr 
disk,
 return -1;

 if (qemuDomainPrepareStorageSourceTLS(disk->src, cfg, disk->info.alias,
-  priv->qemuCaps) < 0)
+  priv) < 0)
 return -1;

 return 0;
@@ -12164,7 +12182,7 @@ 
qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
 return -1;

 if (qemuDomainPrepareStorageSourceTLS(src, cfg, 

[PATCH 09/24] qemu: conf: Add configuration of TLS key encryption for 'vxhs' and 'nbd' disks

2020-07-02 Thread Peter Krempa
Until now libvirt didn't allow using encrypted TLS key for disk clients.

Add fields for configuring the secret and propagate defaults.

Signed-off-by: Peter Krempa 
---
 src/qemu/libvirtd_qemu.aug |  2 ++
 src/qemu/qemu.conf | 19 +++
 src/qemu/qemu_conf.c   | 13 +
 src/qemu/qemu_conf.h   |  2 ++
 src/qemu/test_libvirtd_qemu.aug.in |  2 ++
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 7a6a33c77c..c19a086c38 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -61,9 +61,11 @@ module Libvirtd_qemu =

let vxhs_entry = bool_entry "vxhs_tls"
  | str_entry "vxhs_tls_x509_cert_dir"
+ | str_entry "vxhs_tls_x509_secret_uuid"

let nbd_entry = bool_entry "nbd_tls"
  | str_entry "nbd_tls_x509_cert_dir"
+ | str_entry "nbd_tls_x509_secret_uuid"

let nogfx_entry = bool_entry "nographics_allow_host_audio"

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 9b04c8534b..ab403c21ac 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -303,6 +303,15 @@
 #vxhs_tls_x509_cert_dir = "/etc/pki/libvirt-vxhs"


+# Uncomment and use the following option to override the default secret
+# UUID provided in the default_tls_x509_secret_uuid parameter.
+#
+# NB This default all-zeros UUID will not work. Replace it with the
+# output from the UUID for the TLS secret from a 'virsh secret-list'
+# command and then uncomment the entry
+#
+#vxhs_tls_x509_secret_uuid = "----"
+

 # Enable use of TLS encryption for all NBD disk devices that don't
 # specifically disable it.
@@ -337,6 +346,16 @@
 #nbd_tls_x509_cert_dir = "/etc/pki/libvirt-nbd"


+# Uncomment and use the following option to override the default secret
+# UUID provided in the default_tls_x509_secret_uuid parameter.
+#
+# NB This default all-zeros UUID will not work. Replace it with the
+# output from the UUID for the TLS secret from a 'virsh secret-list'
+# command and then uncomment the entry
+#
+#nbd_tls_x509_secret_uuid = "----"
+
+
 # In order to override the default TLS certificate location for migration
 # certificates, supply a valid path to the certificate directory. If the
 # provided path does not exist, libvirtd will fail to start. If the path is
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b9b90e853f..6e673e8f62 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -339,7 +339,10 @@ static void virQEMUDriverConfigDispose(void *obj)
 VIR_FREE(cfg->chardevTLSx509secretUUID);

 VIR_FREE(cfg->vxhsTLSx509certdir);
+VIR_FREE(cfg->vxhsTLSx509secretUUID);
+
 VIR_FREE(cfg->nbdTLSx509certdir);
+VIR_FREE(cfg->nbdTLSx509secretUUID);

 VIR_FREE(cfg->migrateTLSx509certdir);
 VIR_FREE(cfg->migrateTLSx509secretUUID);
@@ -477,12 +480,8 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,

 if (virConfGetValueBool(conf, "vxhs_tls", >vxhsTLS) < 0)
 return -1;
-if (virConfGetValueString(conf, "vxhs_tls_x509_cert_dir", 
>vxhsTLSx509certdir) < 0)
-return -1;
 if (virConfGetValueBool(conf, "nbd_tls", >nbdTLS) < 0)
 return -1;
-if (virConfGetValueString(conf, "nbd_tls_x509_cert_dir", 
>nbdTLSx509certdir) < 0)
-return -1;
 if (virConfGetValueBool(conf, "chardev_tls", >chardevTLS) < 0)
 return -1;

@@ -512,6 +511,10 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
 GET_CONFIG_TLS_CERTINFO_COMMON(migrate);
 GET_CONFIG_TLS_CERTINFO_SERVER(migrate);

+GET_CONFIG_TLS_CERTINFO_COMMON(vxhs);
+
+GET_CONFIG_TLS_CERTINFO_COMMON(nbd);
+
 #undef GET_CONFIG_TLS_CERTINFO_COMMON
 #undef GET_CONFIG_TLS_CERTINFO_SERVER
 return 0;
@@ -1186,6 +1189,8 @@ virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr cfg)
 SET_TLS_SECRET_UUID_DEFAULT(vnc);
 SET_TLS_SECRET_UUID_DEFAULT(chardev);
 SET_TLS_SECRET_UUID_DEFAULT(migrate);
+SET_TLS_SECRET_UUID_DEFAULT(vxhs);
+SET_TLS_SECRET_UUID_DEFAULT(nbd);

 #undef SET_TLS_SECRET_UUID_DEFAULT

diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 4f54c136db..6193a7111c 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -146,9 +146,11 @@ struct _virQEMUDriverConfig {

 bool vxhsTLS;
 char *vxhsTLSx509certdir;
+char *vxhsTLSx509secretUUID;

 bool nbdTLS;
 char *nbdTLSx509certdir;
+char *nbdTLSx509secretUUID;

 unsigned int remotePortMin;
 unsigned int remotePortMax;
diff --git a/src/qemu/test_libvirtd_qemu.aug.in 
b/src/qemu/test_libvirtd_qemu.aug.in
index e533b9f551..db125bf352 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -28,8 +28,10 @@ module Test_libvirtd_qemu =
 { "chardev_tls_x509_secret_uuid" = "----" }
 { "vxhs_tls" = 

[PATCH 11/24] tests: qemuxml2argv: Test encrypted TLS key for nbd/vxhs disks

2020-07-02 Thread Peter Krempa
Add a dummy secret so that we see what command line is generated.

Signed-off-by: Peter Krempa 
---
 .../disk-network-tlsx509.x86_64-2.12.0.args| 15 ---
 .../disk-network-tlsx509.x86_64-latest.args| 18 +++---
 tests/qemuxml2argvtest.c   |  2 ++
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-2.12.0.args 
b/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-2.12.0.args
index 06686f801d..2a30ad02c9 100644
--- a/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-2.12.0.args
+++ b/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-2.12.0.args
@@ -28,8 +28,11 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -no-acpi \
 -boot strict=on \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-object secret,id=objvirtio-disk0_tls0-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -object 
tls-creds-x509,id=objvirtio-disk0_tls0,dir=/etc/pki/libvirt-vxhs/dummy,\
-,path,endpoint=client,verify-peer=yes \
+,path,endpoint=client,verify-peer=yes,passwordid=objvirtio-disk0_tls0-secret0 \
 -drive file.driver=vxhs,file.tls-creds=objvirtio-disk0_tls0,\
 file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,\
 file.server.host=192.168.0.1,file.server.port=,format=raw,if=none,\
@@ -37,8 +40,11 @@ id=drive-virtio-disk0,cache=none \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
 id=virtio-disk0,bootindex=1,write-cache=on,\
 serial=eb90327c-8302-4725-9e1b-4e85ed4dc251 \
+-object secret,id=objvirtio-disk1_tls0-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -object 
tls-creds-x509,id=objvirtio-disk1_tls0,dir=/etc/pki/libvirt-vxhs/dummy,\
-,path,endpoint=client,verify-peer=yes \
+,path,endpoint=client,verify-peer=yes,passwordid=objvirtio-disk1_tls0-secret0 \
 -drive file.driver=vxhs,file.tls-creds=objvirtio-disk1_tls0,\
 file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc252,\
 file.server.host=192.168.0.2,file.server.port=,format=raw,if=none,\
@@ -50,8 +56,11 @@ 
file.server.host=192.168.0.3,file.server.port=,format=raw,if=none,\
 id=drive-virtio-disk2,cache=none \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk2,\
 id=virtio-disk2,write-cache=on,serial=eb90327c-8302-4725-9e1b-4e85ed4dc252 \
+-object secret,id=objvirtio-disk3_tls0-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -object 
tls-creds-x509,id=objvirtio-disk3_tls0,dir=/etc/pki/libvirt-nbd/dummy,,\
-path,endpoint=client,verify-peer=yes \
+path,endpoint=client,verify-peer=yes,passwordid=objvirtio-disk3_tls0-secret0 \
 -drive file.driver=nbd,file.server.type=inet,file.server.host=example.com,\
 file.server.port=1234,file.tls-creds=objvirtio-disk3_tls0,format=raw,if=none,\
 id=drive-virtio-disk3,cache=none \
diff --git a/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-latest.args 
b/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-latest.args
index 5195107b7b..ec4c28e161 100644
--- a/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-network-tlsx509.x86_64-latest.args
@@ -28,8 +28,12 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -no-acpi \
 -boot strict=on \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-object secret,id=objlibvirt-4-storage_tls0-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -object tls-creds-x509,id=objlibvirt-4-storage_tls0,\
-dir=/etc/pki/libvirt-vxhs/dummy,,path,endpoint=client,verify-peer=yes \
+dir=/etc/pki/libvirt-vxhs/dummy,,path,endpoint=client,verify-peer=yes,\
+passwordid=objlibvirt-4-storage_tls0-secret0 \
 -blockdev '{"driver":"vxhs","tls-creds":"objlibvirt-4-storage_tls0",\
 "vdisk-id":"eb90327c-8302-4725-9e1b-4e85ed4dc251",\
 "server":{"host":"192.168.0.1","port":""},"node-name":"libvirt-4-storage",\
@@ -41,8 +45,12 @@ 
dir=/etc/pki/libvirt-vxhs/dummy,,path,endpoint=client,verify-peer=yes \
 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=libvirt-4-format,\
 id=virtio-disk0,bootindex=1,write-cache=on,\
 serial=eb90327c-8302-4725-9e1b-4e85ed4dc251 \
+-object secret,id=objlibvirt-3-storage_tls0-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -object tls-creds-x509,id=objlibvirt-3-storage_tls0,\
-dir=/etc/pki/libvirt-vxhs/dummy,,path,endpoint=client,verify-peer=yes \
+dir=/etc/pki/libvirt-vxhs/dummy,,path,endpoint=client,verify-peer=yes,\
+passwordid=objlibvirt-3-storage_tls0-secret0 \
 -blockdev '{"driver":"vxhs","tls-creds":"objlibvirt-3-storage_tls0",\
 

[PATCH 06/24] virQEMUDriverConfigLoadSpecificTLSEntry: Split up fetching of server-only config options

2020-07-02 Thread Peter Krempa
The '*_tls_x509_verify' options are relevant only when we are going to
expose a server socket as client sockets always enable verification.

Split up the macro to separate the common bits from the server bits so
that when we'll later extend support of 'nbd' and 'vxhs' disks which are
client only we can reuse the existing macros.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_conf.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2cbff1348a..b9b90e853f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -486,13 +486,8 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
 if (virConfGetValueBool(conf, "chardev_tls", >chardevTLS) < 0)
 return -1;

-#define GET_CONFIG_TLS_CERTINFO(val) \
+#define GET_CONFIG_TLS_CERTINFO_COMMON(val) \
 do { \
-if ((rv = virConfGetValueBool(conf, #val "_tls_x509_verify", \
-  >val## TLSx509verify)) < 0) \
-return -1; \
-if (rv == 1) \
-cfg->val## TLSx509verifyPresent = true; \
 if (virConfGetValueString(conf, #val "_tls_x509_cert_dir", \
   >val## TLSx509certdir) < 0) \
 return -1; \
@@ -502,11 +497,23 @@ 
virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
 return -1; \
 } while (0)

-GET_CONFIG_TLS_CERTINFO(chardev);
+#define GET_CONFIG_TLS_CERTINFO_SERVER(val) \
+do { \
+if ((rv = virConfGetValueBool(conf, #val "_tls_x509_verify", \
+  >val## TLSx509verify)) < 0) \
+return -1; \
+if (rv == 1) \
+cfg->val## TLSx509verifyPresent = true; \
+} while (0)
+
+GET_CONFIG_TLS_CERTINFO_COMMON(chardev);
+GET_CONFIG_TLS_CERTINFO_SERVER(chardev);

-GET_CONFIG_TLS_CERTINFO(migrate);
+GET_CONFIG_TLS_CERTINFO_COMMON(migrate);
+GET_CONFIG_TLS_CERTINFO_SERVER(migrate);

-#undef GET_CONFIG_TLS_CERTINFO
+#undef GET_CONFIG_TLS_CERTINFO_COMMON
+#undef GET_CONFIG_TLS_CERTINFO_SERVER
 return 0;
 }

-- 
2.26.2



[PATCH 18/24] qemu: checkpoint: Implement VIR_DOMAIN_CHECKPOINT_XML_SIZE

2020-07-02 Thread Peter Krempa
Introduce code which merges the appropriate bitmaps and queries the
final size of the backup, so that we can print the XML with size
information.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_checkpoint.c | 143 -
 1 file changed, 142 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index c24d97443c..f45ab29d4c 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -567,6 +567,142 @@ qemuCheckpointCreateXML(virDomainPtr domain,
 }


+struct qemuCheckpointDiskMap {
+virDomainCheckpointDiskDefPtr chkdisk;
+virDomainDiskDefPtr domdisk;
+};
+
+
+static int
+qemuCheckpointGetXMLDescUpdateSize(virDomainObjPtr vm,
+   virDomainCheckpointDefPtr chkdef)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+virQEMUDriverPtr driver = priv->driver;
+g_autoptr(virHashTable) blockNamedNodeData = NULL;
+g_autofree struct qemuCheckpointDiskMap *diskmap = NULL;
+g_autoptr(virJSONValue) recoveractions = NULL;
+g_autoptr(virJSONValue) mergeactions = virJSONValueNewArray();
+g_autoptr(virJSONValue) cleanupactions = virJSONValueNewArray();
+int rc = 0;
+size_t ndisks = 0;
+size_t i;
+int ret = -1;
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+return -1;
+
+if (virDomainObjCheckActive(vm) < 0)
+goto endjob;
+
+if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, 
QEMU_ASYNC_JOB_NONE)))
+goto endjob;
+
+/* enumerate disks relevant for the checkpoint which are also present in 
the
+ * domain */
+diskmap = g_new0(struct qemuCheckpointDiskMap, chkdef->ndisks);
+
+for (i = 0; i < chkdef->ndisks; i++) {
+virDomainCheckpointDiskDefPtr chkdisk = chkdef->disks + i;
+virDomainDiskDefPtr domdisk;
+
+chkdisk->size = 0;
+chkdisk->sizeValid = false;
+
+if (chkdisk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
+continue;
+
+if (!(domdisk = virDomainDiskByTarget(vm->def, chkdisk->name)))
+continue;
+
+if (!qemuBlockBitmapChainIsValid(domdisk->src, chkdef->parent.name, 
blockNamedNodeData))
+continue;
+
+diskmap[ndisks].chkdisk = chkdisk;
+diskmap[ndisks].domdisk = domdisk;
+ndisks++;
+}
+
+if (ndisks == 0) {
+ret = 0;
+goto endjob;
+}
+
+/* we need to calculate the merged bitmap to obtain accurate data */
+for (i = 0; i < ndisks; i++) {
+virDomainDiskDefPtr domdisk = diskmap[i].domdisk;
+g_autoptr(virJSONValue) actions = NULL;
+
+/* possibly delete leftovers from previous cases */
+if (qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, 
domdisk->src,
+  "libvirt-tmp-size-xml")) {
+if (!recoveractions)
+recoveractions = virJSONValueNewArray();
+
+if (qemuMonitorTransactionBitmapRemove(recoveractions,
+   domdisk->src->nodeformat,
+   "libvirt-tmp-size-xml") < 0)
+goto endjob;
+}
+
+if (qemuBlockGetBitmapMergeActions(domdisk->src, NULL, domdisk->src,
+   chkdef->parent.name, 
"libvirt-tmp-size-xml",
+   NULL, , blockNamedNodeData) 
< 0)
+goto endjob;
+
+if (virJSONValueArrayConcat(mergeactions, actions) < 0)
+goto endjob;
+
+if (qemuMonitorTransactionBitmapRemove(cleanupactions,
+   domdisk->src->nodeformat,
+   "libvirt-tmp-size-xml") < 0)
+goto endjob;
+}
+
+qemuDomainObjEnterMonitor(driver, vm);
+
+if (rc == 0 && recoveractions)
+rc = qemuMonitorTransaction(priv->mon, );
+
+if (rc == 0)
+rc = qemuMonitorTransaction(priv->mon, );
+
+if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+goto endjob;
+
+/* now do a final refresh */
+virHashFree(blockNamedNodeData);
+if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, 
QEMU_ASYNC_JOB_NONE)))
+goto endjob;
+
+qemuDomainObjEnterMonitor(driver, vm);
+
+rc = qemuMonitorTransaction(priv->mon, );
+
+if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+goto endjob;
+
+/* update disks */
+for (i = 0; i < ndisks; i++) {
+virDomainCheckpointDiskDefPtr chkdisk = diskmap[i].chkdisk;
+virDomainDiskDefPtr domdisk = diskmap[i].domdisk;
+qemuBlockNamedNodeDataBitmapPtr bitmap;
+
+if ((bitmap = 
qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, domdisk->src,
+
"libvirt-tmp-size-xml"))) {
+chkdisk->size = bitmap->dirtybytes;
+  

[PATCH 00/24] qemu: Incremental backup and TLS handling fixes

2020-07-02 Thread Peter Krempa
This series consists of multiple parts fixing the following bugs. Some
of them depend on previous so I'm sending it as one to prevent
conflicts.

- Patches 1 - 11:

  https://bugzilla.redhat.com/show_bug.cgi?id=1602328
  [RFE] Add support for encrypted TLS client keys for disks

- Patch 12:

  https://bugzilla.redhat.com/show_bug.cgi?id=1840053
  [incremental_backup] cannot do FULL backup for a READONLY disk

- Patches 13 - 14:

  https://bugzilla.redhat.com/show_bug.cgi?id=1829829
   [incremental backup] Creating incremental backup that includes a new VM disk 
that requires full backup is impossible

- Patch 15:

  https://bugzilla.redhat.com/show_bug.cgi?id=1799010
  incremental-backup: RFE: Handle backup bitmaps during virDomainBlockPull

- Patches 16 - 24:

  https://bugzilla.redhat.com/show_bug.cgi?id=1822631
  [incremental backup] RFE: Support TLS for NBD connections for pull mode backup


Peter Krempa (24):
  qemu: domain: Introduce helper for always fetching virStorageSource
private data
  qemuDomainDiskHasEncryptionSecret: unexport
  qemu.conf: Remove misleading mention of 'migrate_tls'
  qemu: conf: Move 'nbd' and 'vxhs' tls config variables together with
rest of tls setup
  virQEMUDriverConfigLoadSpecificTLSEntry: Move fetching of
'chardev_tls' above macro
  virQEMUDriverConfigLoadSpecificTLSEntry: Split up fetching of
server-only config options
  qemu: domain: Add infrastructure passing in TLS key's decryption key
via 'secret'
  qemu block: Add internals for handling 'secret' corresponding to TLS
key
  qemu: conf: Add configuration of TLS key encryption for 'vxhs' and
'nbd' disks
  qemu: domain: Setup secret for TLS key for nbd/vxhs disks
  tests: qemuxml2argv: Test encrypted TLS key for nbd/vxhs disks
  conf: backup: Don't explicitly forbid backup of read-only disk
  docs: backup: Convert XML documentation to RST
  backup: Allow configuring incremental backup per-disk individually
  qemu: backup: integrate with blockpull
  docs: checkpoint: Convert XML documentation to RST
  conf: checkpoint: Add a flag storing whether disk 'size' is valid
  qemu: checkpoint: Implement VIR_DOMAIN_CHECKPOINT_XML_SIZE
  checkpoint: Mention that VIR_DOMAIN_CHECKPOINT_XML_SIZE is expensive
and stale
  testCompareBackupXML: Add infrastructure for testing internal fields
  conf: backup: Store 'tlsAlias' and 'tlsSecretAlias' as internals of a
backup
  qemu: conf: Add configuration of TLS environment for NBD transport of
pull-backups
  conf: backup: Add 'tls' attribute for 'server' element
  qemu: backup: Setup TLS environment for pull-mode backup jobs

 docs/formatbackup.html.in | 191 -
 docs/formatbackup.rst | 164 +++
 docs/formatcheckpoint.html.in | 198 --
 docs/formatcheckpoint.rst | 166 +++
 docs/schemas/domainbackup.rng |  25 ++-
 src/conf/backup_conf.c| 123 ++-
 src/conf/backup_conf.h|  17 ++
 src/conf/checkpoint_conf.c|   2 +-
 src/conf/checkpoint_conf.h|   1 +
 src/libvirt-domain-checkpoint.c   |   3 +-
 src/qemu/libvirtd_qemu.aug|  19 +-
 src/qemu/qemu.conf|  63 +-
 src/qemu/qemu_backup.c|  80 ++-
 src/qemu/qemu_block.c |  12 ++
 src/qemu/qemu_block.h |   2 +
 src/qemu/qemu_blockjob.c  |  37 
 src/qemu/qemu_checkpoint.c| 143 -
 src/qemu/qemu_command.c   |  11 +-
 src/qemu/qemu_conf.c  |  57 +++--
 src/qemu/qemu_conf.h  |  19 +-
 src/qemu/qemu_domain.c|  66 --
 src/qemu/qemu_domain.h|   8 +-
 src/qemu/test_libvirtd_qemu.aug.in|   5 +
 .../backup-pull-encrypted.xml |   2 +-
 .../backup-pull-internal-invalid.xml  |  36 
 tests/domainbackupxml2xmlin/backup-pull.xml   |  12 ++
 .../backup-pull-encrypted.xml |   2 +-
 .../backup-pull-internal-invalid.xml  |   1 +
 tests/domainbackupxml2xmlout/backup-pull.xml  |  12 ++
 tests/genericxml2xmltest.c|  32 ++-
 tests/qemudomaincheckpointxml2xmltest.c   |   1 +
 tests/qemustatusxml2xmldata/modern-in.xml |   1 +
 .../disk-network-tlsx509.x86_64-2.12.0.args   |  15 +-
 .../disk-network-tlsx509.x86_64-latest.args   |  18 +-
 tests/qemuxml2argvtest.c  |   2 +
 35 files changed, 1079 insertions(+), 467 deletions(-)
 delete mode 100644 docs/formatbackup.html.in
 create mode 100644 docs/formatbackup.rst
 delete mode 100644 docs/formatcheckpoint.html.in
 create mode 100644 docs/formatcheckpoint.rst
 create mode 100644 

[PATCH 17/24] conf: checkpoint: Add a flag storing whether disk 'size' is valid

2020-07-02 Thread Peter Krempa
Avoid printing '0' size in case when we weren't able to determine the
backup size by adding a flag whether the size is valid and interlock
printing of the field according to the flag.

Signed-off-by: Peter Krempa 
---
 src/conf/checkpoint_conf.c  | 2 +-
 src/conf/checkpoint_conf.h  | 1 +
 tests/qemudomaincheckpointxml2xmltest.c | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index d557fada49..3405e8a3cc 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -430,7 +430,7 @@ virDomainCheckpointDiskDefFormat(virBufferPtr buf,
   virDomainCheckpointTypeToString(disk->type));
 if (disk->bitmap) {
 virBufferEscapeString(buf, " bitmap='%s'", disk->bitmap);
-if (flags & VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE)
+if (flags & VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE && disk->sizeValid)
 virBufferAsprintf(buf, " size='%llu'", disk->size);
 }
 virBufferAddLit(buf, "/>\n");
diff --git a/src/conf/checkpoint_conf.h b/src/conf/checkpoint_conf.h
index ee5d210593..f115b98c2b 100644
--- a/src/conf/checkpoint_conf.h
+++ b/src/conf/checkpoint_conf.h
@@ -46,6 +46,7 @@ struct _virDomainCheckpointDiskDef {
 int type;   /* virDomainCheckpointType */
 char *bitmap;   /* bitmap name, if type is bitmap */
 unsigned long long size; /* current checkpoint size in bytes */
+bool sizeValid;
 };

 /* Stores the complete checkpoint metadata */
diff --git a/tests/qemudomaincheckpointxml2xmltest.c 
b/tests/qemudomaincheckpointxml2xmltest.c
index b73ac74e81..a5a5b59205 100644
--- a/tests/qemudomaincheckpointxml2xmltest.c
+++ b/tests/qemudomaincheckpointxml2xmltest.c
@@ -83,6 +83,7 @@ testCompareXMLToXMLFiles(const char *inxml,
 }
 if (flags & TEST_SIZE) {
 def->disks[0].size = 1048576;
+def->disks[0].sizeValid = true;
 formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE;
 }

-- 
2.26.2



[PATCH 03/24] qemu.conf: Remove misleading mention of 'migrate_tls'

2020-07-02 Thread Peter Krempa
There's no such parameter. Reword the sentence to account for enabling
TLS-encrypted migration using API flags.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu.conf | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index f89dbd2c3a..9b04c8534b 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -340,9 +340,10 @@
 # In order to override the default TLS certificate location for migration
 # certificates, supply a valid path to the certificate directory. If the
 # provided path does not exist, libvirtd will fail to start. If the path is
-# not provided, but migrate_tls = 1, then the default_tls_x509_cert_dir path
-# will be used. Once/if a default certificate is enabled/defined, migration
-# will then be able to use the certificate via migration API flags.
+# not provided, but TLS-encrypted migration is requested, then the
+# default_tls_x509_cert_dir path will be used. Once/if a default certificate is
+# enabled/defined, migration will then be able to use the certificate via
+# migration API flags.
 #
 #migrate_tls_x509_cert_dir = "/etc/pki/libvirt-migrate"

-- 
2.26.2



[PATCH 07/24] qemu: domain: Add infrastructure passing in TLS key's decryption key via 'secret'

2020-07-02 Thread Peter Krempa
Store the required data in the private data of a storage source and
ensure that the 'alias' of the secret is formatted in the status XML.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_domain.c| 10 +-
 src/qemu/qemu_domain.h|  3 +++
 tests/qemustatusxml2xmldata/modern-in.xml |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 697ddab727..7f0be22f20 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -567,6 +567,7 @@ qemuDomainStorageSourcePrivateDispose(void *obj)
 g_clear_pointer(>secinfo, qemuDomainSecretInfoFree);
 g_clear_pointer(>encinfo, qemuDomainSecretInfoFree);
 g_clear_pointer(>httpcookie, qemuDomainSecretInfoFree);
+g_clear_pointer(>tlsKeySecret, qemuDomainSecretInfoFree);
 }


@@ -1083,6 +1084,7 @@ qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
 if ((srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(n))) {
 qemuDomainSecretInfoDestroy(srcPriv->secinfo);
 qemuDomainSecretInfoDestroy(srcPriv->encinfo);
+qemuDomainSecretInfoDestroy(srcPriv->tlsKeySecret);
 }
 }
 }
@@ -1750,6 +1752,7 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
 g_autofree char *authalias = NULL;
 g_autofree char *encalias = NULL;
 g_autofree char *httpcookiealias = NULL;
+g_autofree char *tlskeyalias = NULL;

 src->nodestorage = 
virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
 src->nodeformat = 
virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
@@ -1764,8 +1767,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
 authalias = 
virXPathString("string(./objects/secret[@type='auth']/@alias)", ctxt);
 encalias = 
virXPathString("string(./objects/secret[@type='encryption']/@alias)", ctxt);
 httpcookiealias = 
virXPathString("string(./objects/secret[@type='httpcookie']/@alias)", ctxt);
+tlskeyalias = 
virXPathString("string(./objects/secret[@type='tlskey']/@alias)", ctxt);

-if (authalias || encalias || httpcookiealias) {
+if (authalias || encalias || httpcookiealias || tlskeyalias) {
 if (!src->privateData &&
 !(src->privateData = qemuDomainStorageSourcePrivateNew()))
 return -1;
@@ -1780,6 +1784,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,

 if (qemuStorageSourcePrivateDataAssignSecinfo(>httpcookie, 
) < 0)
 return -1;
+
+if (qemuStorageSourcePrivateDataAssignSecinfo(>tlsKeySecret, 
) < 0)
+return -1;
 }

 if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
@@ -1831,6 +1838,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr 
src,
 qemuStorageSourcePrivateDataFormatSecinfo(, srcPriv->secinfo, 
"auth");
 qemuStorageSourcePrivateDataFormatSecinfo(, srcPriv->encinfo, 
"encryption");
 qemuStorageSourcePrivateDataFormatSecinfo(, srcPriv->httpcookie, 
"httpcookie");
+qemuStorageSourcePrivateDataFormatSecinfo(, srcPriv->tlsKeySecret, 
"tlskey");
 }

 if (src->tlsAlias)
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 1ddac52092..e524fd0002 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -317,6 +317,9 @@ struct _qemuDomainStorageSourcePrivate {

 /* secure passthrough of the http cookie */
 qemuDomainSecretInfoPtr httpcookie;
+
+/* key for decrypting TLS certificate */
+qemuDomainSecretInfoPtr tlsKeySecret;
 };

 virObjectPtr qemuDomainStorageSourcePrivateNew(void);
diff --git a/tests/qemustatusxml2xmldata/modern-in.xml 
b/tests/qemustatusxml2xmldata/modern-in.xml
index 64d42200e4..2e0e415bc3 100644
--- a/tests/qemustatusxml2xmldata/modern-in.xml
+++ b/tests/qemustatusxml2xmldata/modern-in.xml
@@ -336,6 +336,7 @@
 
 
 
+
 
   
 
-- 
2.26.2



[PATCH 15/24] qemu: backup: integrate with blockpull

2020-07-02 Thread Peter Krempa
Merge the bitmaps when finalizing a block pull job so that backups work
properly afterwards.

https://bugzilla.redhat.com/show_bug.cgi?id=1799010

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_blockjob.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 7e4530f48b..435c945b78 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -936,6 +936,41 @@ qemuBlockJobClearConfigChain(virDomainObjPtr vm,
 }


+static int
+qemuBlockJobProcessEventCompletedPullBitmaps(virDomainObjPtr vm,
+ qemuBlockJobDataPtr job,
+ qemuDomainAsyncJob asyncJob)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+g_autoptr(virHashTable) blockNamedNodeData = NULL;
+g_autoptr(virJSONValue) actions = NULL;
+
+if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, asyncJob)))
+return -1;
+
+if (qemuBlockGetBitmapMergeActions(job->disk->src,
+   job->data.pull.base,
+   job->disk->src,
+   NULL, NULL, NULL,
+   ,
+   blockNamedNodeData) < 0)
+return -1;
+
+if (!actions)
+return 0;
+
+if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
+return -1;
+
+qemuMonitorTransaction(priv->mon, );
+
+if (qemuDomainObjExitMonitor(priv->driver, vm) < 0)
+return -1;
+
+return 0;
+}
+
+
 /**
  * qemuBlockJobProcessEventCompletedPull:
  * @driver: qemu driver object
@@ -976,6 +1011,8 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr 
driver,
 if (!cfgdisk)
 qemuBlockJobClearConfigChain(vm, job->disk);

+qemuBlockJobProcessEventCompletedPullBitmaps(vm, job, asyncJob);
+
 /* when pulling if 'base' is right below the top image we don't have to 
modify it */
 if (job->disk->src->backingStore == job->data.pull.base)
 return;
-- 
2.26.2



Re: [libvirt PATCH 18/31] scripts: check-remote-protocol: remove unused OBJEXT argument

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

Signed-off-by: Pavel Hrdina 
---
scripts/check-remote-protocol.py |  5 ++---
src/Makefile.am  | 10 +-
2 files changed, 7 insertions(+), 8 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [libvirt PATCH 07/31] docs: remove unused wrapstring.xsl file

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

Commit  removed last usage of
this file so drop it as well.

Signed-off-by: Pavel Hrdina 
---
docs/Makefile.am|  1 -
docs/wrapstring.xsl | 56 -
2 files changed, 57 deletions(-)
delete mode 100644 docs/wrapstring.xsl



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [libvirt PATCH 05/31] Makefile: drop undefined LIB_CLOCK_GETTIME

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

This was introduced together with clock-time gnulib module by commit
 and removed from libvirt
by commit <86d223a762990c9d529065a2d3b30b6a00ea63dd>.



Adjustment archeology appreciated.


Signed-off-by: Pavel Hrdina 
---
src/util/Makefile.inc.am | 1 -
tests/Makefile.am| 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [libvirt PATCH 04/31] configure: remove usage of AC_HEADER_MAJOR

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

Commit <03c532cf9711dd6ad35380455a77141ef7d492ab> removed usage of
MAJOR_IN_MKDEV and MAJOR_IN_SYSMACROS from libvirt which makes the
AC_HEADER_MAJOR useless.

Signed-off-by: Pavel Hrdina 
---
configure.ac | 2 --
1 file changed, 2 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [libvirt PATCH 03/31] configure: introduce FLAT_NAMESPACE_FLAGS

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

Set FLAT_NAMESPACE_FLAGS to -Wl,-flat_namespace in configure only for
macOS and use it unconditionally in Makefiles.

Signed-off-by: Pavel Hrdina 
---
configure.ac  | 13 +
src/Makefile.am   | 10 +++---
tests/Makefile.am |  7 +++
3 files changed, 19 insertions(+), 11 deletions(-)



Much nicer.

Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [libvirt PATCH 02/31] configure: drop check for unsupported FreeBSD

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

FreeBSD 10 is no longer supported by libvirt and the struct member
ifi_oqdrops is usable without any define on later FreeBSD versions.

Signed-off-by: Pavel Hrdina 
---
configure.ac | 11 ---
1 file changed, 11 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [libvirt PATCH 01/31] build: use DLOPEN_LIBS directly

2020-07-02 Thread Ján Tomko

On a Thursday in 2020, Pavel Hrdina wrote:

There is no need to have DRIVER_MODULES_LIBS as it's used only for
libvirt.so.  The other places are using DLOPEN_LIBS directly and dlopen
is required if building with libvirtd.



It might be worth noting that it is mandatory since
5aec02dc37623bf739d1edd8f2be3e4ad9f94ff5
make: Drop building without driver modules



Signed-off-by: Pavel Hrdina 
---
m4/virt-driver-modules.m4 | 3 ---
src/Makefile.am   | 2 +-
2 files changed, 1 insertion(+), 4 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


Re: [PATCH v5 11/20] pc_basic_device_init: pass PCMachineState

2020-07-02 Thread Philippe Mathieu-Daudé
On 7/2/20 3:25 PM, Gerd Hoffmann wrote:
> Need access to pcms for pcspk initialization.
> Just preparation, no functional change.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  include/hw/i386/pc.h | 3 ++-
>  hw/i386/pc.c | 3 ++-
>  hw/i386/pc_piix.c| 2 +-
>  hw/i386/pc_q35.c | 2 +-
>  4 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index dce1273c7dad..3a601dbe71da 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -160,7 +160,8 @@ void pc_memory_init(PCMachineState *pcms,
>  MemoryRegion **ram_memory);
>  uint64_t pc_pci_hole64_start(void);
>  DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
> -void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
> +void pc_basic_device_init(struct PCMachineState *pcms,

[Not this patch problem, simply thinking loudly]

What we should pass is a PCMachineClass pointer.

I don't understand why PIT is a runtime changeable property.

> +  ISABus *isa_bus, qemu_irq *gsi,
>ISADevice **rtc_state,
>bool create_fdctrl,
>bool no_vmport,
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 4af9679d039b..d89e577f6fa1 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1155,7 +1155,8 @@ static void pc_superio_init(ISABus *isa_bus, bool 
> create_fdctrl, bool no_vmport)
>  g_free(a20_line);
>  }
>  
> -void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
> +void pc_basic_device_init(struct PCMachineState *pcms,
> +  ISABus *isa_bus, qemu_irq *gsi,
>ISADevice **rtc_state,
>bool create_fdctrl,
>bool no_vmport,
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 1d832b2878b1..a3b416507286 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -235,7 +235,7 @@ static void pc_init1(MachineState *machine,
>  }
>  
>  /* init basic PC hardware */
> -pc_basic_device_init(isa_bus, x86ms->gsi, _state, true,
> +pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, true,
>   (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
>   0x4);
>  
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 047ea8db28ea..b16e22c6cccd 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -275,7 +275,7 @@ static void pc_q35_init(MachineState *machine)
>  }
>  
>  /* init basic PC hardware */
> -pc_basic_device_init(isa_bus, x86ms->gsi, _state, !mc->no_floppy,
> +pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, 
> !mc->no_floppy,
>   (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
>   0xff0104);
>  
> 



[PATCH v5 02/20] stubs: add pci_create_simple

2020-07-02 Thread Gerd Hoffmann
Needed for -soundhw cleanup.

Signed-off-by: Gerd Hoffmann 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
---
 stubs/pci-bus.c | 7 +++
 stubs/Makefile.objs | 1 +
 2 files changed, 8 insertions(+)
 create mode 100644 stubs/pci-bus.c

diff --git a/stubs/pci-bus.c b/stubs/pci-bus.c
new file mode 100644
index ..a8932fa93250
--- /dev/null
+++ b/stubs/pci-bus.c
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "hw/pci/pci.h"
+
+PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
+{
+g_assert_not_reached();
+}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index ff0411d21f22..918e46bdc1ca 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -13,6 +13,7 @@ stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
 stub-obj-y += monitor-core.o
 stub-obj-y += notify-event.o
+stub-obj-y += pci-bus.o
 stub-obj-y += qmp_memory_device.o
 stub-obj-y += qtest.o
 stub-obj-y += ramfb.o
-- 
2.18.4



[PATCH v5 09/20] audio: deprecate -soundhw sb16

2020-07-02 Thread Gerd Hoffmann
Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/sb16.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index df6f755a37f8..2d9e50f99b5d 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -1415,12 +1415,6 @@ static void sb16_realizefn (DeviceState *dev, Error 
**errp)
 AUD_register_card ("sb16", >card);
 }
 
-static int SB16_init (ISABus *bus)
-{
-isa_create_simple (bus, TYPE_SB16);
-return 0;
-}
-
 static Property sb16_properties[] = {
 DEFINE_AUDIO_PROPERTIES(SB16State, card),
 DEFINE_PROP_UINT32 ("version", SB16State, ver,  0x0405), /* 4.5 */
@@ -1453,7 +1447,8 @@ static const TypeInfo sb16_info = {
 static void sb16_register_types (void)
 {
 type_register_static (_info);
-isa_register_soundhw("sb16", "Creative Sound Blaster 16", SB16_init);
+deprecated_register_soundhw("sb16", "Creative Sound Blaster 16",
+1, TYPE_SB16);
 }
 
 type_init (sb16_register_types)
-- 
2.18.4



[PATCH v5 05/20] audio: deprecate -soundhw es1370

2020-07-02 Thread Gerd Hoffmann
Switch to deprecated_register_soundhw().  Remove the now obsolete init
function.  Add an alias so both es1370 and ES1370 are working with
-device.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/es1370.c | 9 ++---
 qdev-monitor.c| 1 +
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 5f8a83ff5624..4255463a49ff 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -884,12 +884,6 @@ static void es1370_exit(PCIDevice *dev)
 AUD_remove_card(>card);
 }
 
-static int es1370_init (PCIBus *bus)
-{
-pci_create_simple (bus, -1, TYPE_ES1370);
-return 0;
-}
-
 static Property es1370_properties[] = {
 DEFINE_AUDIO_PROPERTIES(ES1370State, card),
 DEFINE_PROP_END_OF_LIST(),
@@ -928,7 +922,8 @@ static const TypeInfo es1370_info = {
 static void es1370_register_types (void)
 {
 type_register_static (_info);
-pci_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370", es1370_init);
+deprecated_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370",
+0, TYPE_ES1370);
 }
 
 type_init (es1370_register_types)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 105d9792ecdf..e3083fae394b 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -55,6 +55,7 @@ typedef struct QDevAlias
 static const QDevAlias qdev_alias_table[] = {
 { "AC97", "ac97" }, /* -soundhw name */
 { "e1000", "e1000-82540em" },
+{ "ES1370", "es1370" }, /* -soundhw name */
 { "ich9-ahci", "ahci" },
 { "lsi53c895a", "lsi" },
 { "virtio-9p-ccw", "virtio-9p", QEMU_ARCH_S390X },
-- 
2.18.4



[PATCH v5 19/20] pcspk: update docs/system/target-i386-desc.rst.inc

2020-07-02 Thread Gerd Hoffmann
Add PC speaker with config hints.

Signed-off-by: Gerd Hoffmann 
---
 docs/system/target-i386-desc.rst.inc | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/docs/system/target-i386-desc.rst.inc 
b/docs/system/target-i386-desc.rst.inc
index 47a169e0ae2a..7d1fffacbea3 100644
--- a/docs/system/target-i386-desc.rst.inc
+++ b/docs/system/target-i386-desc.rst.inc
@@ -31,6 +31,8 @@ The QEMU PC System emulator simulates the following 
peripherals:
 
 -  CS4231A compatible sound card
 
+-  PC speaker
+
 -  PCI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1
hub.
 
@@ -49,7 +51,7 @@ must be told to not have parallel ports to have working GUS.
 
 .. parsed-literal::
 
-   |qemu_system_x86| dos.img -soundhw gus -parallel none
+   |qemu_system_x86| dos.img -device gus -parallel none
 
 Alternatively:
 
@@ -60,3 +62,12 @@ Alternatively:
 Or some other unclaimed IRQ.
 
 CS4231A is the chip used in Windows Sound System and GUSMAX products
+
+The PC speaker audio device can be configured using the pcspk-audiodev
+machine property, i.e.
+
+.. parsed-literal::
+
+   |qemu_system_x86| some.img \
+   -audiodev ,id= \
+   -machine pcspk-audiodev=
-- 
2.18.4



[PATCH v5 20/20] audio: set default value for pcspk.iobase property

2020-07-02 Thread Gerd Hoffmann
Allows dropping the explicit qdev_prop_set_uint32 call in pcspk_init.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/audio/pcspk.h | 6 +-
 hw/audio/pcspk.c | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h
index 8b485602675f..06cba00b8376 100644
--- a/include/hw/audio/pcspk.h
+++ b/include/hw/audio/pcspk.h
@@ -33,11 +33,7 @@
 
 static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
 {
-DeviceState *dev;
-
-dev = DEVICE(isadev);
-qdev_prop_set_uint32(dev, "iobase", 0x61);
-object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
+object_property_set_link(OBJECT(isadev), OBJECT(pit), "pit", NULL);
 isa_realize_and_unref(isadev, bus, _fatal);
 }
 
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 4c7e339ac2b5..ea539e7605a8 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -219,7 +219,7 @@ static const VMStateDescription vmstate_spk = {
 
 static Property pcspk_properties[] = {
 DEFINE_AUDIO_PROPERTIES(PCSpkState, card),
-DEFINE_PROP_UINT32("iobase", PCSpkState, iobase,  -1),
+DEFINE_PROP_UINT32("iobase", PCSpkState, iobase,  0x61),
 DEFINE_PROP_BOOL("migrate", PCSpkState, migrate,  true),
 DEFINE_PROP_END_OF_LIST(),
 };
-- 
2.18.4



[PATCH v5 10/20] audio: deprecate -soundhw hda

2020-07-02 Thread Gerd Hoffmann
Add deprecation message to the audio init function.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/intel-hda.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index f673b8317a84..f6cea49686d7 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -25,6 +25,7 @@
 #include "qemu/bitops.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qemu/error-report.h"
 #include "hw/audio/soundhw.h"
 #include "intel-hda.h"
 #include "migration/vmstate.h"
@@ -1307,6 +1308,8 @@ static int intel_hda_and_codec_init(PCIBus *bus)
 BusState *hdabus;
 DeviceState *codec;
 
+warn_report("'-soundhw hda' is deprecated, "
+"please use '-device intel-hda -device hda-duplex' instead");
 controller = DEVICE(pci_create_simple(bus, -1, "intel-hda"));
 hdabus = QLIST_FIRST(>child_bus);
 codec = qdev_new("hda-duplex");
-- 
2.18.4



[PATCH v5 01/20] stubs: add isa_create_simple

2020-07-02 Thread Gerd Hoffmann
Needed for -soundhw cleanup.

Signed-off-by: Gerd Hoffmann 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
---
 stubs/isa-bus.c | 7 +++
 stubs/Makefile.objs | 1 +
 2 files changed, 8 insertions(+)
 create mode 100644 stubs/isa-bus.c

diff --git a/stubs/isa-bus.c b/stubs/isa-bus.c
new file mode 100644
index ..522f448997d4
--- /dev/null
+++ b/stubs/isa-bus.c
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "hw/isa/isa.h"
+
+ISADevice *isa_create_simple(ISABus *bus, const char *name)
+{
+g_assert_not_reached();
+}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index f32b9e47a3d8..ff0411d21f22 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -8,6 +8,7 @@ stub-obj-y += fdset.o
 stub-obj-y += gdbstub.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
+stub-obj-y += isa-bus.o
 stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
 stub-obj-y += monitor-core.o
-- 
2.18.4



[PATCH v5 17/20] audio: deprecate -soundhw pcspk

2020-07-02 Thread Gerd Hoffmann
Add deprecation message to the audio init function.

Factor out audio initialization and call that from
both audio init and realize, so setting the audiodev
property is enough to properly initialize pcspk.

Add a property alias to the machine type to set the
audio device, so pcspk can be initialized using:
"-machine pcspk-audiodev="

Using "-global isa-pcspk.audiodev=" works too but
is not recommended.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/pcspk.c | 24 +---
 hw/i386/pc.c |  2 ++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index c37a3878612e..4c7e339ac2b5 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -28,6 +28,7 @@
 #include "audio/audio.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
+#include "qemu/error-report.h"
 #include "hw/timer/i8254.h"
 #include "migration/vmstate.h"
 #include "hw/audio/pcspk.h"
@@ -112,11 +113,15 @@ static void pcspk_callback(void *opaque, int free)
 }
 }
 
-static int pcspk_audio_init(ISABus *bus)
+static int pcspk_audio_init(PCSpkState *s)
 {
-PCSpkState *s = pcspk_state;
 struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0};
 
+if (s->voice) {
+/* already initialized */
+return 0;
+}
+
 AUD_register_card(s_spk, >card);
 
 s->voice = AUD_open_out(>card, s->voice, s_spk, s, pcspk_callback, );
@@ -185,6 +190,10 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
 
 isa_register_ioport(isadev, >ioport, s->iobase);
 
+if (s->card.state) {
+pcspk_audio_init(s);
+}
+
 pcspk_state = s;
 }
 
@@ -236,9 +245,18 @@ static const TypeInfo pcspk_info = {
 .class_init = pcspk_class_initfn,
 };
 
+static int pcspk_audio_init_soundhw(ISABus *bus)
+{
+PCSpkState *s = pcspk_state;
+
+warn_report("'-soundhw pcspk' is deprecated, "
+"please set a backend using '-machine pcspk-audiodev=' 
instead");
+return pcspk_audio_init(s);
+}
+
 static void pcspk_register(void)
 {
 type_register_static(_info);
-isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
+isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init_soundhw);
 }
 type_init(pcspk_register)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 88785f9dcc70..c45e7bfd864b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1892,6 +1892,8 @@ static void pc_machine_initfn(Object *obj)
 
 pc_system_flash_create(pcms);
 pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
+object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
+  OBJECT(pcms->pcspk), "audiodev");
 }
 
 static void pc_machine_reset(MachineState *machine)
-- 
2.18.4



[PATCH v5 13/20] pc_basic_device_init: drop no_vmport arg

2020-07-02 Thread Gerd Hoffmann
Now that we pass pcms anyway, we don't need the no_vmport arg any more.
No functional change.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/pc.h | 1 -
 hw/i386/pc.c | 3 +--
 hw/i386/pc_piix.c| 1 -
 hw/i386/pc_q35.c | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index bd447e380b5e..d7690bf4290f 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -164,7 +164,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
   ISABus *isa_bus, qemu_irq *gsi,
   ISADevice **rtc_state,
   bool create_fdctrl,
-  bool no_vmport,
   uint32_t hpet_irqs);
 void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(PCMachineState *pcms,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 9f5153b6f24d..407c782b5d42 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1159,7 +1159,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
   ISABus *isa_bus, qemu_irq *gsi,
   ISADevice **rtc_state,
   bool create_fdctrl,
-  bool no_vmport,
   uint32_t hpet_irqs)
 {
 int i;
@@ -1226,7 +1225,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
 i8257_dma_init(isa_bus, 0);
 
 /* Super I/O */
-pc_superio_init(isa_bus, create_fdctrl, no_vmport);
+pc_superio_init(isa_bus, create_fdctrl, pcms->vmport != ON_OFF_AUTO_ON);
 }
 
 void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 6c1612d0ca45..1ef3f39c55a5 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -236,7 +236,6 @@ static void pc_init1(MachineState *machine,
 
 /* init basic PC hardware */
 pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, true,
- (pcms->vmport != ON_OFF_AUTO_ON),
  0x4);
 
 pc_nic_init(pcmc, isa_bus, pci_bus);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6faf4458549a..5f8f21b84093 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -276,7 +276,6 @@ static void pc_q35_init(MachineState *machine)
 
 /* init basic PC hardware */
 pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, !mc->no_floppy,
- (pcms->vmport != ON_OFF_AUTO_ON),
  0xff0104);
 
 /* connect pm stuff to lpc */
-- 
2.18.4



[PATCH v5 15/20] audio: rework pcspk_init()

2020-07-02 Thread Gerd Hoffmann
Instead of creating and returning the pc speaker accept it as argument.
That allows to rework the initialization workflow in followup patches.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/audio/pcspk.h | 6 +-
 hw/i386/pc.c | 2 +-
 hw/isa/i82378.c  | 2 +-
 hw/mips/jazz.c   | 2 +-
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h
index 7e7f5f49dcb0..8b485602675f 100644
--- a/include/hw/audio/pcspk.h
+++ b/include/hw/audio/pcspk.h
@@ -31,18 +31,14 @@
 
 #define TYPE_PC_SPEAKER "isa-pcspk"
 
-static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
+static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
 {
 DeviceState *dev;
-ISADevice *isadev;
 
-isadev = isa_new(TYPE_PC_SPEAKER);
 dev = DEVICE(isadev);
 qdev_prop_set_uint32(dev, "iobase", 0x61);
 object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
 isa_realize_and_unref(isadev, bus, _fatal);
-
-return isadev;
 }
 
 #endif /* HW_PCSPK_H */
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 407c782b5d42..4fc1b7048b28 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1219,7 +1219,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
 /* connect PIT to output control line of the HPET */
 qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
 }
-pcspk_init(isa_bus, pit);
+pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
 }
 
 i8257_dma_init(isa_bus, 0);
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index d9e6c7fa0096..75a2da288157 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -102,7 +102,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
 pit = i8254_pit_init(isabus, 0x40, 0, NULL);
 
 /* speaker */
-pcspk_init(isabus, pit);
+pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit);
 
 /* 2 82C37 (dma) */
 isa_create_simple(isabus, "i82374");
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index c3b0da60ccc1..0002bff69590 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -250,7 +250,7 @@ static void mips_jazz_init(MachineState *machine,
 isa_bus_irqs(isa_bus, i8259);
 i8257_dma_init(isa_bus, 0);
 pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
-pcspk_init(isa_bus, pit);
+pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
 
 /* Video card */
 switch (jazz_model) {
-- 
2.18.4



[PATCH v5 00/20] audio: deprecate -soundhw

2020-07-02 Thread Gerd Hoffmann
v2:
 - use g_assert_not_reached() for stubs.
 - add deprecation notice.

v3:
 - rebase to latest master.
 - adapt to armbru's device initialization changes.

v4:
 - reorder patches, drop temporary -global setup,
   go straight to -machine pcspk-audiodev= instead.
 - update error messages and documentation accordingly.

v5:
 - spell fixes (Eric).
 - fix mips build error.

Gerd Hoffmann (20):
  stubs: add isa_create_simple
  stubs: add pci_create_simple
  audio: add deprecated_register_soundhw
  audio: deprecate -soundhw ac97
  audio: deprecate -soundhw es1370
  audio: deprecate -soundhw adlib
  audio: deprecate -soundhw cs4231a
  audio: deprecate -soundhw gus
  audio: deprecate -soundhw sb16
  audio: deprecate -soundhw hda
  pc_basic_device_init: pass PCMachineState
  pc_basic_device_init: drop has_pit arg
  pc_basic_device_init: drop no_vmport arg
  softmmu: initialize spice and audio earlier
  audio: rework pcspk_init()
  audio: create pcspk device early
  audio: deprecate -soundhw pcspk
  audio: add soundhw deprecation notice
  pcspk: update docs/system/target-i386-desc.rst.inc
  audio: set default value for pcspk.iobase property

 include/hw/audio/pcspk.h | 12 ++--
 include/hw/audio/soundhw.h   |  2 ++
 include/hw/i386/pc.h |  6 +++---
 hw/audio/ac97.c  |  9 ++---
 hw/audio/adlib.c |  8 +---
 hw/audio/cs4231a.c   |  8 +---
 hw/audio/es1370.c|  9 ++---
 hw/audio/gus.c   |  8 +---
 hw/audio/intel-hda.c |  3 +++
 hw/audio/pcspk.c | 26 ++
 hw/audio/sb16.c  |  9 ++---
 hw/audio/soundhw.c   | 24 +++-
 hw/i386/pc.c | 14 --
 hw/i386/pc_piix.c|  3 +--
 hw/i386/pc_q35.c |  3 +--
 hw/isa/i82378.c  |  2 +-
 hw/mips/jazz.c   |  2 +-
 qdev-monitor.c   |  2 ++
 softmmu/vl.c | 12 ++--
 stubs/isa-bus.c  |  7 +++
 stubs/pci-bus.c  |  7 +++
 docs/system/deprecated.rst   |  9 +
 docs/system/target-i386-desc.rst.inc | 13 -
 stubs/Makefile.objs  |  2 ++
 24 files changed, 121 insertions(+), 79 deletions(-)
 create mode 100644 stubs/isa-bus.c
 create mode 100644 stubs/pci-bus.c

-- 
2.18.4



[PATCH v5 03/20] audio: add deprecated_register_soundhw

2020-07-02 Thread Gerd Hoffmann
Add helper function for -soundhw deprecation.  It can replace the
simple init functions which just call {isa,pci}_create_simple()
with a hardcoded type.  It also prints a deprecation message.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/audio/soundhw.h |  2 ++
 hw/audio/soundhw.c | 24 +++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/hw/audio/soundhw.h b/include/hw/audio/soundhw.h
index c8eef8241846..f09a297854af 100644
--- a/include/hw/audio/soundhw.h
+++ b/include/hw/audio/soundhw.h
@@ -6,6 +6,8 @@ void isa_register_soundhw(const char *name, const char *descr,
 
 void pci_register_soundhw(const char *name, const char *descr,
   int (*init_pci)(PCIBus *bus));
+void deprecated_register_soundhw(const char *name, const char *descr,
+ int isa, const char *typename);
 
 void soundhw_init(void);
 void select_soundhw(const char *optarg);
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
index c750473c8f0c..173b674ff53a 100644
--- a/hw/audio/soundhw.c
+++ b/hw/audio/soundhw.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/option.h"
 #include "qemu/help_option.h"
 #include "qemu/error-report.h"
 #include "qom/object.h"
@@ -32,6 +33,7 @@
 struct soundhw {
 const char *name;
 const char *descr;
+const char *typename;
 int enabled;
 int isa;
 union {
@@ -65,6 +67,17 @@ void pci_register_soundhw(const char *name, const char 
*descr,
 soundhw_count++;
 }
 
+void deprecated_register_soundhw(const char *name, const char *descr,
+ int isa, const char *typename)
+{
+assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+soundhw[soundhw_count].name = name;
+soundhw[soundhw_count].descr = descr;
+soundhw[soundhw_count].isa = isa;
+soundhw[soundhw_count].typename = typename;
+soundhw_count++;
+}
+
 void select_soundhw(const char *optarg)
 {
 struct soundhw *c;
@@ -136,7 +149,16 @@ void soundhw_init(void)
 
 for (c = soundhw; c->name; ++c) {
 if (c->enabled) {
-if (c->isa) {
+if (c->typename) {
+warn_report("'-soundhw %s' is deprecated, "
+"please use '-device %s' instead",
+c->name, c->typename);
+if (c->isa) {
+isa_create_simple(isa_bus, c->typename);
+} else {
+pci_create_simple(pci_bus, -1, c->typename);
+}
+} else if (c->isa) {
 if (!isa_bus) {
 error_report("ISA bus not available for %s", c->name);
 exit(1);
-- 
2.18.4



[PATCH v5 14/20] softmmu: initialize spice and audio earlier

2020-07-02 Thread Gerd Hoffmann
audiodev must be initialized before machine_set_property
so the machine can have audiodev property aliases.

spice must initialize before audiodev because the default
audiodev is spice only in case spice is actually enabled.

Signed-off-by: Gerd Hoffmann 
---
 softmmu/vl.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 3e15ee243572..8ee91219060a 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4131,12 +4131,17 @@ void qemu_init(int argc, char **argv, char **envp)
   fsdev_init_func, NULL, _fatal);
 #endif
 
+/* spice needs the timers to be initialized by this point */
+/* spice must initialize before audio as it changes the default auiodev */
+qemu_spice_init();
+
 /*
- * Note: we need to create block backends before
+ * Note: we need to create audio and block backends before
  * machine_set_property(), so machine properties can refer to
  * them.
  */
 configure_blockdev(_queue, machine_class, snapshot);
+audio_init_audiodevs();
 
 machine_opts = qemu_get_machine_opts();
 qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
@@ -4230,9 +4235,6 @@ void qemu_init(int argc, char **argv, char **envp)
 semihosting_arg_fallback(kernel_filename, kernel_cmdline);
 }
 
-/* spice needs the timers to be initialized by this point */
-qemu_spice_init();
-
 cpu_ticks_init();
 
 if (default_net) {
@@ -4342,8 +4344,6 @@ void qemu_init(int argc, char **argv, char **envp)
 create_default_memdev(current_machine, mem_path);
 }
 
-audio_init_audiodevs();
-
 /* from here on runstate is RUN_STATE_PRELAUNCH */
 machine_run_board_init(current_machine);
 
-- 
2.18.4



[PATCH v5 04/20] audio: deprecate -soundhw ac97

2020-07-02 Thread Gerd Hoffmann
Switch to deprecated_register_soundhw().  Remove the now obsolete init
function.  Add an alias so both ac97 and AC97 are working with -device.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/ac97.c | 9 ++---
 qdev-monitor.c  | 1 +
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 8a9b9924c495..38522cf0ba44 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -1393,12 +1393,6 @@ static void ac97_exit(PCIDevice *dev)
 AUD_remove_card(>card);
 }
 
-static int ac97_init (PCIBus *bus)
-{
-pci_create_simple(bus, -1, TYPE_AC97);
-return 0;
-}
-
 static Property ac97_properties[] = {
 DEFINE_AUDIO_PROPERTIES(AC97LinkState, card),
 DEFINE_PROP_END_OF_LIST (),
@@ -1436,7 +1430,8 @@ static const TypeInfo ac97_info = {
 static void ac97_register_types (void)
 {
 type_register_static (_info);
-pci_register_soundhw("ac97", "Intel 82801AA AC97 Audio", ac97_init);
+deprecated_register_soundhw("ac97", "Intel 82801AA AC97 Audio",
+0, TYPE_AC97);
 }
 
 type_init (ac97_register_types)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 22da107484c5..105d9792ecdf 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -53,6 +53,7 @@ typedef struct QDevAlias
 
 /* Please keep this table sorted by typename. */
 static const QDevAlias qdev_alias_table[] = {
+{ "AC97", "ac97" }, /* -soundhw name */
 { "e1000", "e1000-82540em" },
 { "ich9-ahci", "ahci" },
 { "lsi53c895a", "lsi" },
-- 
2.18.4



[PATCH v5 11/20] pc_basic_device_init: pass PCMachineState

2020-07-02 Thread Gerd Hoffmann
Need access to pcms for pcspk initialization.
Just preparation, no functional change.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/pc.h | 3 ++-
 hw/i386/pc.c | 3 ++-
 hw/i386/pc_piix.c| 2 +-
 hw/i386/pc_q35.c | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index dce1273c7dad..3a601dbe71da 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -160,7 +160,8 @@ void pc_memory_init(PCMachineState *pcms,
 MemoryRegion **ram_memory);
 uint64_t pc_pci_hole64_start(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
-void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
+void pc_basic_device_init(struct PCMachineState *pcms,
+  ISABus *isa_bus, qemu_irq *gsi,
   ISADevice **rtc_state,
   bool create_fdctrl,
   bool no_vmport,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4af9679d039b..d89e577f6fa1 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1155,7 +1155,8 @@ static void pc_superio_init(ISABus *isa_bus, bool 
create_fdctrl, bool no_vmport)
 g_free(a20_line);
 }
 
-void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
+void pc_basic_device_init(struct PCMachineState *pcms,
+  ISABus *isa_bus, qemu_irq *gsi,
   ISADevice **rtc_state,
   bool create_fdctrl,
   bool no_vmport,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1d832b2878b1..a3b416507286 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -235,7 +235,7 @@ static void pc_init1(MachineState *machine,
 }
 
 /* init basic PC hardware */
-pc_basic_device_init(isa_bus, x86ms->gsi, _state, true,
+pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, true,
  (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
  0x4);
 
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 047ea8db28ea..b16e22c6cccd 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -275,7 +275,7 @@ static void pc_q35_init(MachineState *machine)
 }
 
 /* init basic PC hardware */
-pc_basic_device_init(isa_bus, x86ms->gsi, _state, !mc->no_floppy,
+pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, !mc->no_floppy,
  (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
  0xff0104);
 
-- 
2.18.4



[PATCH v5 08/20] audio: deprecate -soundhw gus

2020-07-02 Thread Gerd Hoffmann
Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/gus.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index c8df2bde6b32..7e4a8cadad6f 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -286,12 +286,6 @@ static void gus_realizefn (DeviceState *dev, Error **errp)
 AUD_set_active_out (s->voice, 1);
 }
 
-static int GUS_init (ISABus *bus)
-{
-isa_create_simple (bus, TYPE_GUS);
-return 0;
-}
-
 static Property gus_properties[] = {
 DEFINE_AUDIO_PROPERTIES(GUSState, card),
 DEFINE_PROP_UINT32 ("freq",GUSState, freq,44100),
@@ -322,7 +316,7 @@ static const TypeInfo gus_info = {
 static void gus_register_types (void)
 {
 type_register_static (_info);
-isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init);
+deprecated_register_soundhw("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS);
 }
 
 type_init (gus_register_types)
-- 
2.18.4



[PATCH v5 12/20] pc_basic_device_init: drop has_pit arg

2020-07-02 Thread Gerd Hoffmann
Now that we pass pcms anyway, we don't need the has_pit arg any more.
No functional change.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/pc.h | 1 -
 hw/i386/pc.c | 3 +--
 hw/i386/pc_piix.c| 2 +-
 hw/i386/pc_q35.c | 2 +-
 4 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 3a601dbe71da..bd447e380b5e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -165,7 +165,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
   ISADevice **rtc_state,
   bool create_fdctrl,
   bool no_vmport,
-  bool has_pit,
   uint32_t hpet_irqs);
 void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(PCMachineState *pcms,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index d89e577f6fa1..9f5153b6f24d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1160,7 +1160,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
   ISADevice **rtc_state,
   bool create_fdctrl,
   bool no_vmport,
-  bool has_pit,
   uint32_t hpet_irqs)
 {
 int i;
@@ -1211,7 +1210,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
 
 qemu_register_boot_set(pc_boot_set, *rtc_state);
 
-if (!xen_enabled() && has_pit) {
+if (!xen_enabled() && pcms->pit_enabled) {
 if (kvm_pit_in_kernel()) {
 pit = kvm_pit_init(isa_bus, 0x40);
 } else {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a3b416507286..6c1612d0ca45 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -236,7 +236,7 @@ static void pc_init1(MachineState *machine,
 
 /* init basic PC hardware */
 pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, true,
- (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
+ (pcms->vmport != ON_OFF_AUTO_ON),
  0x4);
 
 pc_nic_init(pcmc, isa_bus, pci_bus);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index b16e22c6cccd..6faf4458549a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -276,7 +276,7 @@ static void pc_q35_init(MachineState *machine)
 
 /* init basic PC hardware */
 pc_basic_device_init(pcms, isa_bus, x86ms->gsi, _state, !mc->no_floppy,
- (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
+ (pcms->vmport != ON_OFF_AUTO_ON),
  0xff0104);
 
 /* connect pm stuff to lpc */
-- 
2.18.4



[PATCH v5 07/20] audio: deprecate -soundhw cs4231a

2020-07-02 Thread Gerd Hoffmann
Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/cs4231a.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index ffdbb58d6a11..59705a8d4701 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -683,12 +683,6 @@ static void cs4231a_realizefn (DeviceState *dev, Error 
**errp)
 AUD_register_card ("cs4231a", >card);
 }
 
-static int cs4231a_init (ISABus *bus)
-{
-isa_create_simple (bus, TYPE_CS4231A);
-return 0;
-}
-
 static Property cs4231a_properties[] = {
 DEFINE_AUDIO_PROPERTIES(CSState, card),
 DEFINE_PROP_UINT32 ("iobase",  CSState, port, 0x534),
@@ -720,7 +714,7 @@ static const TypeInfo cs4231a_info = {
 static void cs4231a_register_types (void)
 {
 type_register_static (_info);
-isa_register_soundhw("cs4231a", "CS4231A", cs4231a_init);
+deprecated_register_soundhw("cs4231a", "CS4231A", 1, TYPE_CS4231A);
 }
 
 type_init (cs4231a_register_types)
-- 
2.18.4



[PATCH v5 16/20] audio: create pcspk device early

2020-07-02 Thread Gerd Hoffmann
Create the pcspk device early, so it exists at
machine type initialization time.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/pc.h | 1 +
 hw/i386/pc.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index d7690bf4290f..a802e699749a 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -33,6 +33,7 @@ struct PCMachineState {
 PCIBus *bus;
 I2CBus *smbus;
 PFlashCFI01 *flash[2];
+ISADevice *pcspk;
 
 /* Configuration options: */
 uint64_t max_ram_below_4g;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4fc1b7048b28..88785f9dcc70 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1219,7 +1219,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
 /* connect PIT to output control line of the HPET */
 qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
 }
-pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
+pcspk_init(pcms->pcspk, isa_bus, pit);
 }
 
 i8257_dma_init(isa_bus, 0);
@@ -1891,6 +1891,7 @@ static void pc_machine_initfn(Object *obj)
 pcms->pit_enabled = true;
 
 pc_system_flash_create(pcms);
+pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
 }
 
 static void pc_machine_reset(MachineState *machine)
-- 
2.18.4



[PATCH v5 18/20] audio: add soundhw deprecation notice

2020-07-02 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 docs/system/deprecated.rst | 9 +
 1 file changed, 9 insertions(+)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 843ae71fc618..6aa492b45006 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -82,6 +82,15 @@ should specify an ``audiodev=`` property.  Additionally, 
when using
 vnc, you should specify an ``audiodev=`` propery if you plan to
 transmit audio through the VNC protocol.
 
+Creating sound card devices using ``-soundhw`` (since 5.1)
+''
+
+Sound card devices should be created using ``-device`` instead.  The
+names are the same for most devices.  The exceptions are ``hda`` which
+needs two devices (``-device intel-hda -device hda-duplex``) and
+``pcspk`` which can be activated using ``-machine
+pcspk-audiodev=``.
+
 ``-mon ...,control=readline,pretty=on|off`` (since 4.1)
 '''
 
-- 
2.18.4



[PATCH v5 06/20] audio: deprecate -soundhw adlib

2020-07-02 Thread Gerd Hoffmann
Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

Signed-off-by: Gerd Hoffmann 
---
 hw/audio/adlib.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
index 7c3b67dcfb8c..65dff5b6fca4 100644
--- a/hw/audio/adlib.c
+++ b/hw/audio/adlib.c
@@ -319,16 +319,10 @@ static const TypeInfo adlib_info = {
 .class_init= adlib_class_initfn,
 };
 
-static int Adlib_init (ISABus *bus)
-{
-isa_create_simple (bus, TYPE_ADLIB);
-return 0;
-}
-
 static void adlib_register_types (void)
 {
 type_register_static (_info);
-isa_register_soundhw("adlib", ADLIB_DESC, Adlib_init);
+deprecated_register_soundhw("adlib", ADLIB_DESC, 1, TYPE_ADLIB);
 }
 
 type_init (adlib_register_types)
-- 
2.18.4



Re: [libvirt PATCH] docs: Update CI documentation

2020-07-02 Thread Daniel P . Berrangé
On Thu, Jul 02, 2020 at 03:04:41PM +0200, Andrea Bolognani wrote:
> We're no longer using either Travis CI or the Jenkins-based
> CentOS CI, but we have started using Cirrus CI.
> 
> Mention the libvirt-ci subproject as well, as a pointer for those
> who might want to learn more about our CI infrastructure.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  docs/ci.rst | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)

Reviewed-by: Daniel P. Berrangé 


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



[libvirt PATCH] docs: Update CI documentation

2020-07-02 Thread Andrea Bolognani
We're no longer using either Travis CI or the Jenkins-based
CentOS CI, but we have started using Cirrus CI.

Mention the libvirt-ci subproject as well, as a pointer for those
who might want to learn more about our CI infrastructure.

Signed-off-by: Andrea Bolognani 
---
 docs/ci.rst | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/docs/ci.rst b/docs/ci.rst
index 2e88e06b1b..b321a67bd9 100644
--- a/docs/ci.rst
+++ b/docs/ci.rst
@@ -4,10 +4,14 @@ Libvirt Continuous Integration
 
 .. contents::
 
-The libvirt project primarily uses GitLab CI for automated testing of Linux
-builds, and cross-compiled Windows builds. `Travis 
`_
-is used for validating macOS builds, and `Jenkins 
`_
-is temporarily used for validating FreeBSD builds.
+The libvirt project uses GitLab CI for automated testing.
+
+Linux builds and cross-compiled Windows builds happen on GitLab CI's shared
+runners, while FreeBSD and macOS coverage is achieved by triggering `Cirrus CI
+`_ jobs behind the scenes.
+
+Most of the tooling used to build CI pipelines is maintained as part of the
+`libvirt-ci `_ subproject.
 
 GitLab CI Dashboard
 ===
-- 
2.25.4



Re: [libvirt PATCH] NEWS: Update for libvirt 6.5.0

2020-07-02 Thread Daniel P . Berrangé
On Thu, Jul 02, 2020 at 02:41:38PM +0200, Andrea Bolognani wrote:
> Signed-off-by: Andrea Bolognani 
> ---
>  NEWS.rst | 27 +++
>  1 file changed, 27 insertions(+)

Reviewed-by: Daniel P. Berrangé 


> 
> diff --git a/NEWS.rst b/NEWS.rst
> index 0e9822cd03..499711fb18 100644
> --- a/NEWS.rst
> +++ b/NEWS.rst
> @@ -47,8 +47,30 @@ v6.5.0 (unreleased)
>  alphabetical order. Hook script in old place will be executed
>  as first for backward compatibility.
>  
> +  * qemu: Add support for migratable host-passthrough CPU
> +
> +QEMU 2.12 made it possible for guests to use a migration-friendly
> +version of the host-passthrough CPU. This feature is now exposed by
> +libvirt.

Reminds me that we need to stop marking a guest as tainted for running
host-passthrough.  We should only mark tainted once the user triggers
migration, and when they're not using the migration-friendly variant.


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



[libvirt PATCH] NEWS: Update for libvirt 6.5.0

2020-07-02 Thread Andrea Bolognani
Signed-off-by: Andrea Bolognani 
---
 NEWS.rst | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/NEWS.rst b/NEWS.rst
index 0e9822cd03..499711fb18 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -47,8 +47,30 @@ v6.5.0 (unreleased)
 alphabetical order. Hook script in old place will be executed
 as first for backward compatibility.
 
+  * qemu: Add support for migratable host-passthrough CPU
+
+QEMU 2.12 made it possible for guests to use a migration-friendly
+version of the host-passthrough CPU. This feature is now exposed by
+libvirt.
+
 * **Improvements**
 
+  * network: Support NAT with IPv6
+
+It's now possible to use  in a libvirt network.
+
+  * qemu: Auto-fill NUMA information for incomplete topologies
+
+If the NUMA topology is not fully described in the guest XML, libvirt
+will complete it by putting all unspecified CPUs in the first NUMA node.
+This is only done in the QEMU binary itself supports disjointed CPU
+ranges for NUMA nodes.
+
+  * qemu: Assign hostdev-backed interfaces to PCIe slots
+
+All SR-IOV capable devices are PCIe, so when their VFs are assigned to
+guests they should end up in PCIe slots rather than conventional PCI ones.
+
 * **Bug fixes**
 
   * qemu: fixed crash in ``qemuDomainBlockCommit``
@@ -61,6 +83,11 @@ v6.5.0 (unreleased)
 Removes the correlation between the zPCI address attributes uid and fid.
 Fixes the validation and autogeneration of zPCI address attributes.
 
+  * qemu: Skip pre-creation of NVMe disks during migration
+
+libvirt has no way to create NVMe devices on the target host, so it now
+just makes sure they exist and let the migration proceed in that case.
+
 
 v6.4.0 (2020-06-02)
 ===
-- 
2.25.4



[libvirt PATCH 31/31] tools: wireshark: fix compilation errors

2020-07-02 Thread Pavel Hrdina
With meson introduction which is using the same CFLAGS for the whole
project some compilation errors were discovered.

Signed-off-by: Pavel Hrdina 
---
 tools/wireshark/src/packet-libvirt.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/wireshark/src/packet-libvirt.c 
b/tools/wireshark/src/packet-libvirt.c
index 20b7a3ec812..db8efe45a39 100644
--- a/tools/wireshark/src/packet-libvirt.c
+++ b/tools/wireshark/src/packet-libvirt.c
@@ -77,15 +77,15 @@ static gint ett_libvirt_stream_hole = -1;
 
 XDR_PRIMITIVE_DISSECTOR(int, gint32,  int)
 XDR_PRIMITIVE_DISSECTOR(u_int,   guint32, uint)
-XDR_PRIMITIVE_DISSECTOR(short,   gint16,  int)
+//XDR_PRIMITIVE_DISSECTOR(short,   gint16,  int)
 XDR_PRIMITIVE_DISSECTOR(u_short, guint16, uint)
 XDR_PRIMITIVE_DISSECTOR(char,gchar,   int)
 XDR_PRIMITIVE_DISSECTOR(u_char,  guchar,  uint)
 XDR_PRIMITIVE_DISSECTOR(hyper,   gint64,  int64)
 XDR_PRIMITIVE_DISSECTOR(u_hyper, guint64, uint64)
-XDR_PRIMITIVE_DISSECTOR(float,   gfloat,  float)
+//XDR_PRIMITIVE_DISSECTOR(float,   gfloat,  float)
 XDR_PRIMITIVE_DISSECTOR(double,  gdouble, double)
-XDR_PRIMITIVE_DISSECTOR(bool,bool_t,  boolean)
+//XDR_PRIMITIVE_DISSECTOR(bool,bool_t,  boolean)
 
 typedef gboolean (*vir_xdr_dissector_t)(tvbuff_t *tvb, proto_tree *tree, XDR 
*xdrs, int hf);
 
@@ -345,7 +345,9 @@ dissect_libvirt_num_of_fds(tvbuff_t *tvb, proto_tree *tree)
 }
 
 static void
-dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
+dissect_libvirt_fds(tvbuff_t *tvb G_GNUC_UNUSED,
+gint start G_GNUC_UNUSED,
+gint32 nfds G_GNUC_UNUSED)
 {
 /* TODO: NOP for now */
 }
@@ -420,8 +422,13 @@ dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
 return; /* No payload */
 
 if (status == VIR_NET_OK) {
-vir_xdr_dissector_t xd = find_payload_dissector(proc, type, 
get_program_data(prog, VIR_PROGRAM_DISSECTORS),
-*(gsize 
*)get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN));
+const vir_dissector_index_t *pds = get_program_data(prog, 
VIR_PROGRAM_DISSECTORS);
+const gsize *len = get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN);
+
+if (!len)
+goto unknown;
+
+vir_xdr_dissector_t xd = find_payload_dissector(proc, type, pds, *len);
 if (xd == NULL)
 goto unknown;
 dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, 
xd);
-- 
2.26.2



[libvirt PATCH 19/31] src: Makefile: remove LOCK_CHECKING_CFLAGS leftover

2020-07-02 Thread Pavel Hrdina
Commit  removed objectlocking
test but forgot to remove all of the usages of LOCK_CHECKING_CFLAGS.

Signed-off-by: Pavel Hrdina 
---
 src/Makefile.am | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index e1117029ebc..834e356b68b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,7 +32,6 @@ AM_CPPFLAGS = -I$(top_srcdir) \
 AM_CFLAGS =$(LIBXML_CFLAGS) \
$(GLIB_CFLAGS) \
$(WARN_CFLAGS) \
-   $(LOCK_CHECKING_CFLAGS) \
$(WIN32_EXTRA_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(NULL)
-- 
2.26.2



[libvirt PATCH 26/31] src: remote: Makefile: properly format sysconfdir in virtproxyd.conf

2020-07-02 Thread Pavel Hrdina
Commit <5b816e16968ba02def56f067774ecd9a8c8d44d7> removed hard-coded
sysconfdir path from *.conf files but missed virtproxyd.

Signed-off-by: Pavel Hrdina 
---
 src/remote/Makefile.inc.am | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 893d6894e2f..80f4aad7828 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -276,6 +276,7 @@ remote/virtproxyd.conf: remote/libvirtd.conf.in
$(AM_V_GEN)sed \
-e '/[@]CUT_ENABLE_IP[@]/d' \
-e '/[@]END[@]/d' \
+   -e 's|[@]sysconfdir[@]|@sysconfdir@|' \
-e 's|[@]runstatedir[@]|@runstatedir@|' \
-e 's/[@]DAEMON_NAME[@]/virtproxyd/' \
$< > $@
@@ -301,6 +302,7 @@ remote/virtproxyd.aug: remote/libvirtd.aug.in
$(AM_V_GEN)$(SED) \
-e '/[@]CUT_ENABLE_IP[@]/d' \
-e '/[@]END[@]/d' \
+   -e 's|[@]sysconfdir[@]|@sysconfdir@|' \
-e 's/[@]DAEMON_NAME[@]/virtproxyd/' \
-e 's/[@]DAEMON_NAME_UC[@]/Virtproxyd/' \
$< > $@
@@ -325,6 +327,7 @@ remote/test_virtproxyd.aug: remote/test_libvirtd.aug.in \
$(SED) \
-e '/[@]CUT_ENABLE_IP[@]/d' \
-e '/[@]END[@]/d' \
+   -e 's|[@]sysconfdir[@]|@sysconfdir@|' \
-e 's|[@]runstatedir[@]|@runstatedir@|' \
-e 's/[@]DAEMON_NAME[@]/virtproxyd/' \
-e 's/[@]DAEMON_NAME_UC[@]/Virtproxyd/' \
-- 
2.26.2



[libvirt PATCH 28/31] tests: commandhelper: change how we detect if running as daemon

2020-07-02 Thread Pavel Hrdina
The old code works correctly with make and running directly from shell
but it failed with Meson test suite where session ID and process group
are the same in both cases.

What changes in both cases is parent process ID so use that instead of
session ID.

Signed-off-by: Pavel Hrdina 
---
 tests/commandhelper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 3f040be8f22..4266e11902f 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -126,7 +126,7 @@ int main(int argc, char **argv) {
 fprintf(log, "FD:%zu\n", i);
 }
 
-fprintf(log, "DAEMON:%s\n", getpgrp() == getsid(0) ? "yes" : "no");
+fprintf(log, "DAEMON:%s\n", getpgrp() != getppid() ? "yes" : "no");
 if (!(cwd = getcwd(NULL, 0)))
 goto cleanup;
 if (strlen(cwd) > strlen(".../commanddata") &&
-- 
2.26.2



[libvirt PATCH 11/31] m4: virt-sanlock: drop check for SANLK_INQ_WAIT

2020-07-02 Thread Pavel Hrdina
SANLK_INQ_WAIT was introduced in sanlock 2.4 which is available in all
supported OSes.

Signed-off-by: Pavel Hrdina 
---
 m4/virt-sanlock.m4| 9 -
 src/locking/lock_driver_sanlock.c | 6 --
 2 files changed, 15 deletions(-)

diff --git a/m4/virt-sanlock.m4 b/m4/virt-sanlock.m4
index a7fba520dfc..15a9bc6035f 100644
--- a/m4/virt-sanlock.m4
+++ b/m4/virt-sanlock.m4
@@ -25,15 +25,6 @@ AC_DEFUN([LIBVIRT_CHECK_SANLOCK],[
   LIBVIRT_CHECK_PKG([SANLOCK], [libsanlock_client], [3.2.4])
 
   if test "x$with_sanlock" = "xyes" ; then
-AC_CHECK_DECLS([SANLK_INQ_WAIT], [sanlock_inq_wait=1], 
[sanlock_inq_wait=0], [[
-  #include 
-  #include 
-]])
-if test sanlock_inq_wait = 1; then
-  AC_DEFINE_UNQUOTED([HAVE_SANLK_INQ_WAIT], 1,
-[whether sanlock supports SANLK_INQ_WAIT])
-fi
-
 old_cppflags="$CPPFLAGS"
 old_libs="$LIBS"
 CPPFLAGS="$CPPFLAGS $SANLOCK_CFLAGS"
diff --git a/src/locking/lock_driver_sanlock.c 
b/src/locking/lock_driver_sanlock.c
index ea1c23eab69..cc8266a2b35 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -361,18 +361,12 @@ 
virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
 #endif
 if (rv < 0) {
 if (-rv == EINPROGRESS && --retries) {
-#ifdef HAVE_SANLK_INQ_WAIT
 /* we have this function which blocks until lockspace change the
  * state. It returns 0 if lockspace has been added, -ENOENT if it
  * hasn't. */
 VIR_DEBUG("Inquiring lockspace");
 if (sanlock_inq_lockspace(, SANLK_INQ_WAIT) < 0)
 VIR_DEBUG("Unable to inquire lockspace");
-#else
-/* fall back to polling */
-VIR_DEBUG("Sleeping for %dms", LOCKSPACE_SLEEP);
-g_usleep(LOCKSPACE_SLEEP * 1000);
-#endif
 VIR_DEBUG("Retrying to add lockspace (left %d)", retries);
 goto retry;
 }
-- 
2.26.2



[libvirt PATCH 16/31] m4: virt-xdr: rewrite XDR check

2020-07-02 Thread Pavel Hrdina
The current code to check XDR support was obsolete and way to
complicated.

On linux we can use pkg-config to check for libtirpc and have
the CFLAGS and LIBS configured by it as well.

On MinGW there is portablexdr library which installs header files
directly into system include directory.

On FreeBSD and macOS XDR functions are part of libc so there is
no library needed, we just need to call AM_CONDITIONAL to silence
configure which otherwise complains about missing WITH_XDR.

Signed-off-by: Pavel Hrdina 
---
 m4/virt-xdr.m4  | 39 +++--
 src/Makefile.am |  4 +++-
 src/admin/Makefile.inc.am   |  1 +
 src/locking/Makefile.inc.am |  2 ++
 src/logging/Makefile.inc.am |  1 +
 src/remote/Makefile.inc.am  |  1 +
 6 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/m4/virt-xdr.m4 b/m4/virt-xdr.m4
index 83754157d9a..09d0c2ba2f4 100644
--- a/m4/virt-xdr.m4
+++ b/m4/virt-xdr.m4
@@ -18,37 +18,20 @@ dnl .
 dnl
 
 AC_DEFUN([LIBVIRT_CHECK_XDR], [
-  with_xdr="no"
   if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then
-dnl Where are the XDR functions?
-dnl If portablexdr is installed, prefer that.
-dnl Otherwise try -lxdr (some MinGW)
-dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix)
-AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
-  AC_SEARCH_LIBS([xdrmem_create],[xdr tirpc],[],
-[AC_MSG_ERROR([Cannot find a XDR library])])
-])
+dnl On MinGW portablexdr provides XDR functions, on linux they are
+dnl provided by libtirpc and on FreeBSD/macOS there is no need to
+dnl use extra library as it's provided by libc directly.
+
 with_xdr="yes"
 
-dnl Recent glibc requires -I/usr/include/tirpc for 
-old_CFLAGS=$CFLAGS
-AC_CACHE_CHECK([where to find ], [lv_cv_xdr_cflags], [
-  for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do
-if test x"$add_CFLAGS" = xmissing; then
-  lv_cv_xdr_cflags=missing; break
-fi
-CFLAGS="$old_CFLAGS $add_CFLAGS"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include 
-]])], [lv_cv_xdr_cflags=${add_CFLAGS:-none}; break])
-  done
-])
-CFLAGS=$old_CFLAGS
-case $lv_cv_xdr_cflags in
-  none) XDR_CFLAGS= ;;
-  missing) AC_MSG_ERROR([Unable to find ]) ;;
-  *) XDR_CFLAGS=$lv_cv_xdr_cflags ;;
-esac
-AC_SUBST([XDR_CFLAGS])
+if test "$with_win" = "yes"; then
+  LIBVIRT_CHECK_LIB([XDR], [portablexdr], [xdrmem_create], [rpc/rpc.h])
+elif test "$with_linux" = "yes"; then
+  LIBVIRT_CHECK_PKG([XDR], [libtirpc], [0.1.10])
+else
+  AM_CONDITIONAL([WITH_XDR], [test "x$with_xdr" = "xyes"])
+fi
   fi
 ])
 
diff --git a/src/Makefile.am b/src/Makefile.am
index b893f4179e8..8b0cbb6fc86 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -435,7 +435,9 @@ libvirt_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(NULL)
 libvirt_la_LIBADD += \
-   $(DLOPEN_LIBS)
+   $(DLOPEN_LIBS) \
+   $(XDR_LIBS) \
+   $(NULL)
 libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS)
 # Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we
 # lose automake's automatic dependencies on an appropriate subset of
diff --git a/src/admin/Makefile.inc.am b/src/admin/Makefile.inc.am
index 0a9717adec6..8556a3b8523 100644
--- a/src/admin/Makefile.inc.am
+++ b/src/admin/Makefile.inc.am
@@ -72,6 +72,7 @@ libvirt_admin_la_LDFLAGS = \
 
 libvirt_admin_la_LIBADD = \
libvirt.la \
+   $(XDR_LIBS) \
$(CAPNG_LIBS) \
$(YAJL_LIBS) \
$(DEVMAPPER_LIBS) \
diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am
index d1bf49cd3fb..ab01d8e0482 100644
--- a/src/locking/Makefile.inc.am
+++ b/src/locking/Makefile.inc.am
@@ -120,6 +120,7 @@ lockd_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
 lockd_la_LIBADD = \
libvirt.la \
$(GLIB_LIBS) \
+   $(XDR_LIBS) \
$(NULL)
 augeas_DATA += locking/libvirt_lockd.aug
 if WITH_DTRACE_PROBES
@@ -161,6 +162,7 @@ virtlockd_CFLAGS = \
 virtlockd_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
+   $(XDR_LIBS) \
$(NO_UNDEFINED_LDFLAGS) \
$(NULL)
 virtlockd_LDADD = \
diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am
index dc09cfe3fa8..4be33765e9e 100644
--- a/src/logging/Makefile.inc.am
+++ b/src/logging/Makefile.inc.am
@@ -99,6 +99,7 @@ virtlogd_CFLAGS = \
 virtlogd_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
+   $(XDR_LIBS) \
$(NO_UNDEFINED_LDFLAGS) \
$(NULL)
 virtlogd_LDADD = \
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 1b1be8340df..8a40c96563c 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -69,6 +69,7 @@ REMOTE_DAEMON_LD_ADD = \
$(LIBXML_LIBS) \
$(GNUTLS_LIBS) \
$(SASL_LIBS) \

[libvirt PATCH 09/31] m4: virt-sanlock: drop check for sanlock_inq_lockspace

2020-07-02 Thread Pavel Hrdina
This check was introduced by commit
<96a02703daad4dc6663165adbc0feade9900cebd> to guard calling
sanlock_inq_lockspace() function but it used SANLK_INQ_WAIT as a
parameter which was introduced later.  This was eventually fixed by
commit <238dba0f9c925359cb3b8beddd8c8ae739cb4e06>.

We can safely replace check for sanlock_inq_lockspace as that function
was introduced in sanlock-1.9.  The oldest used version, sanlock-2.2,
is by Ubuntu 16.04.

Signed-off-by: Pavel Hrdina 
---
 m4/virt-sanlock.m4| 12 
 src/locking/lock_driver_sanlock.c |  2 +-
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/m4/virt-sanlock.m4 b/m4/virt-sanlock.m4
index 00de7980e82..cc35b10b09f 100644
--- a/m4/virt-sanlock.m4
+++ b/m4/virt-sanlock.m4
@@ -29,6 +29,10 @@ AC_DEFUN([LIBVIRT_CHECK_SANLOCK],[
   #include 
   #include 
 ]])
+if test sanlock_inq_wait = 1; then
+  AC_DEFINE_UNQUOTED([HAVE_SANLK_INQ_WAIT], 1,
+[whether sanlock supports SANLK_INQ_WAIT])
+fi
 
 old_cppflags="$CPPFLAGS"
 old_libs="$LIBS"
@@ -42,14 +46,6 @@ AC_DEFUN([LIBVIRT_CHECK_SANLOCK],[
 [whether Sanlock supports sanlock_killpath])
 fi
 
-AC_CHECK_LIB([sanlock_client], [sanlock_inq_lockspace],
-   [sanlock_inq_lockspace=yes], [sanlock_inq_lockspace=no])
-if test "x$sanlock_inq_lockspace" = "xyes" && \
-   test $sanlock_inq_wait = 1; then
-  AC_DEFINE_UNQUOTED([HAVE_SANLOCK_INQ_LOCKSPACE], 1,
-[whether sanlock supports sanlock_inq_lockspace])
-fi
-
 dnl Ideally, we would check for sanlock_add_lockspace_timeout here too, but
 dnl sanlock_write_lockspace has been introduced 2 releases after
 dnl sanlock_add_lockspace_timeout therefore if sanlock_write_lockspace is 
found
diff --git a/src/locking/lock_driver_sanlock.c 
b/src/locking/lock_driver_sanlock.c
index 4ebe98e86db..ea1c23eab69 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -361,7 +361,7 @@ 
virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
 #endif
 if (rv < 0) {
 if (-rv == EINPROGRESS && --retries) {
-#ifdef HAVE_SANLOCK_INQ_LOCKSPACE
+#ifdef HAVE_SANLK_INQ_WAIT
 /* we have this function which blocks until lockspace change the
  * state. It returns 0 if lockspace has been added, -ENOENT if it
  * hasn't. */
-- 
2.26.2



[libvirt PATCH 08/31] docs: drop %.png: %.fig rule

2020-07-02 Thread Pavel Hrdina
convert bin is part of ImageMagick package and uses uniconvertor to
create png file from fig files.

Unfortunately uniconvertor is python2 only and not available in most
recent distributions which makes the convert command fail with:

sh: uniconvertor: command not found
/usr/bin/mv: cannot stat '/tmp/magick-1397138DRT8Pzx4Qmoc.svg': No such file or 
directory
convert: delegate failed `'uniconvertor' '%i' '%o.svg'; /usr/bin/mv '%o.svg' 
'%o'' @ error/delegate.c/InvokeDelegate/1958.
convert: unable to open file `/tmp/magick-1397138S8ARueJXLXkc': No such file or 
directory @ error/constitute.c/ReadImage/605.
convert: no images defined `docs/migration-managed-direct.png' @ 
error/convert.c/ConvertImageCommand/3226.

It looks like that there are plans to somehow port uniconvertor into
python3 but as part of different project color-picker but the job is
far from complete.

Signed-off-by: Pavel Hrdina 
---
 docs/Makefile.am | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/docs/Makefile.am b/docs/Makefile.am
index 07a7d7a369c..3fd8256e668 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -406,9 +406,6 @@ hvsupport.html.in: $(top_srcdir)/scripts/hvsupport.py 
$(api_DATA) \
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(top_srcdir)/scripts/hvsupport.py \
$(top_srcdir) $(top_builddir) > $@ || { rm $@ && exit 1; }
 
-%.png: %.fig
-   convert -rotate 90 $< $@
-
 manpages/%.html.in: manpages/%.rst
$(AM_V_GEN)$(MKDIR_P) `dirname $@` && \
 grep -v '^:Manual ' < $< | \
-- 
2.26.2



[libvirt PATCH 29/31] tests: use WITH_NSS instead of NSS

2020-07-02 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 m4/virt-nss.m4  | 2 +-
 tests/nssmock.c | 2 +-
 tests/nsstest.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/m4/virt-nss.m4 b/m4/virt-nss.m4
index 951a74e835b..b519c36e859 100644
--- a/m4/virt-nss.m4
+++ b/m4/virt-nss.m4
@@ -58,7 +58,7 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
 fi
 
 if test "x$with_nss_plugin" = "xyes" ; then
-  AC_DEFINE_UNQUOTED([NSS], 1, [whether nss plugin is enabled])
+  AC_DEFINE_UNQUOTED([WITH_NSS], 1, [whether nss plugin is enabled])
 
   AC_CHECK_TYPE([struct gaih_addrtuple],
 [AC_DEFINE([HAVE_STRUCT_GAIH_ADDRTUPLE], [1],
diff --git a/tests/nssmock.c b/tests/nssmock.c
index 62e8fa372a2..b1c1aba957a 100644
--- a/tests/nssmock.c
+++ b/tests/nssmock.c
@@ -18,7 +18,7 @@
 
 #include 
 
-#ifdef NSS
+#ifdef WITH_NSS
 # include "virmock.h"
 # include 
 # include 
diff --git a/tests/nsstest.c b/tests/nsstest.c
index 514b4f7195d..135f6b6c939 100644
--- a/tests/nsstest.c
+++ b/tests/nsstest.c
@@ -20,7 +20,7 @@
 
 #include "testutils.h"
 
-#ifdef NSS
+#ifdef WITH_NSS
 
 # include "libvirt_nss.h"
 # include "virsocket.h"
-- 
2.26.2



[libvirt PATCH 21/31] src: remote: Makefile: drop CFLAGS and LDFLAGS duplication

2020-07-02 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/remote/Makefile.inc.am | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 8a40c96563c..893d6894e2f 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -35,16 +35,13 @@ REMOTE_DAEMON_SOURCES = \
$(NULL)
 
 REMOTE_DAEMON_CFLAGS = \
-   $(LIBXML_CFLAGS) \
-   $(GLIB_CFLAGS) \
+   $(AM_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(SASL_CFLAGS) \
$(XDR_CFLAGS) \
$(DBUS_CFLAGS) \
$(LIBNL_CFLAGS) \
-   $(WARN_CFLAGS) \
$(PIE_CFLAGS) \
-   $(COVERAGE_CFLAGS) \
-I$(srcdir)/access \
-I$(builddir)/access \
-I$(srcdir)/conf \
@@ -54,11 +51,9 @@ REMOTE_DAEMON_CFLAGS = \
$(NULL)
 
 REMOTE_DAEMON_LD_FLAGS = \
-   $(RELRO_LDFLAGS) \
+   $(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
-   $(NO_INDIRECT_LDFLAGS) \
$(NO_UNDEFINED_LDFLAGS) \
-   $(COVERAGE_LDFLAGS) \
$(NULL)
 
 REMOTE_DAEMON_LD_ADD = \
-- 
2.26.2



[libvirt PATCH 04/31] configure: remove usage of AC_HEADER_MAJOR

2020-07-02 Thread Pavel Hrdina
Commit <03c532cf9711dd6ad35380455a77141ef7d492ab> removed usage of
MAJOR_IN_MKDEV and MAJOR_IN_SYSMACROS from libvirt which makes the
AC_HEADER_MAJOR useless.

Signed-off-by: Pavel Hrdina 
---
 configure.ac | 2 --
 1 file changed, 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 75695252898..f8d9038e4ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,8 +155,6 @@ AC_TYPE_UID_T
 dnl Support building Win32 DLLs (must appear *before* AM_PROG_LIBTOOL)
 AC_LIBTOOL_WIN32_DLL
 
-AC_HEADER_MAJOR
-
 m4_ifndef([LT_INIT], [
   AM_PROG_LIBTOOL
 ], [
-- 
2.26.2



[libvirt PATCH 25/31] src: util: Makefile: drop undefined OPENPTY_LIBS

2020-07-02 Thread Pavel Hrdina
Commit  added check for
openpty function from util library using AC_CHECK_LIB(). However, that
macro doesn't define OPENPTY_LIBS, it only defines WITH_LIBUTIL and
prepends -lutil into LIBS for the whole project.

Signed-off-by: Pavel Hrdina 
---
 src/util/Makefile.inc.am | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 5203fa28d48..eca7e7e0a1e 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -281,7 +281,6 @@ libvirt_util_la_CFLAGS = \
$(NULL)
 libvirt_util_la_LIBADD = \
-lm \
-   $(OPENPTY_LIBS) \
$(CAPNG_LIBS) \
$(YAJL_LIBS) \
$(LIBNL_LIBS) \
-- 
2.26.2



[libvirt PATCH 23/31] src: util: rename some program macros

2020-07-02 Thread Pavel Hrdina
Fixes inconsistency with macro names for external programs.

Signed-off-by: Pavel Hrdina 
---
 m4/virt-external-programs.m4|  8 
 src/util/virnetdevmidonet.c |  4 ++--
 src/util/virnetdevopenvswitch.c | 16 
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4
index bd3cb1f7576..d905beed71d 100644
--- a/m4/virt-external-programs.m4
+++ b/m4/virt-external-programs.m4
@@ -61,8 +61,8 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
   AC_PATH_PROG([UDEVADM], [udevadm], [udevadm], [$LIBVIRT_SBIN_PATH])
   AC_PATH_PROG([MODPROBE], [modprobe], [modprobe], [$LIBVIRT_SBIN_PATH])
   AC_PATH_PROG([RMMOD], [rmmod], [rmmod], [$LIBVIRT_SBIN_PATH])
-  AC_PATH_PROG([MMCTL], [mm-ctl], [mm-ctl], [$LIBVIRT_SBIN_PATH])
-  AC_PATH_PROG([OVSVSCTL], [ovs-vsctl], [ovs-vsctl], [$LIBVIRT_SBIN_PATH])
+  AC_PATH_PROG([MM_CTL], [mm-ctl], [mm-ctl], [$LIBVIRT_SBIN_PATH])
+  AC_PATH_PROG([OVS_VSCTL], [ovs-vsctl], [ovs-vsctl], [$LIBVIRT_SBIN_PATH])
   AC_PATH_PROG([SCRUB], [scrub], [scrub], [$LIBVIRT_SBIN_PATH])
   AC_PATH_PROG([ADDR2LINE], [addr2line], [addr2line], [$LIBVIRT_SBIN_PATH])
   AC_PATH_PROG([MDEVCTL], [mdevctl], [mdevctl], [$LIBVIRT_SBIN_PATH])
@@ -75,9 +75,9 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
  [Location or name of the radvd program])
   AC_DEFINE_UNQUOTED([TC], ["$TC"],
  [Location or name of the tc program (see iproute2)])
-  AC_DEFINE_UNQUOTED([MMCTL], ["$MMCTL"],
+  AC_DEFINE_UNQUOTED([MM_CTL], ["$MM_CTL"],
  [Location or name of the mm-ctl program])
-  AC_DEFINE_UNQUOTED([OVSVSCTL], ["$OVSVSCTL"],
+  AC_DEFINE_UNQUOTED([OVS_VSCTL], ["$OVS_VSCTL"],
  [Location or name of the ovs-vsctl program])
   AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
  [Location or name of the udevadm program])
diff --git a/src/util/virnetdevmidonet.c b/src/util/virnetdevmidonet.c
index 354350ce1b7..be1b6e8a457 100644
--- a/src/util/virnetdevmidonet.c
+++ b/src/util/virnetdevmidonet.c
@@ -45,7 +45,7 @@ virNetDevMidonetBindPort(const char *ifname,
 
 virUUIDFormat(virtualport->interfaceID, virtportuuid);
 
-cmd = virCommandNew(MMCTL);
+cmd = virCommandNew(MM_CTL);
 
 virCommandAddArgList(cmd, "--bind-port", virtportuuid, ifname, NULL);
 
@@ -79,7 +79,7 @@ virNetDevMidonetUnbindPort(const virNetDevVPortProfile 
*virtualport)
 
 virUUIDFormat(virtualport->interfaceID, virtportuuid);
 
-cmd = virCommandNew(MMCTL);
+cmd = virCommandNew(MM_CTL);
 virCommandAddArgList(cmd, "--unbind-port", virtportuuid, NULL);
 
 if (virCommandRun(cmd, NULL) < 0) {
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index dbb489d174d..89e55650083 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -151,7 +151,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
 ovsport->profileID);
 }
 
-cmd = virCommandNew(OVSVSCTL);
+cmd = virCommandNew(OVS_VSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
 virCommandAddArgList(cmd, "--", "--if-exists", "del-port",
  ifname, "--", "add-port", brname, ifname, NULL);
@@ -199,7 +199,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname 
G_GNUC_UNUSED, const char
 {
 g_autoptr(virCommand) cmd = NULL;
 
-cmd = virCommandNew(OVSVSCTL);
+cmd = virCommandNew(OVS_VSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
 virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, NULL);
 
@@ -226,7 +226,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, 
const char *ifname)
 size_t len;
 g_autoptr(virCommand) cmd = NULL;
 
-cmd = virCommandNew(OVSVSCTL);
+cmd = virCommandNew(OVS_VSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
 virCommandAddArgList(cmd, "--if-exists", "get", "Interface",
  ifname, "external_ids:PortData", NULL);
@@ -267,7 +267,7 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, const 
char *ifname)
 return 0;
 }
 
-cmd = virCommandNew(OVSVSCTL);
+cmd = virCommandNew(OVS_VSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
 virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
 virCommandAddArgFormat(cmd, "external_ids:PortData=%s", migrate);
@@ -373,7 +373,7 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
 g_autoptr(virCommand) cmd = NULL;
 g_autofree char *output = NULL;
 
-cmd = virCommandNew(OVSVSCTL);
+cmd = virCommandNew(OVS_VSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
 virCommandAddArgList(cmd, "--if-exists", "--format=list", "--data=json",
  "--no-headings", "--columns=statistics", "list",
@@ -439,7 +439,7 @@ virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, 
char **master)
 
 *master = NULL;
 
-cmd = 

[libvirt PATCH 00/31] fixes and cleanups for current build system

2020-07-02 Thread Pavel Hrdina
While working on rewrite to Meson I discovered some parts of our
current build system that could be improved to help with the
transition to Meson. It will make the review of the Meson patches
a bit easier.

Pavel Hrdina (31):
  build: use DLOPEN_LIBS directly
  configure: drop check for unsupported FreeBSD
  configure: introduce FLAT_NAMESPACE_FLAGS
  configure: remove usage of AC_HEADER_MAJOR
  Makefile: drop undefined LIB_CLOCK_GETTIME
  docs: remove incorrect generated files by apibuild.py
  docs: remove unused wrapstring.xsl file
  docs: drop %.png: %.fig rule
  m4: virt-sanlock: drop check for sanlock_inq_lockspace
  m4: virt-sanlock: use pkg-config to find libsanlock_client
  m4: virt-sanlock: drop check for SANLK_INQ_WAIT
  m4: virt-sanlock: drop check for sanlock_killpath()
  m4: virt-sanlock: drop check for sanlock_write_lockspace()
  m4: virt-secdriver-selinux: drop obsolete function checks
  m4: virt-selinux: drop check for selabel_open signature change
  m4: virt-xdr: rewrite XDR check
  po: change the format of POTFILES.in
  scripts: check-remote-protocol: remove unused OBJEXT argument
  src: Makefile: remove LOCK_CHECKING_CFLAGS leftover
  src: remove unnecessary -I$(srcdir)/secret include
  src: remote: Makefile: drop CFLAGS and LDFLAGS duplication
  src: logging: Makefile: drop undefined LOG_DRIVER
  src: util: rename some program macros
  src: util: Makefile: drop undefined LDEXP_LIBM
  src: util: Makefile: drop undefined OPENPTY_LIBS
  src: remote: Makefile: properly format sysconfdir in virtproxyd.conf
  src: unify virFileActivateDirOverride()
  tests: commandhelper: change how we detect if running as daemon
  tests: use WITH_NSS instead of NSS
  tools: virsh-secret: fix compilation error
  tools: wireshark: fix compilation errors

 build-aux/syntax-check.mk|   4 +-
 configure.ac |  26 +-
 docs/Makefile.am |  12 +-
 docs/wrapstring.xsl  |  56 ---
 m4/virt-driver-modules.m4|   3 -
 m4/virt-external-programs.m4 |   8 +-
 m4/virt-nss.m4   |   2 +-
 m4/virt-sanlock.m4   |  33 +-
 m4/virt-secdriver-selinux.m4 |  24 +-
 m4/virt-selinux.m4   |  17 -
 m4/virt-xdr.m4   |  39 +-
 po/Makefile.am   |   6 +-
 po/POTFILES.in   | 726 +--
 scripts/check-remote-protocol.py |   5 +-
 src/Makefile.am  |  25 +-
 src/admin/Makefile.inc.am|   1 +
 src/libvirt.c|   2 +-
 src/libvirt_private.syms |   3 +-
 src/libxl/Makefile.inc.am|   1 -
 src/locking/Makefile.inc.am  |   2 +
 src/locking/lock_daemon.c|   2 +-
 src/locking/lock_driver_sanlock.c|  38 --
 src/logging/Makefile.inc.am  |   2 +-
 src/logging/log_daemon.c |   2 +-
 src/qemu/Makefile.inc.am |   1 -
 src/qemu/qemu_shim.c |   2 +-
 src/remote/Makefile.inc.am   |  13 +-
 src/remote/remote_daemon.c   |   2 +-
 src/security/virt-aa-helper.c|   2 +-
 src/storage/Makefile.inc.am  |   4 -
 src/util/Makefile.inc.am |   3 -
 src/util/virfile.c   |  25 +-
 src/util/virfile.h   |   4 +-
 src/util/virnetdevmidonet.c  |   4 +-
 src/util/virnetdevopenvswitch.c  |  16 +-
 tests/Makefile.am|  10 +-
 tests/commandhelper.c|   2 +-
 tests/nssmock.c  |   2 +-
 tests/nsstest.c  |   2 +-
 tests/qemucapsprobe.c|   2 +-
 tests/securityselinuxhelper.c|   5 +-
 tests/testutils.c|   2 +-
 tools/virsh-secret.c |   2 +-
 tools/virsh.c|   2 +-
 tools/virt-admin.c   |   2 +-
 tools/wireshark/src/packet-libvirt.c |  19 +-
 46 files changed, 472 insertions(+), 693 deletions(-)
 delete mode 100644 docs/wrapstring.xsl

-- 
2.26.2



[libvirt PATCH 15/31] m4: virt-selinux: drop check for selabel_open signature change

2020-07-02 Thread Pavel Hrdina
All supported OSes have at least libselinux version 2.5 so it's safe
to drop this check.

Signed-off-by: Pavel Hrdina 
---
 m4/virt-selinux.m4| 17 -
 tests/securityselinuxhelper.c |  5 ++---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/m4/virt-selinux.m4 b/m4/virt-selinux.m4
index 64e69808440..fb541e207ed 100644
--- a/m4/virt-selinux.m4
+++ b/m4/virt-selinux.m4
@@ -27,23 +27,6 @@ AC_DEFUN([LIBVIRT_CHECK_SELINUX],[
 [fgetfilecon_raw], [selinux/selinux.h])
 
   if test "$with_selinux" = "yes"; then
-# libselinux changed signatures for 2.5
-# TODO: Drop once we don't support Ubuntu 16.04
-AC_CACHE_CHECK([for selinux selabel_open parameter type],
-   [lv_cv_selabel_open_const],
-[AC_COMPILE_IFELSE(
-  [AC_LANG_PROGRAM(
- [[
-#include 
-#include 
-struct selabel_handle *selabel_open(unsigned, struct selinux_opt *, unsigned);
- ]])],
- [lv_cv_selabel_open_const=''],
- [lv_cv_selabel_open_const='const'])])
-AC_DEFINE_UNQUOTED([VIR_SELINUX_OPEN_CONST], [$lv_cv_selabel_open_const],
-  [Define to empty or 'const' depending on how SELinux qualifies its
-   selabel_open parameter])
-
 AC_MSG_CHECKING([SELinux mount point])
 if test "$with_selinux_mount" = "check" || test -z "$with_selinux_mount"; 
then
   if test -d /sys/fs/selinux ; then
diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c
index f89224c07a4..0556241fd55 100644
--- a/tests/securityselinuxhelper.c
+++ b/tests/securityselinuxhelper.c
@@ -53,8 +53,7 @@ static const char *(*real_selinux_lxc_contexts_path)(void);
 #endif
 
 static struct selabel_handle *(*real_selabel_open)(unsigned int backend,
-  VIR_SELINUX_OPEN_CONST
-  struct selinux_opt *opts,
+  const struct selinux_opt 
*opts,
   unsigned nopts);
 static void (*real_selabel_close)(struct selabel_handle *handle);
 static int (*real_selabel_lookup_raw)(struct selabel_handle *handle,
@@ -288,7 +287,7 @@ const char *selinux_lxc_contexts_path(void)
 
 struct selabel_handle *
 selabel_open(unsigned int backend,
- VIR_SELINUX_OPEN_CONST struct selinux_opt *opts,
+ const struct selinux_opt *opts,
  unsigned nopts)
 {
 char *fake_handle;
-- 
2.26.2



  1   2   >