Re: [libvirt] [PATCH 7/7] snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST flag

2019-02-20 Thread Eric Blake
On 2/20/19 9:53 AM, Eric Blake wrote:
> Continue the work of the previous patch in making it possible
> to copy the state of a transient domain with snapshots from one
> host to another, by allowing the destination to perform bulk
> redefines.  Note that the destination still has to do separate
> calls for creating/defining the domain first, and then redefining
> the snapshots (that is, there is intentional asymmetry between
> dumping the list in virDomainGetXMLDesc() but redefining it via
> virDomainSnapshotCreateXML()), but this is better than the
> previous state of having to make multiple REDEFINE calls.  The
> bulk flag requires no pre-existing snapshot metadata (as that
> makes life much easier if there is a failure encountered partway
> through the list processing - simply remove all other snapshot
> metadatas), and makes no guarantees on which snapshot (when there
> are multiple) will actually be returned.
> 
> Wire up the virsh snapshot-create command to support the new flag.
> 
> Actual driver implementations will be in later patches.
> 
> Signed-off-by: Eric Blake 
> ---
>  include/libvirt/libvirt-domain-snapshot.h |  3 +++
>  src/libvirt-domain-snapshot.c | 21 ++---
>  tools/virsh-snapshot.c| 13 +
>  3 files changed, 34 insertions(+), 3 deletions(-)
> 

For convenience, I'll probably squash this in (while the API requires
both REDEFINE and REDEFINE_LIST flags, the virsh tooling can imply one
from the other):

diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index f6efadde2d..a58731c46e 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -131,7 +131,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
 VIRSH_COMMON_OPT_CURRENT(N_("with redefine, set current snapshot")),
 {.name = "redefine-list",
  .type = VSH_OT_BOOL,
- .help = N_("with redefine, bulk define a set of snapshots"),
+ .help = N_("bulk define a set of snapshots, implies --redefine"),
 },
 {.name = "no-metadata",
  .type = VSH_OT_BOOL,
@@ -189,7 +189,8 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
 if (vshCommandOptBool(cmd, "live"))
 flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE;
 if (vshCommandOptBool(cmd, "redefine-list"))
-flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST;
+flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
+VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST;

 if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
 goto cleanup;


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

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


[libvirt] domXML modeling question

2019-02-20 Thread Jim Fehlig
There have been a few requests [1][2] to support Xen's max_grant_frames setting 
in libvirt domXML, but I'm not quite sure how to model it. The documentation [3] 
on this setting states:


Specify the maximum number of grant frames the domain is allowed to have.  This
value controls how many pages the domain is able to grant access to for other
domains, needed e.g. for the operation of paravirtualized devices.  The default
is settable via xl.conf(5).

It smells of a  setting, e.g. the amount of memory a domain can share, 
but doesn't map to any of the existing settings. A new subelement  
doesn't feel right. Does anyone suggest a better way of modeling max_grant_frames?


Another option I considered is setting the value based on number of PV devices, 
but I think that flies in the face of libvirt's policy of not dictating policy. 
Regardless of domain config modeling I can work on a driver-wide setting in 
libxl.conf, similar to Xen's xl.conf(5) global.


Regards,
Jim

[1] https://www.redhat.com/archives/libvir-list/2018-April/msg00216.html
[2] https://www.redhat.com/archives/libvirt-users/2019-January/msg00011.html
[3] 
http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/man/xl.cfg.5.pod.in;h=ad81af1ed8cc983c76b5ec2c3aa02e28f042cc63;hb=HEAD#l569


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


Re: [libvirt] [PATCH v2 3/3] news: document bhyve msrs feature

2019-02-20 Thread Cole Robinson
On 2/10/19 6:09 AM, Roman Bogorodskiy wrote:
> Describe bhyve's ignoring unknown MSRs writes feature
> introduced by commit 525918ac5c.
> 
> Signed-off-by: Roman Bogorodskiy 
> ---
>  docs/news.xml | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/docs/news.xml b/docs/news.xml
> index 8d6d58ae6a..cb23b63143 100644
> --- a/docs/news.xml
> +++ b/docs/news.xml
> @@ -59,6 +59,16 @@
>of the network's bridge element.
>  
>
> +  
> +
> +  bhyve: support for ignoring unknown MSRs reads and writes
> +
> +
> +  A new features element msrs unknown='ignore'/ was
> +  introduced and the bhyve driver supports it to control unknown
> +  Model Specific Registers (MSRs) reads and writes.
> +
> +  
>  
>  
>  
> 

I would put  in XML brackets too

Reviewed-by: Cole Robinson 

- Cole

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


Re: [libvirt] [PATCH v2 2/3] bhyve: implement ignore unknown MSRs feature

2019-02-20 Thread Cole Robinson
On 2/10/19 6:09 AM, Roman Bogorodskiy wrote:
> Implement the MSRs ignore unknown reads and writes feature
> that's specified using:
> 
>   
> ...
> 
> ...
>   
> 
> in the domain XML.
> 
> In bhyve, it's just passing '-w' command line argument to the bhyve(8)
> executable.
> 
> Signed-off-by: Roman Bogorodskiy 
> ---
>  docs/drvbhyve.html.in | 22 
>  src/bhyve/bhyve_command.c |  4 +++
>  .../bhyvexml2argvdata/bhyvexml2argv-msrs.args | 10 ++
>  .../bhyvexml2argv-msrs.ldargs |  3 ++
>  .../bhyvexml2argvdata/bhyvexml2argv-msrs.xml  | 26 ++
>  tests/bhyvexml2argvtest.c |  1 +
>  .../bhyvexml2xmlout-msrs.xml  | 36 +++
>  tests/bhyvexml2xmltest.c  |  1 +
>  8 files changed, 103 insertions(+)
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-msrs.args
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-msrs.ldargs
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-msrs.xml
>  create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-msrs.xml
> 
> diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
> index 2e9cf5551b..97f6f1b900 100644
> --- a/docs/drvbhyve.html.in
> +++ b/docs/drvbhyve.html.in
> @@ -462,6 +462,23 @@ Example:
>  /domain
>  
>  
> +Ignoring unknown MSRs writes
> +
> +Some guests might require ignoring unknown Model Specific Registers (MSRs)
> +reads and writes.
> +Since 5.1.0 it's possible to switch this on 
> using:
> +
> +domain type="bhyve"
> +...
> +  features
> +msrs unknown='ignore'/
> +  /features
> +...
> +/domain
> +
> +
> +By default unknown reads and writes are not ignored.
> +

Hmm. I think think this should go into domainformat.html.in with a note
that it's currently only implemented for bhyve, and not bhyve specific
docs. That's the pattern we follow for the qemu driver

>  Pass-through of arbitrary bhyve commands
>  
>  Since 5.1.0, it's possible to pass additional 
> command-line
> @@ -489,5 +506,10 @@ They are unsupported, using them may result in 
> inconsistent state,
>  and upgrading either bhyve or libvirtd maybe break behavior of a domain that
>  was relying on a specific commands pass-through.
>  
> +
> +>>> 525918ac5c... bhyve: implement MSRs ignore unknown writes feature
> +===
> +>>> 93d9056998... fixup! bhyve: implement MSRs ignore unknown writes 
> feature
> +

Something went wrong here. Feel to just fix those issues and push

Reviewed-by: Cole Robinson 

- Cole

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


Re: [libvirt] [PATCH v2 1/3] conf: introduce 'msrs' feature

2019-02-20 Thread Cole Robinson
On 2/10/19 6:09 AM, Roman Bogorodskiy wrote:
> Introduce the 'msrs' feature element that controls Model Specific
> Registers related behaviour. At this moment it allows only
> single tunable attribute "unknown":
> 
>  
> 
> Which tells hypervisor to ignore accesses to unimplemented
> Model Specific Registers. The only user of that for now is going
> to be the bhyve driver.
> 
> Signed-off-by: Roman Bogorodskiy 

Reviewed-by: Cole Robinson 

- Cole

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


Re: [libvirt] [jenkins-ci PATCH] lcitool: Don't import crypt

2019-02-20 Thread Cole Robinson
On 2/14/19 4:39 AM, Andrea Bolognani wrote:
> It hasn't been needed since dbe55924f90d, and flake8 rightfully
> complains about that.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  guests/lcitool | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/guests/lcitool b/guests/lcitool
> index 759eff6..e8263da 100755
> --- a/guests/lcitool
> +++ b/guests/lcitool
> @@ -17,7 +17,6 @@
>  # with this program. If not, see .
>  
>  import argparse
> -import crypt
>  import fnmatch
>  import json
>  import os
> 

Reviewed-by: Cole Robinson 

- Cole

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


[libvirt] libvirt 'make cov' vs gnulib 'make coverage'

2019-02-20 Thread Cole Robinson
Recently I've played with libvirt coverage/gcov/lcov support. The
libvirt specific way to enable it is:

  ./configure --enable-test-coverage
  make check
  make cov
  firefox coverage/index.html

However it looks like gnulib provides an automagic way to get similar
output. The process is:

  make coverage
  firefox doc/coverage/index.html

'make coverage' is composed of these 3 additional commands:

  make init-coverage   # clear lcov counters
  make build-coverage  # 'make check' with coverage flags, generate
   # lcov metadata
  make gen-coverage# generate the html report

It seems like we can just drop our custom coverage implementation.

* Less code for us
* The gnulib implementation is more flexible with the split commands
* libvirt impl needs an explicit directory list. right now gnulib output
  reports info for the tools/ dir but libvirt's doesn't
* gnulib impl doesn't require a reconfigure
* seems like libvirt impl never calls lcov --zerocounters which AFAICT
  means that every 'make check' run adds to the coverage stats. so if
  you wanted to check for coverage changes across commits we require a
  make clean in between to zero out the stats for testing. gnulib
  init-coverage takes care of that.

Anyone know a reason not to rip this out? If not I'll send a patch

Thanks,
Cole

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


Re: [libvirt] [PATCHv2 2/2] network: add netmask to dhcp range of dnsmasq conf file for IPv4

2019-02-20 Thread John Ferlan



On 2/18/19 6:21 PM, Laine Stump wrote:
> dnsmasq documentation says that the *IPv4* prefix/network
> address/broadcast address sent to dhcp clients will be automatically
> determined by dnsmasq by looking at the interface it's listening on,
> so the original libvirt code did not add a netmask to the dnsmasq
> commandline (or later, the dnsmasq conf file).
> 
> For *IPv6* however, dnsmasq apparently cannot automatically determine
> the prefix (functionally the same as a netmask), and it must be
> explicitly provided in the conf file (as a part of the dhcp-range
> option). So many years after IPv4 DHCP support had been added, when
> IPv6 dhcp support was added the prefix was included at the end of the
> dhcp-range setting, but only for IPv6.
> 
> Recently a user reported (privately, because they suspected a possible
> security implication, which turned out to be unfounded) a bug on a
> host where one of the interfaces was a superset of the libvirt network
> where dhcp is needed (e.g., the host's ethernet is 10.0.0.20/8, and
> the libvirt network is 10.10.0.1/24). For some reason dnsmasq was
> supplying the netmask for the /8 network to clients requesting an
> address on the /24 interface.
> 
> This seems like a bug in dnsmasq, but even if/when it gets fixed
> there, it looks like there is no harm in just always adding the
> netmask to all IPv4 dhcp-range options similar to how prefix is added
> to all IPv6 dhcp-range options.
> 
> Signed-off-by: Laine Stump 
> ---
>  src/network/bridge_driver.c   | 27 +++
>  .../dhcp6-nat-network.conf|  2 +-
>  .../networkxml2confdata/isolated-network.conf |  2 +-
>  .../nat-network-dns-srv-record-minimal.conf   |  2 +-
>  .../nat-network-dns-srv-record.conf   |  2 +-
>  .../nat-network-dns-txt-record.conf   |  2 +-
>  .../networkxml2confdata/nat-network-mtu.conf  |  2 +-
>  .../nat-network-name-with-quotes.conf |  2 +-
>  tests/networkxml2confdata/nat-network.conf|  2 +-
>  .../networkxml2confdata/netboot-network.conf  |  2 +-
>  .../netboot-proxy-network.conf|  2 +-
>  .../networkxml2confdata/ptr-domains-auto.conf |  2 +-
>  12 files changed, 33 insertions(+), 16 deletions(-)
> 
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 6d80818e40..9fa902896b 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -1320,11 +1320,28 @@ networkDnsmasqConfContents(virNetworkObjPtr obj,
>  !(eaddr = virSocketAddrFormat(>ranges[r].end)))
>  goto cleanup;
>  
> -virBufferAsprintf(, "dhcp-range=%s,%s",
> -  saddr, eaddr);
> -if (VIR_SOCKET_ADDR_IS_FAMILY(>address, AF_INET6))
> -virBufferAsprintf(, ",%d", prefix);
> -virBufferAddLit(, "\n");
> +if (VIR_SOCKET_ADDR_IS_FAMILY(>address, AF_INET6)) {
> +   virBufferAsprintf(, "dhcp-range=%s,%s,%d\n",
> + saddr, eaddr, prefix);
> +} else {
> +/* IPv4 - dnsmasq requires a netmask rather than prefix */
> +virSocketAddr netmask;

Does it matter if this isn't initialized? e.g. "= { 0 };"

> +char *netmaskStr;

VIR_AUTOFREE(char *) netmaskStr = NULL;

> +
> +if (virSocketAddrPrefixToNetmask(prefix, , AF_INET) 
> < 0) {
> +virReportError(VIR_ERR_INTERNAL_ERROR,
> +   _("Failed to translate bridge '%s' "
> + "prefix %d to netmask"),
> +   def->bridge, prefix);
> +goto cleanup;
> +}
> +
> +if (!(netmaskStr = virSocketAddrFormat()))
> +goto cleanup;
> +virBufferAsprintf(, "dhcp-range=%s,%s,%s\n",
> +  saddr, eaddr, netmaskStr);
> +VIR_FREE(netmaskStr);

w/ VIR_AUTOFREE, this isn't necessary

I know bridge_driver doesn't use it yet, but doesn't harm to start.

Reviewed-by: John Ferlan 

John

[...]

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


Re: [libvirt] [PATCH v3 00/17] qemu: virtio-{non-}transitional support

2019-02-20 Thread Cole Robinson
On 2/13/19 3:31 AM, Andrea Bolognani wrote:
> On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote:
>> v2 libvirt patches:
>> https://www.redhat.com/archives/libvir-list/2019-January/msg00877.html
>> v1 libvirt patches:
>> https://www.redhat.com/archives/libvir-list/2019-January/msg00593.html
>> Previous incomplete RFC here:
>> https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html
>> qemu patches, queued for qemu 4.0.0:
>> https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html
>> Previous libvirt discussion around this:
>> https://www.redhat.com/archives/libvir-list/2018-August/msg01073.html
>>
>> Changes since v2:
>> * Some prep patches merged
>> * filesystem model dropped the -9p naming, now uses virtio-{non-}transitional
>>   like other devices
>> * Now uses a single capability QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL
>>   which is set whenever any of the -transitional or -non-transitional
>>   devices are present.
>> * Add a formatdomain section 'Virtio transitional devices' and reference
>>   it from each relevant device section
>> * if virtio-transitional specified, and qemu is too old but has the
>>   disable_X options, convert it to explicit
>>   disable-legacy=off,disable-modern=off
>> * Misc small changes pointed out in review
> 

Thanks for the reviews, I fixed all the issues you pointed out and
pushed the patches here:

https://github.com/crobinso/libvirt/tree/virtio-v4

I'll wait to push until after 5.2.0 is out, so we have a longer window
to tweak things if eduardo's responses change anything, and to discuss
the controller type=scsi model=virtio patch I think you have pending...

> Oh, and this definitely deserves to be mentioned in the release
> notes! Can you please post a 18/17 or a separate patch that adds
> the corresponding entry?
> 

I'll send one after I push the commits

Thanks,
Cole

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


[libvirt] [PATCH v2 3/6] conf: Clean up some unnecessary goto paths

2019-02-20 Thread John Ferlan
Now that we're using VIR_AUTOPTR(virBitmap) there's a couple of methods
that we can clean up some now unnecessary goto paths.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 26 +-
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f27af65d80..ddcb76f05d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2983,7 +2983,6 @@ static int
 virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 unsigned int iothreads)
 {
-int retval = -1;
 size_t i;
 ssize_t nxt = -1;
 virDomainIOThreadIDDefPtr iothrid = NULL;
@@ -2997,7 +2996,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 
 /* iothread's are numbered starting at 1, account for that */
 if (!(thrmap = virBitmapNew(iothreads + 1)))
-goto error;
+return -1;
 virBitmapSetAll(thrmap);
 
 /* Clear 0 since we don't use it, then mark those which are
@@ -3009,26 +3008,23 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 
 /* resize array */
 if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
-goto error;
+return -1;
 
 /* Populate iothreadids[] using the set bit number from thrmap */
 while (def->niothreadids < iothreads) {
 if ((nxt = virBitmapNextSetBit(thrmap, nxt)) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to populate iothreadids"));
-goto error;
+return -1;
 }
 if (VIR_ALLOC(iothrid) < 0)
-goto error;
+return -1;
 iothrid->iothread_id = nxt;
 iothrid->autofill = true;
 def->iothreadids[def->niothreadids++] = iothrid;
 }
 
-retval = 0;
-
- error:
-return retval;
+return 0;
 }
 
 
@@ -18779,31 +18775,27 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
 virDomainThreadSchedParamPtr sched;
 virProcessSchedPolicy policy;
 int priority;
-int ret = -1;
 VIR_AUTOPTR(virBitmap) map = NULL;
 
 if (!(map = virDomainSchedulerParse(node, name, , )))
-goto cleanup;
+return -1;
 
 while ((next = virBitmapNextSetBit(map, next)) > -1) {
 if (!(sched = func(def, next)))
-goto cleanup;
+return -1;
 
 if (sched->policy != VIR_PROC_POLICY_NONE) {
 virReportError(VIR_ERR_XML_DETAIL,
_("%ssched attributes 'vcpus' must not overlap"),
name);
-goto cleanup;
+return -1;
 }
 
 sched->policy = policy;
 sched->priority = priority;
 }
 
-ret = 0;
-
- cleanup:
-return ret;
+return 0;
 }
 
 
-- 
2.20.1

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


[libvirt] [PATCH v2 2/6] conf: Use VIR_AUTOPTR(virBitmap) in domain_conf

2019-02-20 Thread John Ferlan
Let's make use of the auto __cleanup capabilities for virBitmapPtr.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 542d53e709..f27af65d80 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1803,8 +1803,8 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
  virBitmapPtr autoCpuset)
 {
 int maxvcpus = virDomainDefGetVcpusMax(def);
-virBitmapPtr allcpumap = NULL;
 size_t i;
+VIR_AUTOPTR(virBitmap) allcpumap = NULL;
 
 if (hostcpus < 0)
 return -1;
@@ -1831,7 +1831,6 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
 virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen);
 }
 
-virBitmapFree(allcpumap);
 return i;
 }
 
@@ -2988,7 +2987,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 size_t i;
 ssize_t nxt = -1;
 virDomainIOThreadIDDefPtr iothrid = NULL;
-virBitmapPtr thrmap = NULL;
+VIR_AUTOPTR(virBitmap) thrmap = NULL;
 
 /* Same value (either 0 or some number), then we have none to fill in or
  * the iothreadid array was filled from the XML
@@ -3029,7 +3028,6 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 retval = 0;
 
  error:
-virBitmapFree(thrmap);
 return retval;
 }
 
@@ -18327,9 +18325,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 {
 int ret = -1;
 virDomainIOThreadIDDefPtr iothrid;
-virBitmapPtr cpumask = NULL;
 unsigned int iothreadid;
 char *tmp = NULL;
+VIR_AUTOPTR(virBitmap) cpumask = NULL;
 
 if (!(tmp = virXMLPropString(node, "iothread"))) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -18385,7 +18383,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 
  cleanup:
 VIR_FREE(tmp);
-virBitmapFree(cpumask);
 return ret;
 }
 
@@ -18397,9 +18394,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 static virBitmapPtr
 virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 {
-virBitmapPtr def = NULL;
 virBitmapPtr ret = NULL;
 char *tmp = NULL;
+VIR_AUTOPTR(virBitmap) def = NULL;
 
 if (!(tmp = virXMLPropString(node, "cpuset"))) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -18419,7 +18416,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 VIR_STEAL_PTR(ret, def);
 
  cleanup:
-virBitmapFree(def);
 VIR_FREE(tmp);
 return ret;
 }
@@ -18780,11 +18776,11 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
 virDomainDefPtr def)
 {
 ssize_t next = -1;
-virBitmapPtr map = NULL;
 virDomainThreadSchedParamPtr sched;
 virProcessSchedPolicy policy;
 int priority;
 int ret = -1;
+VIR_AUTOPTR(virBitmap) map = NULL;
 
 if (!(map = virDomainSchedulerParse(node, name, , )))
 goto cleanup;
@@ -18807,7 +18803,6 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
 ret = 0;
 
  cleanup:
-virBitmapFree(map);
 return ret;
 }
 
@@ -19511,12 +19506,12 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
 {
 xmlNodePtr oldnode = ctxt->node;
 xmlNodePtr *nodes = NULL;
-virBitmapPtr vcpus = NULL;
 virResctrlAllocPtr alloc = NULL;
 virDomainResctrlDefPtr resctrl = NULL;
 ssize_t i = 0;
 int n;
 int ret = -1;
+VIR_AUTOPTR(virBitmap) vcpus = NULL;
 
 ctxt->node = node;
 
@@ -19576,7 +19571,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
 ctxt->node = oldnode;
 virDomainResctrlDefFree(resctrl);
 virObjectUnref(alloc);
-virBitmapFree(vcpus);
 VIR_FREE(nodes);
 return ret;
 }
@@ -19730,9 +19724,9 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
 {
 xmlNodePtr oldnode = ctxt->node;
 xmlNodePtr *nodes = NULL;
-virBitmapPtr vcpus = NULL;
 virResctrlAllocPtr alloc = NULL;
 virDomainResctrlDefPtr resctrl = NULL;
+VIR_AUTOPTR(virBitmap) vcpus = NULL;
 
 ssize_t i = 0;
 int n;
@@ -19791,7 +19785,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
 ctxt->node = oldnode;
 virDomainResctrlDefFree(resctrl);
 virObjectUnref(alloc);
-virBitmapFree(vcpus);
 VIR_FREE(nodes);
 return ret;
 }
-- 
2.20.1

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


[libvirt] [PATCH v2 1/6] conf: Rework virDomainEmulatorPinDefParseXML

2019-02-20 Thread John Ferlan
In preparation for using auto free mechanism, change to using the
VIR_STEAL_PTR on @def to @ret and of course be sure to properly clean
up @def in cleanup.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ceeb247ef4..542d53e709 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18398,6 +18398,7 @@ static virBitmapPtr
 virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 {
 virBitmapPtr def = NULL;
+virBitmapPtr ret = NULL;
 char *tmp = NULL;
 
 if (!(tmp = virXMLPropString(node, "cpuset"))) {
@@ -18412,14 +18413,15 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 if (virBitmapIsAllClear(def)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid value of 'cpuset': %s"), tmp);
-virBitmapFree(def);
-def = NULL;
 goto cleanup;
 }
 
+VIR_STEAL_PTR(ret, def);
+
  cleanup:
+virBitmapFree(def);
 VIR_FREE(tmp);
-return def;
+return ret;
 }
 
 
-- 
2.20.1

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


[libvirt] [PATCH v2 4/6] conf: Remove a few unused variables in domain_conf

2019-02-20 Thread John Ferlan
In preparation for VIR_AUTOFREE usage, let's remove a couple
of unused variables so that clang compilations won't fail.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ddcb76f05d..1ec521a35d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7138,7 +7138,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt 
ATTRIBUTE_UNUSED,
 xmlNodePtr alias = NULL;
 xmlNodePtr boot = NULL;
 xmlNodePtr rom = NULL;
-char *type = NULL;
 char *romenabled = NULL;
 char *rombar = NULL;
 char *aliasStr = NULL;
@@ -7224,7 +7223,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt 
ATTRIBUTE_UNUSED,
  cleanup:
 if (ret < 0)
 virDomainDeviceInfoClear(info);
-VIR_FREE(type);
 VIR_FREE(rombar);
 VIR_FREE(romenabled);
 VIR_FREE(aliasStr);
@@ -13012,7 +13010,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
 xmlXPathContextPtr ctxt,
 unsigned int flags)
 {
-char *type = NULL;
 char *path = NULL;
 char *model = NULL;
 char *backend = NULL;
@@ -13093,7 +13090,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
 goto error;
 
  cleanup:
-VIR_FREE(type);
 VIR_FREE(path);
 VIR_FREE(model);
 VIR_FREE(backend);
@@ -18548,7 +18544,7 @@ virDomainHugepagesParseXML(xmlNodePtr node,
 {
 int ret = -1;
 xmlNodePtr oldnode = ctxt->node;
-char *unit = NULL, *nodeset = NULL;
+char *nodeset = NULL;
 
 ctxt->node = node;
 
@@ -18576,7 +18572,6 @@ virDomainHugepagesParseXML(xmlNodePtr node,
 
 ret = 0;
  cleanup:
-VIR_FREE(unit);
 VIR_FREE(nodeset);
 ctxt->node = oldnode;
 return ret;
-- 
2.20.1

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


[libvirt] [PATCH v2 5/6] conf: Use VIR_AUTOFREE in domain_conf

2019-02-20 Thread John Ferlan
Let's make use of the auto __cleanup capabilities for VIR_FREE consumers.
In some cases adding or removing blank lines for readability.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 1080 +---
 1 file changed, 347 insertions(+), 733 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1ec521a35d..98a35b0296 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1099,11 +1099,11 @@ static int
 virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap,
   xmlNodePtr node)
 {
-char *name = NULL;
-char *state = NULL;
 int state_type;
 int name_type;
 int ret = -1;
+VIR_AUTOFREE(char *) name = NULL;
+VIR_AUTOFREE(char *) state = NULL;
 
 if (!(name = virXMLPropString(node, "name"))) {
 virReportError(VIR_ERR_CONF_SYNTAX, "%s",
@@ -1161,8 +1161,6 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr 
keywrap,
 ret = 0;
 
  cleanup:
-VIR_FREE(name);
-VIR_FREE(state);
 return ret;
 }
 
@@ -1171,8 +1169,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, 
xmlXPathContextPtr ctxt)
 {
 size_t i;
 int ret = -1;
-xmlNodePtr *nodes = NULL;
 int n;
+VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
 
 if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, )) < 0)
 return n;
@@ -1194,7 +1192,6 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, 
xmlXPathContextPtr ctxt)
  cleanup:
 if (ret < 0)
 VIR_FREE(def->keywrap);
-VIR_FREE(nodes);
 return ret;
 }
 
@@ -1267,10 +1264,10 @@ static int
 virDomainVirtioOptionsParseXML(xmlNodePtr driver,
virDomainVirtioOptionsPtr *virtio)
 {
-char *str = NULL;
 int ret = -1;
 int val;
 virDomainVirtioOptionsPtr res;
+VIR_AUTOFREE(char *) str = NULL;
 
 if (*virtio || !driver)
 return 0;
@@ -1302,7 +1299,6 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver,
 ret = 0;
 
  cleanup:
-VIR_FREE(str);
 return ret;
 }
 
@@ -1344,8 +1340,8 @@ static int
 virDomainBlkioDeviceParseXML(xmlNodePtr root,
  virBlkioDevicePtr dev)
 {
-char *c = NULL;
 xmlNodePtr node;
+VIR_AUTOFREE(char *) c = NULL;
 
 node = root->children;
 while (node) {
@@ -1410,7 +1406,6 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root,
 return 0;
 
  error:
-VIR_FREE(c);
 VIR_FREE(dev->path);
 return -1;
 }
@@ -5338,8 +5333,8 @@ virDomainDefCollectBootOrder(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
  void *data)
 {
 virHashTablePtr bootHash = data;
-char *order = NULL;
 int ret = -1;
+VIR_AUTOFREE(char *) order = NULL;
 
 if (info->bootIndex == 0)
 return 0;
@@ -5368,7 +5363,6 @@ virDomainDefCollectBootOrder(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 ret = 0;
 
  cleanup:
-VIR_FREE(order);
 return ret;
 }
 
@@ -6889,8 +6883,8 @@ static int
 virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
  virDomainDeviceUSBMasterPtr master)
 {
-char *startport;
 int ret = -1;
+VIR_AUTOFREE(char *) startport = NULL;
 
 memset(master, 0, sizeof(*master));
 
@@ -6906,7 +6900,6 @@ virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
 ret = 0;
 
  cleanup:
-VIR_FREE(startport);
 return ret;
 }
 
@@ -6914,9 +6907,9 @@ static int
 virDomainDeviceBootParseXML(xmlNodePtr node,
 virDomainDeviceInfoPtr info)
 {
-char *order;
-char *loadparm = NULL;
 int ret = -1;
+VIR_AUTOFREE(char *) order = NULL;
+VIR_AUTOFREE(char *) loadparm = NULL;
 
 if (!(order = virXMLPropString(node, "order"))) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -6950,8 +6943,6 @@ virDomainDeviceBootParseXML(xmlNodePtr node,
 ret = 0;
 
  cleanup:
-VIR_FREE(order);
-VIR_FREE(loadparm);
 return ret;
 }
 
@@ -6960,8 +6951,8 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node,
   virDomainDeviceISAAddressPtr addr)
 {
 int ret = -1;
-char *iobase;
-char *irq;
+VIR_AUTOFREE(char *) iobase = NULL;
+VIR_AUTOFREE(char *) irq = NULL;
 
 memset(addr, 0, sizeof(*addr));
 
@@ -6984,8 +6975,6 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node,
 
 ret = 0;
  cleanup:
-VIR_FREE(iobase);
-VIR_FREE(irq);
 return ret;
 }
 
@@ -6995,7 +6984,7 @@ virDomainDeviceDimmAddressParseXML(xmlNodePtr node,
virDomainDeviceDimmAddressPtr addr)
 {
 int ret = -1;
-char *tmp = NULL;
+VIR_AUTOFREE(char *) tmp = NULL;
 
 if (!(tmp = virXMLPropString(node, "slot")) ||
 virStrToLong_uip(tmp, NULL, 10, >slot) < 0) {
@@ -7012,15 +7001,11 @@ virDomainDeviceDimmAddressParseXML(xmlNodePtr node,
_("invalid dimm base address '%s'"), tmp);
 goto cleanup;
 }
-
-VIR_FREE(tmp);
 }
 

[libvirt] [PATCH v2 6/6] conf: Clean up some unnecessary goto paths

2019-02-20 Thread John Ferlan
Now that we're using VIR_AUTOFREE there's quite a bit of clean up
possible for now unnecessary goto paths.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 801 -
 1 file changed, 310 insertions(+), 491 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 98a35b0296..0a28ee3dd8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1101,32 +1101,31 @@ 
virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap,
 {
 int state_type;
 int name_type;
-int ret = -1;
 VIR_AUTOFREE(char *) name = NULL;
 VIR_AUTOFREE(char *) state = NULL;
 
 if (!(name = virXMLPropString(node, "name"))) {
 virReportError(VIR_ERR_CONF_SYNTAX, "%s",
_("missing name for cipher"));
-goto cleanup;
+return -1;
 }
 
 if ((name_type = virDomainKeyWrapCipherNameTypeFromString(name)) < 0) {
 virReportError(VIR_ERR_CONF_SYNTAX,
_("%s is not a supported cipher name"), name);
-goto cleanup;
+return -1;
 }
 
 if (!(state = virXMLPropString(node, "state"))) {
 virReportError(VIR_ERR_CONF_SYNTAX,
_("missing state for cipher named %s"), name);
-goto cleanup;
+return -1;
 }
 
 if ((state_type = virTristateSwitchTypeFromString(state)) < 0) {
 virReportError(VIR_ERR_CONF_SYNTAX,
_("%s is not a supported cipher state"), state);
-goto cleanup;
+return -1;
 }
 
 switch ((virDomainKeyWrapCipherName) name_type) {
@@ -1137,7 +1136,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr 
keywrap,
  "one cipher node with name %s"),
virDomainKeyWrapCipherNameTypeToString(name_type));
 
-goto cleanup;
+return -1;
 }
 keywrap->aes = state_type;
 break;
@@ -1149,7 +1148,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr 
keywrap,
  "one cipher node with name %s"),
virDomainKeyWrapCipherNameTypeToString(name_type));
 
-goto cleanup;
+return -1;
 }
 keywrap->dea = state_type;
 break;
@@ -1158,10 +1157,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr 
keywrap,
 break;
 }
 
-ret = 0;
-
- cleanup:
-return ret;
+return 0;
 }
 
 static int
@@ -1264,7 +1260,6 @@ static int
 virDomainVirtioOptionsParseXML(xmlNodePtr driver,
virDomainVirtioOptionsPtr *virtio)
 {
-int ret = -1;
 int val;
 virDomainVirtioOptionsPtr res;
 VIR_AUTOFREE(char *) str = NULL;
@@ -1281,7 +1276,7 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver,
 if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid iommu value"));
-goto cleanup;
+return -1;
 }
 res->iommu = val;
 }
@@ -1291,15 +1286,12 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver,
 if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid ats value"));
-goto cleanup;
+return -1;
 }
 res->ats = val;
 }
 
-ret = 0;
-
- cleanup:
-return ret;
+return 0;
 }
 
 
@@ -5333,7 +5325,6 @@ virDomainDefCollectBootOrder(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
  void *data)
 {
 virHashTablePtr bootHash = data;
-int ret = -1;
 VIR_AUTOFREE(char *) order = NULL;
 
 if (info->bootIndex == 0)
@@ -5348,22 +5339,19 @@ virDomainDefCollectBootOrder(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 return 0;
 }
 if (virAsprintf(, "%u", info->bootIndex) < 0)
-goto cleanup;
+return -1;
 
 if (virHashLookup(bootHash, order)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("boot order '%s' used for more than one device"),
order);
-goto cleanup;
+return -1;
 }
 
 if (virHashAddEntry(bootHash, order, (void *) 1) < 0)
-goto cleanup;
-
-ret = 0;
+return -1;
 
- cleanup:
-return ret;
+return 0;
 }
 
 
@@ -6883,7 +6871,6 @@ static int
 virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
  virDomainDeviceUSBMasterPtr master)
 {
-int ret = -1;
 VIR_AUTOFREE(char *) startport = NULL;
 
 memset(master, 0, sizeof(*master));
@@ -6894,27 +6881,23 @@ virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
 virStrToLong_ui(startport, NULL, 10, >startport) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse  'startport' attribute"));
-goto cleanup;
+return -1;
 

[libvirt] [PATCH v2 0/6] Alter domain_conf to make use of autofree

2019-02-20 Thread John Ferlan
v1: https://www.redhat.com/archives/libvir-list/2019-February/msg01160.html

Changes since v1:

 * Push patch 1 

 * Split patch 2 to follow code review guidance:

   * (Patch1) Pull out virDomainEmulatorPinDefParseXML changes to
   use VIR_STEAL_PTR
   * (Patch2) Use VIR_AUTOPTR(virBitmap) 
   * (Patch3) Handle a couple cases where goto's no longer necessary

 * Drop Patch 3

 * Split Patch 4 to follow code review guidance:

   * (Patch4) Remove unused variables
   * (Patch5) Just use VIR_AUTOFREE
   * (Patch6) Handle the removal of goto logic that's no longer necessary
  

John Ferlan (6):
  conf: Rework virDomainEmulatorPinDefParseXML
  conf: Use VIR_AUTOPTR(virBitmap) in domain_conf
  conf: Clean up some unnecessary goto paths
  conf: Remove a few unused variables in domain_conf
  conf: Use VIR_AUTOFREE in domain_conf
  conf: Clean up some unnecessary goto paths

 src/conf/domain_conf.c | 1937 ++--
 1 file changed, 676 insertions(+), 1261 deletions(-)

-- 
2.20.1

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


[libvirt] [glib PATCH v2 09/15] po: minimize id ilo is it ja ka kk km kn ko

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/id.mini.po|  20 +
 po/id.po | 153 ---
 po/ilo.mini.po   |  20 +
 po/ilo.po| 153 ---
 po/is.mini.po|  20 +
 po/is.po | 153 ---
 po/it.mini.po|  20 +
 po/it.po | 153 ---
 po/{ja.po => ja.mini.po} | 141 
 po/ka.mini.po|  20 +
 po/ka.po | 153 ---
 po/kk.mini.po|  20 +
 po/kk.po | 153 ---
 po/km.mini.po|  20 +
 po/km.po | 153 ---
 po/kn.mini.po|  20 +
 po/kn.po | 153 ---
 po/ko.mini.po|  20 +
 po/ko.po | 153 ---
 19 files changed, 225 insertions(+), 1473 deletions(-)
 create mode 100644 po/id.mini.po
 delete mode 100644 po/id.po
 create mode 100644 po/ilo.mini.po
 delete mode 100644 po/ilo.po
 create mode 100644 po/is.mini.po
 delete mode 100644 po/is.po
 create mode 100644 po/it.mini.po
 delete mode 100644 po/it.po
 rename po/{ja.po => ja.mini.po} (55%)
 create mode 100644 po/ka.mini.po
 delete mode 100644 po/ka.po
 create mode 100644 po/kk.mini.po
 delete mode 100644 po/kk.po
 create mode 100644 po/km.mini.po
 delete mode 100644 po/km.po
 create mode 100644 po/kn.mini.po
 delete mode 100644 po/kn.po
 create mode 100644 po/ko.mini.po
 delete mode 100644 po/ko.po

diff --git a/po/id.mini.po b/po/id.mini.po
new file mode 100644
index 000..66423de
--- /dev/null
+++ b/po/id.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:21+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Indonesian (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/id/)\n"
+"Language: id\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/id.po b/po/id.po
deleted file mode 100644
index 314ff45..000
--- a/po/id.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:21+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Indonesian (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/id/)\n"
-"Language: id\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: 

[libvirt] [glib PATCH v2 04/15] po: minimize & canonicalize translations stored in git

2019-02-20 Thread Daniel P . Berrangé
Similar to the libvirt-glib.pot, .po files contain line numbers and file
names identifying where in the source a translatable string comes from.
The source locations in the .po files are thrown away and replaced with
content from the libvirt-glib.pot whenever msgmerge is run, so this is not
precious information that needs to be stored in git.

When msgmerge processes a .po file, it will add in any msgids from the
libvirt-glib.pot that were not already present. Thus, if a particular msgid
currently has no translation, it can be considered redundant and again
does not need storing in git.

When msgmerge processes a .po file and can't find an exact existing
translation match, it will try todo fuzzy matching instead, marking such
entries with a "# fuzzy" comment to alert the translator to take a
look and either discard, edit or accept the match. Looking at the
existing fuzzy matches in .po files shows that the quality is awful,
with many having a completely different set of printf format specifiers
between the msgid and fuzzy msgstr entry. Fortunately when msgfmt
generates the .gmo, the fuzzy entries are all ignored anyway. The fuzzy
entries could be useful to translators if they were working on the .po
files directly from git, but Libvirt-Glib outsourced translation to the
Fedora Zanata system, so keeping fuzzy matches in git is not much help.

Finally, by default msgids are sorted based on source location. Thus, if
a bit of code with translatable text is moved from one file to another,
it may shift around in the .po file, despite the msgid not itself changing.
If the msgids were sorted alphabetically, the .po files would have
stable ordering when code is refactored.

This patch takes advantage of the above observations to canonicalize
and minimize the content stored for .po files in git. Instead of storing
the real .po files, we now store .mini.po files.

The .mini.po files are the same file format as .po files, but have no
source location comments, are sorted alphabetically, and all fuzzy
msgstrs and msgids with no translation are discarded. This cuts the size
of content in the po directory.

Users working from a libvirt-glib git checkout who need the full .po files
can run "make update-po", which merges the libvirt-glib.pot and .mini.po
file to create a .po file containing all the content previously stored
in git.

Conversely if a full .po file has been modified, for example, by
downloading new content from Zanata, the .mini.po files can be updated
by running "make update-mini-po". The resulting diffs of the .mini.po
file will clearly show the changed translations without any of the noise
that previously obscured content. Being able to see content changes
clearly actually identified a bug in the zanata python client where it
was adding bogus "fuzzy" annotations to many messages:

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

Users working from libvirt-glib releases should not see any difference in
behaviour, since the tarballs only contain the full .po files, not the
.mini.po files.

As an added benefit, generating tarballs with "make dist", will no
longer cause creation of dirty files in git, since it won't touch the
.mini.po files, only the .po files which are no longer kept in git.

The languages are minimized in the following commit since it is a
large mechanical process.

Signed-off-by: Daniel P. Berrangé 
---
 .gitignore   |  3 +++
 build-aux/minimize-po.pl | 37 +
 po/Makefile.am   | 29 +++-
 po/README.md | 58 +---
 4 files changed, 104 insertions(+), 23 deletions(-)
 create mode 100755 build-aux/minimize-po.pl

diff --git a/.gitignore b/.gitignore
index 10d0157..de89c4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,6 +83,9 @@ libvirt-gconfig/tests/test-domain-create
 libvirt-gconfig/tests/test-domain-parse
 .tx/
 po/*.gmo
+po/*po
+!po/*.mini.po
+po/*pot
 tests/test-events
 tests/test-gconfig
 tests/*.log
diff --git a/build-aux/minimize-po.pl b/build-aux/minimize-po.pl
new file mode 100755
index 000..497533a
--- /dev/null
+++ b/build-aux/minimize-po.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+my @block;
+my $msgstr = 0;
+my $empty = 0;
+my $unused = 0;
+my $fuzzy = 0;
+while (<>) {
+if (/^$/) {
+if (!$empty && !$unused && !$fuzzy) {
+print @block;
+}
+@block = ();
+$msgstr = 0;
+$fuzzy = 0;
+push @block, $_;
+} else {
+if (/^msgstr/) {
+$msgstr = 1;
+$empty = 1;
+}
+if (/^#.*fuzzy/) {
+$fuzzy = 1;
+}
+if (/^#~ msgstr/) {
+$unused = 1;
+}
+if ($msgstr && /".+"/) {
+$empty = 0;
+}
+push @block, $_;
+}
+}
+
+if (@block && !$empty && !$unused) {
+print @block;
+}
diff --git a/po/Makefile.am b/po/Makefile.am
index d66aec7..729de3f 100644
--- a/po/Makefile.am
+++ b/po/Makefile.am
@@ 

[libvirt] [glib PATCH v2 14/15] po: minimize uk ur vi wba yo zh_CN zh_HK zh_TW zu

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/{uk.po => uk.mini.po} | 152 +++---
 po/ur.mini.po|  20 +
 po/ur.po | 153 ---
 po/vi.mini.po|  20 +
 po/vi.po | 153 ---
 po/wba.mini.po   |  19 +
 po/wba.po| 152 --
 po/yo.mini.po|  19 +
 po/yo.po | 152 --
 po/zh_CN.mini.po |  20 +
 po/zh_CN.po  | 153 ---
 po/zh_HK.mini.po |  20 +
 po/zh_HK.po  | 153 ---
 po/zh_TW.mini.po |  20 +
 po/zh_TW.po  | 153 ---
 po/zu.mini.po|  20 +
 po/zu.po | 153 ---
 17 files changed, 216 insertions(+), 1316 deletions(-)
 rename po/{uk.po => uk.mini.po} (65%)
 create mode 100644 po/ur.mini.po
 delete mode 100644 po/ur.po
 create mode 100644 po/vi.mini.po
 delete mode 100644 po/vi.po
 create mode 100644 po/wba.mini.po
 delete mode 100644 po/wba.po
 create mode 100644 po/yo.mini.po
 delete mode 100644 po/yo.po
 create mode 100644 po/zh_CN.mini.po
 delete mode 100644 po/zh_CN.po
 create mode 100644 po/zh_HK.mini.po
 delete mode 100644 po/zh_HK.po
 create mode 100644 po/zh_TW.mini.po
 delete mode 100644 po/zh_TW.po
 create mode 100644 po/zu.mini.po
 delete mode 100644 po/zu.po

diff --git a/po/uk.po b/po/uk.mini.po
similarity index 65%
rename from po/uk.po
rename to po/uk.mini.po
index bd37f63..a0ab0ff 100644
--- a/po/uk.po
+++ b/po/uk.mini.po
@@ -1,5 +1,5 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
 #
 # Translators:
@@ -8,9 +8,9 @@
 # Yuri Chornoivan , 2017. #zanata
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
 "PO-Revision-Date: 2017-12-06 12:39+\n"
 "Last-Translator: Yuri Chornoivan \n"
 "Language-Team: Ukrainian (http://www.transifex.com/projects/p/libvirt-glib/;
@@ -23,135 +23,99 @@ msgstr ""
 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
 "X-Generator: Zanata 4.6.2\n"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr "Немає документа XML для обробки"
+#, c-format
+msgid "Connection %s is already open"
+msgstr "З’єднання %s вже відкрито"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr "Не вдалося обробити налаштування"
+msgid "Connection is not open"
+msgstr "З'єднання не відкрито"
+
+msgid "Connection is not opened"
+msgstr "З’єднання не відкрито"
+
+msgid "Failed to create domain"
+msgstr "Не вдалося створити домен"
+
+msgid "Failed to create storage pool"
+msgstr "Не вдалося створити резервне сховище"
+
+msgid "Failed to fetch list of domains"
+msgstr "Не вдалося отримати список доменів"
+
+msgid "Failed to fetch list of interfaces"
+msgstr "Не вдалося отримати список інтерфейсів"
+
+msgid "Failed to fetch list of networks"
+msgstr "Не вдалося отримати список мереж"
+
+msgid "Failed to fetch list of pools"
+msgstr "Не вдалося отримати список буферів"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
 #, c-format
-msgid "XML data has no '%s' node"
-msgstr "У даних XML немає вузла «%s»"
+msgid "Got virStreamRecv error in %s"
+msgstr "Отримано повідомлення про помилку virStreamRecv у %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
 msgid "No XML document associated with this config object"
 msgstr "З цим об’єктом налаштування не пов’язано жодного документа XML"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
+msgid "No XML document to parse"
+msgstr "Немає документа XML для обробки"
+
 msgid "No XML schema associated with this config object"
 msgstr "З цим об’єктом налаштування не пов’язано жодної схеми XML"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
 #, c-format
 msgid "Unable to create RNG parser for %s"
 msgstr "Не вдалося створити обробник RNG для %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr "Не вдалося обробити RNG, %s"
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
 #, c-format
 msgid "Unable to create RNG validation context %s"
 msgstr "Не вдалося створити контекст перевірки RNG, %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr "Не вдалося перевірити документи"
-
-#: 

[libvirt] [glib PATCH v2 01/15] po: provide custom make rules for po file management

2019-02-20 Thread Daniel P . Berrangé
Historically we have relied on intltool to install a standard
po/Makefile.in.in which has very limited scope for customization.
intltool is deprecated in favour of standard gettextize tools,
but these share the same disadvantages.

Writing make rules for po file management is no more difficult
than any other rules libvirt-glib has, so stop using intltool
and don't use gettextize ether.

Signed-off-by: Daniel P. Berrangé 
---
 .gitignore   |   8 ---
 autogen.sh   |   3 +-
 configure.ac |   8 ++-
 libvirt-gconfig/Makefile.am  |   1 +
 libvirt-glib.spec.in |   2 +-
 libvirt-glib/Makefile.am |   1 +
 libvirt-gobject/Makefile.am  |   1 +
 m4/virt-gettext.m4   |   5 --
 m4/virt-nls.m4   |  45 
 mingw-libvirt-glib.spec.in   |   2 +-
 po/Makefile.am   | 100 +++
 po/{POTFILES.in => POTFILES} |   0
 po/README.md |  38 +
 13 files changed, 192 insertions(+), 22 deletions(-)
 delete mode 100644 m4/virt-gettext.m4
 create mode 100644 m4/virt-nls.m4
 create mode 100644 po/Makefile.am
 rename po/{POTFILES.in => POTFILES} (100%)
 create mode 100644 po/README.md

diff --git a/.gitignore b/.gitignore
index 116bb12..10d0157 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,7 +22,6 @@ Makefile.in
 m4/ltsugar.m4
 m4/lt~obsolete.m4
 m4/libtool.m4
-m4/intltool.m4
 m4/ltversion.m4
 m4/ltoptions.m4
 autom4te.cache
@@ -83,14 +82,7 @@ libvirt-gconfig/tests/test-capabilities-parse
 libvirt-gconfig/tests/test-domain-create
 libvirt-gconfig/tests/test-domain-parse
 .tx/
-po/Makefile
-po/Makefile.in
-po/Makefile.in.in
-po/POTFILES
-po/libvirt-glib.pot
-po/stamp-it
 po/*.gmo
-po/.zanata-cache/
 tests/test-events
 tests/test-gconfig
 tests/*.log
diff --git a/autogen.sh b/autogen.sh
index 4f7135f..3b593ce 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -10,7 +10,7 @@ cd $srcdir
 
 DIE=0
 
-for prog in intltoolize autoreconf automake autoconf libtoolize
+for prog in autoreconf automake autoconf libtoolize
 do
 ($prog --version) < /dev/null > /dev/null 2>&1 || {
 echo
@@ -35,7 +35,6 @@ fi
 touch ChangeLog AUTHORS
 
 mkdir -p build-aux
-intltoolize --force
 autoreconf -if
 
 cd $THEDIR
diff --git a/configure.ac b/configure.ac
index dc743bb..6b66f5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,10 +112,8 @@ PKG_CHECK_MODULES(GOBJECT2, gobject-2.0 >= $GLIB2_REQUIRED)
 PKG_CHECK_MODULES(GIO2, gio-2.0 >= $GLIB2_REQUIRED)
 PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
 
-LIBVIRT_GLIB_GETTEXT
-dnl Should be in m4/virt-gettext.m4 but intltoolize is too
-dnl dumb to find it there
-IT_PROG_INTLTOOL([0.35.0])
+LIBVIRT_GLIB_ARG_NLS
+LIBVIRT_GLIB_CHECK_NLS
 
 
 GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
@@ -218,7 +216,7 @@ AC_OUTPUT(Makefile
   docs/libvirt-glib/version.xml
   docs/libvirt-gobject/Makefile
   docs/libvirt-gconfig/Makefile
-  po/Makefile.in
+  po/Makefile
   tests/Makefile
   libvirt-glib-1.0.pc
   libvirt-gconfig-1.0.pc
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index cfcc0e4..b976e4d 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -201,6 +201,7 @@ libvirt_gconfig_1_0_la_SOURCES = \
 nodist_libvirt_gconfig_1_0_la_SOURCES = \
$(GCONFIG_GENERATED_FILES)
 libvirt_gconfig_1_0_la_CFLAGS = \
+   -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GConfig\"" \
-DDATADIR="\"$(datadir)\"" \
-DLIBVIRT_GCONFIG_BUILD \
diff --git a/libvirt-glib.spec.in b/libvirt-glib.spec.in
index 7e02c83..877cc2f 100644
--- a/libvirt-glib.spec.in
+++ b/libvirt-glib.spec.in
@@ -37,7 +37,7 @@ BuildRequires: libtool
 %if %{with_vala}
 BuildRequires: vala-tools
 %endif
-BuildRequires: intltool
+BuildRequires: gettext
 
 %package devel
 Group: Development/Libraries
diff --git a/libvirt-glib/Makefile.am b/libvirt-glib/Makefile.am
index 12a390f..fa52352 100644
--- a/libvirt-glib/Makefile.am
+++ b/libvirt-glib/Makefile.am
@@ -16,6 +16,7 @@ libvirt_glib_1_0_la_SOURCES = \
libvirt-glib-main.c
 libvirt_glib_1_0_la_CFLAGS = \
-DLIBVIRT_GLIB_BUILD \
+   -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GLib\"" \
-DLOCALEDIR="\"$(datadir)/locale\"" \
$(COVERAGE_CFLAGS) \
diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 5e130ee..210c753 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -66,6 +66,7 @@ libvirt_gobject_1_0_la_SOURCES = \
 nodist_libvirt_gobject_1_0_la_SOURCES = \
$(GOBJECT_GENERATED_FILES)
 libvirt_gobject_1_0_la_CFLAGS = \
+   -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
 

[libvirt] [glib PATCH v2 03/15] po: add rules for integration with zanata

2019-02-20 Thread Daniel P . Berrangé
Add rules to handle pushing libvirt-glib.pot to zanata, and refreshing .po
files with new content from zanata.

Signed-off-by: Daniel P. Berrangé 
---
 po/Makefile.am | 8 
 1 file changed, 8 insertions(+)

diff --git a/po/Makefile.am b/po/Makefile.am
index f2818c7..d66aec7 100644
--- a/po/Makefile.am
+++ b/po/Makefile.am
@@ -60,6 +60,14 @@ update-po: $(POFILES)
 
 update-gmo: $(GMOFILES)
 
+push-pot: $(POTFILE)
+   zanata push --push-type=source
+
+pull-po: $(POTFILE)
+   zanata pull --create-skeletons
+   $(MAKE) update-po
+   $(MAKE) update-gmo
+
 $(POTFILE): POTFILES $(POTFILE_DEPS)
$(XGETTEXT) -o $@-t $(XGETTEXT_ARGS) \
  --files-from=$(abs_srcdir)/POTFILES
-- 
2.20.1

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

[libvirt] [glib PATCH v2 00/15] po: improve translation handling

2019-02-20 Thread Daniel P . Berrangé
This applies the same improvements previously done in libvirt:

  https://www.redhat.com/archives/libvir-list/2018-April/msg01004.html
  
https://www.berrange.com/posts/2018/11/29/improved-translation-po-file-handling-by-ditching-gettext-autotools-integration/

The key problems with our current approach are:

 - The pot & po files stored in GIT contain huge set of
   annotations about source file names & line numbers.
   These are out of date as soon as a change is commited
   to git following a translation refresh. This makes
   diffs impossible to meaningfully review, as they are
   98% noise, 2% signal.

 - The po file messages are sorted by source location,
   so when we move code between files, or rename files,
   the po file message order changes for no good reason.
   This makes diffs even more impossible to review.

 - The po files contain entries for all messages even
   if most have no translation, bloating size of po/
   data stored in git

 - Whenever 'make dist' is run, it alters all the pot
   and po files, so developers need to then reset their
   content to match git HEAD manually. This is caused
   by having auto-generated content (source file locations)
   mixed in with the static content (the actual translated
   strings)

After this series, we only minimized po files in git, with
the redundated & outdated source locations info stripped.
This stripped info is re-added automatically during build
to create the real .po files, that we distribute, and/or
upload to translators in Zanata.

As a result the po directory is smaller in size, and
when refreshing from Zanata, we have git commits that
clearly show *only* the altered translations, nothing
else. The importance of this cannot be overstated - by
having these clear diffs when doing this change in libvirt,
I discovered a serious bug in the Zanata client that has
been screwing up translations in every project that uses
Zanata by adding bogus "fuzzy" annotations.

The particularly attractive statistic:

 194 files changed, 2607 insertions(+), 14146 deletions(-)

Changed in v2:

 - Fix a number of problems with VPATH builds

Daniel P. Berrangé (15):
  po: provide custom make rules for po file management
  po: remove language list from zanata configuration
  po: add rules for integration with zanata
  po: minimize & canonicalize translations stored in git
  po: minimize af am anp ar as ast bal be bg bn_IN
  po: minimize bn bo br brx bs ca cs cy da de_CH
  po: minimize de el en_GB eo es et eu fa fi
  po: minimize fr gl gu he hi hr hu ia
  po: minimize id ilo is it ja ka kk km kn ko
  po: minimize kw_GB kw@kkcor kw kw@uccor ky lt lv mai mk ml
  po: minimize mn mr ms nb nds ne nl nn nso
  po: minimize or pa pl pt_BR pt ro ru si sk sl
  po: minimize sq sr@latin sr sv ta te tg th tr tw
  po: minimize uk ur vi wba yo zh_CN zh_HK zh_TW zu
  po: refresh translations from zanata

 .gitignore |  11 +--
 autogen.sh |   3 +-
 build-aux/minimize-po.pl   |  37 
 configure.ac   |   8 +-
 libvirt-gconfig/Makefile.am|   1 +
 libvirt-glib.spec.in   |   2 +-
 libvirt-glib/Makefile.am   |   1 +
 libvirt-gobject/Makefile.am|   1 +
 m4/virt-gettext.m4 |   5 --
 m4/virt-nls.m4 |  45 ++
 mingw-libvirt-glib.spec.in |   2 +-
 po/Makefile.am | 111 +++
 po/{POTFILES.in => POTFILES}   |   0
 po/README.md   |  76 
 po/af.mini.po  |  20 +
 po/af.po   | 153 
 po/am.mini.po  |  20 +
 po/am.po   | 153 
 po/anp.mini.po |  19 
 po/anp.po  | 152 ---
 po/ar.mini.po  |  21 +
 po/ar.po   | 154 
 po/as.mini.po  |  20 +
 po/as.po   | 153 
 po/ast.mini.po |  20 +
 po/ast.po  | 153 
 po/bal.mini.po |  20 +
 po/bal.po  | 153 
 po/be.mini.po  |  21 +
 po/be.po   | 154 
 po/bg.mini.po  |  20 +
 po/bg.po   | 153 
 po/bn.mini.po  |  20 +
 po/bn.po   | 153 
 po/bn_IN.mini.po   |  20 +
 po/bn_IN.po| 153 
 po/bo.mini.po  |  20 +
 po/bo.po   | 153 
 po/br.mini.po  |  20 +
 po/br.po   | 153 
 

[libvirt] [glib PATCH v2 06/15] po: minimize bn bo br brx bs ca cs cy da de_CH

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/bn.mini.po|  20 +
 po/bn.po | 153 -
 po/bo.mini.po|  20 +
 po/bo.po | 153 -
 po/br.mini.po|  20 +
 po/br.po | 153 -
 po/brx.mini.po   |  20 +
 po/brx.po| 153 -
 po/bs.mini.po|  21 ++
 po/bs.po | 154 --
 po/{ca.po => ca.mini.po} | 152 ++---
 po/{cs.po => cs.mini.po} | 158 +++
 po/cy.mini.po|  21 ++
 po/cy.po | 154 --
 po/da.mini.po|  20 +
 po/da.po | 153 -
 po/de_CH.mini.po |  20 +
 po/de_CH.po  | 153 -
 18 files changed, 281 insertions(+), 1417 deletions(-)
 create mode 100644 po/bn.mini.po
 delete mode 100644 po/bn.po
 create mode 100644 po/bo.mini.po
 delete mode 100644 po/bo.po
 create mode 100644 po/br.mini.po
 delete mode 100644 po/br.po
 create mode 100644 po/brx.mini.po
 delete mode 100644 po/brx.po
 create mode 100644 po/bs.mini.po
 delete mode 100644 po/bs.po
 rename po/{ca.po => ca.mini.po} (62%)
 rename po/{cs.po => cs.mini.po} (57%)
 create mode 100644 po/cy.mini.po
 delete mode 100644 po/cy.po
 create mode 100644 po/da.mini.po
 delete mode 100644 po/da.po
 create mode 100644 po/de_CH.mini.po
 delete mode 100644 po/de_CH.po

diff --git a/po/bn.mini.po b/po/bn.mini.po
new file mode 100644
index 000..3657a5c
--- /dev/null
+++ b/po/bn.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:19+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Bengali (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/bn/)\n"
+"Language: bn\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/bn.po b/po/bn.po
deleted file mode 100644
index b08bf7d..000
--- a/po/bn.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:19+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Bengali (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/bn/)\n"
-"Language: bn\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1761
-msgid "Connection is not 

[libvirt] [glib PATCH v2 08/15] po: minimize fr gl gu he hi hr hu ia

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/{fr.po => fr.mini.po} | 156 +++
 po/gl.mini.po|  20 +
 po/gl.po | 153 --
 po/gu.mini.po|  20 +
 po/gu.po | 153 --
 po/he.mini.po|  20 +
 po/he.po | 153 --
 po/{hi.po => hi.mini.po} | 141 +++
 po/hr.mini.po|  21 ++
 po/hr.po | 154 --
 po/hu.mini.po|  20 +
 po/hu.po | 153 --
 po/ia.mini.po|  20 +
 po/ia.po | 153 --
 14 files changed, 225 insertions(+), 1112 deletions(-)
 rename po/{fr.po => fr.mini.po} (58%)
 create mode 100644 po/gl.mini.po
 delete mode 100644 po/gl.po
 create mode 100644 po/gu.mini.po
 delete mode 100644 po/gu.po
 create mode 100644 po/he.mini.po
 delete mode 100644 po/he.po
 rename po/{hi.po => hi.mini.po} (62%)
 create mode 100644 po/hr.mini.po
 delete mode 100644 po/hr.po
 create mode 100644 po/hu.mini.po
 delete mode 100644 po/hu.po
 create mode 100644 po/ia.mini.po
 delete mode 100644 po/ia.po

diff --git a/po/fr.po b/po/fr.mini.po
similarity index 58%
rename from po/fr.po
rename to po/fr.mini.po
index f5a8978..c61b518 100644
--- a/po/fr.po
+++ b/po/fr.mini.po
@@ -1,16 +1,17 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
 #
 # Translators:
 # Jérôme Fenal , 2013
 # Jean-Baptiste Holcroft , 2016. #zanata
+# Jean-Baptiste Holcroft , 2019. #zanata
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2016-07-15 05:10+\n"
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2019-01-21 08:05+\n"
 "Last-Translator: Jean-Baptiste Holcroft \n"
 "Language-Team: French (http://www.transifex.com/projects/p/libvirt-glib/;
 "language/fr/)\n"
@@ -21,135 +22,96 @@ msgstr ""
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 "X-Generator: Zanata 4.6.2\n"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr "Aucun document XML à analyser"
+#, c-format
+msgid "Connection %s is already open"
+msgstr "La connexion %s est déjà ouverte"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr "Impossible d'analyser la configuration"
+msgid "Connection is not open"
+msgstr "La connexion n'est pas ouverte"
+
+msgid "Connection is not opened"
+msgstr "La connexion n'est pas ouverte"
+
+msgid "Failed to create domain"
+msgstr "Échec de la création du domaine"
+
+msgid "Failed to create storage pool"
+msgstr "Échec de la création du pool de stockage"
+
+msgid "Failed to fetch list of domains"
+msgstr "Impossible de récupérer la liste des domaines"
+
+msgid "Failed to fetch list of interfaces"
+msgstr "Impossible de récupérer la liste des interfaces"
+
+msgid "Failed to fetch list of networks"
+msgstr "Impossible de récupérer la liste des réseaux"
+
+msgid "Failed to fetch list of pools"
+msgstr "Impossible de récupérer la liste des pools"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
 #, c-format
-msgid "XML data has no '%s' node"
-msgstr "Les données XML n'ont pas de nœud « %s »"
+msgid "Got virStreamRecv error in %s"
+msgstr "Erreur virStreamRecv survenue dans %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
 msgid "No XML document associated with this config object"
 msgstr "Aucun document XML associé avec cet objet de configuration"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
+msgid "No XML document to parse"
+msgstr "Aucun document XML à analyser"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
 #, c-format
 msgid "Unable to create RNG parser for %s"
 msgstr "Impossible de créer l'analyseur RNG pour %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr "Impossible d'analyser le RNG %s"
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
 #, c-format
 msgid "Unable to create RNG validation context %s"
 msgstr "Impossible de créer un contexte de validation RNG %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr "Impossible de valider le document"
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr "La connexion %s est déjà ouverte"
-
-#: 

Re: [libvirt] [PATCH 4/4] conf: Use VIR_AUTOFREE in domain_conf

2019-02-20 Thread John Ferlan



On 2/20/19 10:47 AM, Ján Tomko wrote:
> On Wed, Feb 20, 2019 at 09:46:59AM -0500, John Ferlan wrote:
>> Let's make use of the auto __cleanup capabilities cleaning up any
>> now unnecessary goto paths.
>>
> 
> At this scale, separating the AUTOFREE conversion and the return values
> would really make this easier to read.

Fair enough.

> 
> Also, this fails compilation with clang.
> 
>> Signed-off-by: John Ferlan 
>> ---
>> src/conf/domain_conf.c | 1890 ++--
>> 1 file changed, 660 insertions(+), 1230 deletions(-)
>>
> 
>> @@ -7138,11 +7092,11 @@
>> virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt
>> ATTRIBUTE_UNUSED,
>>     xmlNodePtr alias = NULL;
>>     xmlNodePtr boot = NULL;
>>     xmlNodePtr rom = NULL;
>> -    char *type = NULL;
>> -    char *romenabled = NULL;
>> -    char *rombar = NULL;
>> -    char *aliasStr = NULL;
>>     int ret = -1;
>> +    VIR_AUTOFREE(char *) type = NULL;
> 
> conf/domain_conf.c:7096:26: error: unused variable 'type'
> [-Werror,-Wunused-variable]
>    VIR_AUTOFREE(char *) type = NULL;
>     ^
> 

Well gcc doesn't complain, but I see it's not used.  I'll insert a
cleanup patch before this one.

John

>> +    VIR_AUTOFREE(char *) romenabled = NULL;
>> +    VIR_AUTOFREE(char *) rombar = NULL;
>> +    VIR_AUTOFREE(char *) aliasStr = NULL;
>>
>>     virDomainDeviceInfoClear(info);
>>
>> @@ -13013,15 +12748,15 @@
>> virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
>>     xmlXPathContextPtr ctxt,
>>     unsigned int flags)
>> {
>> -    char *type = NULL;
>> -    char *path = NULL;
>> -    char *model = NULL;
>> -    char *backend = NULL;
>> -    char *version = NULL;
>>     virDomainTPMDefPtr def;
>>     xmlNodePtr save = ctxt->node;
>> -    xmlNodePtr *backends = NULL;
>>     int nbackends;
>> +    VIR_AUTOFREE(char *) type = NULL;
> 
> conf/domain_conf.c:12754:26: error: unused variable 'type'
> [-Werror,-Wunused-variable]
>    VIR_AUTOFREE(char *) type = NULL;
>     ^
> 
>> +    VIR_AUTOFREE(char *) path = NULL;
>> +    VIR_AUTOFREE(char *) model = NULL;
>> +    VIR_AUTOFREE(char *) backend = NULL;
>> +    VIR_AUTOFREE(char *) version = NULL;
>> +    VIR_AUTOFREE(xmlNodePtr *) backends = NULL;
>>
>>     if (VIR_ALLOC(def) < 0)
>>     return NULL;
>> @@ -18549,7 +18093,8 @@ virDomainHugepagesParseXML(xmlNodePtr node,
>> {
>>     int ret = -1;
>>     xmlNodePtr oldnode = ctxt->node;
>> -    char *unit = NULL, *nodeset = NULL;
>> +    VIR_AUTOFREE(char *) unit = NULL;
> 
> conf/domain_conf.c:18096:26: error: unused variable 'unit'
> [-Werror,-Wunused-variable]
>    VIR_AUTOFREE(char *) unit = NULL;
>     ^
> 
>> +    VIR_AUTOFREE(char *) nodeset = NULL;
>>
>>     ctxt->node = node;
>>
> 
> Jano

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


[libvirt] [PATCH 7/7] snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST flag

2019-02-20 Thread Eric Blake
Continue the work of the previous patch in making it possible
to copy the state of a transient domain with snapshots from one
host to another, by allowing the destination to perform bulk
redefines.  Note that the destination still has to do separate
calls for creating/defining the domain first, and then redefining
the snapshots (that is, there is intentional asymmetry between
dumping the list in virDomainGetXMLDesc() but redefining it via
virDomainSnapshotCreateXML()), but this is better than the
previous state of having to make multiple REDEFINE calls.  The
bulk flag requires no pre-existing snapshot metadata (as that
makes life much easier if there is a failure encountered partway
through the list processing - simply remove all other snapshot
metadatas), and makes no guarantees on which snapshot (when there
are multiple) will actually be returned.

Wire up the virsh snapshot-create command to support the new flag.

Actual driver implementations will be in later patches.

Signed-off-by: Eric Blake 
---
 include/libvirt/libvirt-domain-snapshot.h |  3 +++
 src/libvirt-domain-snapshot.c | 21 ++---
 tools/virsh-snapshot.c| 13 +
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/include/libvirt/libvirt-domain-snapshot.h 
b/include/libvirt/libvirt-domain-snapshot.h
index 2532b99c58..113fe4a18b 100644
--- a/include/libvirt/libvirt-domain-snapshot.h
+++ b/include/libvirt/libvirt-domain-snapshot.h
@@ -71,6 +71,9 @@ typedef enum {
 VIR_DOMAIN_SNAPSHOT_CREATE_LIVE= (1 << 8), /* create the snapshot
   while the guest is
   running */
+VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST = (1 << 9), /* parse multiple
+snapshots in one
+API call */
 } virDomainSnapshotCreateFlags;

 /* Take a snapshot of the current VM state */
diff --git a/src/libvirt-domain-snapshot.c b/src/libvirt-domain-snapshot.c
index 4e46f0876b..a661bcbff9 100644
--- a/src/libvirt-domain-snapshot.c
+++ b/src/libvirt-domain-snapshot.c
@@ -102,7 +102,7 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot)
  * @flags: bitwise-OR of virDomainSnapshotCreateFlags
  *
  * Creates a new snapshot of a domain based on the snapshot xml
- * contained in xmlDesc.
+ * contained in xmlDesc, with a top-level  element.
  *
  * If @flags is 0, the domain can be active, in which case the
  * snapshot will be a system checkpoint (both disk state and runtime
@@ -131,8 +131,17 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot)
  * guest-visible layout.  When redefining a snapshot name that does
  * not exist, the hypervisor may validate that reverting to the
  * snapshot appears to be possible (for example, disk images have
- * snapshot contents by the requested name).  Not all hypervisors
- * support these flags.
+ * snapshot contents by the requested name).  Alternatively, if @flags
+ * includes VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST (which requires
+ * VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and is incompatible with
+ * VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT), and the domain has no existing
+ * snapshot metadata, then @xmlDesc is parsed as a top-level
+ *  element with an optional current='name' attribute, and
+ * containing one or more  children (as produced by
+ * virDomainGetXMLDesc() with the flag VIR_DOMAIN_XML_SNAPSHOTS), to
+ * do a bulk redefine of all snapshots at once (it is unspecified
+ * which of the redefined snapshots will be used as the return value
+ * on success).  Not all hypervisors support these flags.
  *
  * If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, then the
  * domain's disk images are modified according to @xmlDesc, but then
@@ -218,6 +227,9 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
 VIR_REQUIRE_FLAG_GOTO(VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT,
   VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE,
   error);
+VIR_REQUIRE_FLAG_GOTO(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST,
+  VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE,
+  error);

 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE,
  VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA,
@@ -225,6 +237,9 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE,
  VIR_DOMAIN_SNAPSHOT_CREATE_HALT,
  error);
+VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST,
+ VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT,
+ error);

 if (conn->driver->domainSnapshotCreateXML) {
 virDomainSnapshotPtr ret;
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 

[libvirt] [PATCH 5/7] domain: Expand virDomainDefFormatInternal with snapshots

2019-02-20 Thread Eric Blake
Make it possible to grab all snapshot XMLs via a single API
call, by adding a new internal flag.  All callers are adjusted,
for now passing NULL and not using the new flag. A new wrapper
virDomainDefFormatFull() is added to make it easier for the
next patch to add a few callers without having to revisit all
existing clients of virDomainDefFormat().

Signed-off-by: Eric Blake 
---
 src/conf/domain_conf.h  |  8 +
 src/conf/domain_conf.c  | 58 +++--
 src/conf/snapshot_conf.c|  4 +--
 src/network/bridge_driver.c |  3 +-
 src/qemu/qemu_domain.c  |  2 +-
 5 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9bccd8bcd1..9b13c147da 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3047,6 +3047,7 @@ typedef enum {
 VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM   = 1 << 6,
 VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT  = 1 << 7,
 VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST= 1 << 8,
+VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS   = 1 << 9,
 } virDomainDefFormatFlags;

 /* Use these flags to skip specific domain ABI consistency checks done
@@ -3124,12 +3125,19 @@ unsigned int virDomainDefFormatConvertXMLFlags(unsigned 
int flags);
 char *virDomainDefFormat(virDomainDefPtr def,
  virCapsPtr caps,
  unsigned int flags);
+char *virDomainDefFormatFull(virDomainDefPtr def,
+ virCapsPtr caps,
+ virDomainSnapshotObjListPtr snapshots,
+ virDomainSnapshotObjPtr current_snapshot,
+ unsigned int flags);
 char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
  virDomainObjPtr obj,
  virCapsPtr caps,
  unsigned int flags);
 int virDomainDefFormatInternal(virDomainDefPtr def,
virCapsPtr caps,
+   virDomainSnapshotObjListPtr snapshots,
+   virDomainSnapshotObjPtr current_snapshot,
unsigned int flags,
virBufferPtr buf,
virDomainXMLOptionPtr xmlopt);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 56c437ca0a..ae496834ee 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1,7 +1,7 @@
 /*
  * domain_conf.c: domain XML processing
  *
- * Copyright (C) 2006-2016 Red Hat, Inc.
+ * Copyright (C) 2006-2019 Red Hat, Inc.
  * Copyright (C) 2006-2008 Daniel P. Berrange
  * Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
  *
@@ -28264,6 +28264,8 @@ virDomainVsockDefFormat(virBufferPtr buf,
 int
 virDomainDefFormatInternal(virDomainDefPtr def,
virCapsPtr caps,
+   virDomainSnapshotObjListPtr snapshots,
+   virDomainSnapshotObjPtr current_snapshot,
unsigned int flags,
virBufferPtr buf,
virDomainXMLOptionPtr xmlopt)
@@ -28281,9 +28283,16 @@ virDomainDefFormatInternal(virDomainDefPtr def,
   VIR_DOMAIN_DEF_FORMAT_STATUS |
   VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
   VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
-  VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST,
+  VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST |
+  VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS,
   -1);

+if ((flags & VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS) && !snapshots) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("snapshots requested but not provided"));
+goto error;
+}
+
 if (!(type = virDomainVirtTypeToString(def->virtType))) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected domain type %d"), def->virtType);
@@ -29068,6 +29077,23 @@ virDomainDefFormatInternal(virDomainDefPtr def,

 virDomainSEVDefFormat(buf, def->sev);

+if (flags & VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS) {
+unsigned int snapflags = flags & VIR_DOMAIN_DEF_FORMAT_SECURE ?
+VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE : 0;
+
+virBufferAddLit(buf, "def->name);
+virBufferAddLit(buf, ">\n");
+virBufferAdjustIndent(buf, 2);
+if (virDomainSnapshotObjListFormat(buf, uuidstr, snapshots, caps,
+   xmlopt, snapflags))
+goto error;
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, "\n");
+}
+
 virBufferAdjustIndent(buf, -2);
 virBufferAddLit(buf, "\n");

@@ -29103,16 +29129,29 @@ unsigned int 
virDomainDefFormatConvertXMLFlags(unsigned int flags)
 }


+char *
+virDomainDefFormatFull(virDomainDefPtr def, virCapsPtr caps,
+   virDomainSnapshotObjListPtr snapshots,
+   

[libvirt] [PATCH 2/7] snapshot: Give virDomainSnapshotDefFormat its own flags

2019-02-20 Thread Eric Blake
virDomainSnapshotDefFormat currently takes two sets of knobs:
an 'unsigned int flags' argument that can currently just be
VIR_DOMAIN_DEF_FORMAT_SECURE, and an 'int internal' argument used as
a bool to determine whether to output an additional element.  It
then reuses the 'flags' knob to call into virDomainDefFormatInternal(),
which takes a different set of flags. In fact, prior to commit 0ecd6851
(1.2.12), the 'flags' argument actually took the public
VIR_DOMAIN_XML_SECURE, which was even more confusing.  Let's borrow
from the style of that earlier commit, by introducing a function
for translating from the public flags (VIR_DOMAIN_SNAPSHOT_XML_SECURE
was just recently introduced) into a new enum specific to snapshot
formatting, and adjust all callers to use snapshot-specific enum
values when formatting, and where the formatter now uses a new
variable 'domainflags' to make it obvious when we are translating
from snapshot flags back to domain flags.  We don't even have to
use the conversion function for drivers that don't accept the
public VIR_DOMAIN_SNAPSHOT_XML_SECURE flag.

Signed-off-by: Eric Blake 
---
 src/conf/snapshot_conf.h  | 10 --
 src/conf/snapshot_conf.c  | 28 ++--
 src/esx/esx_driver.c  |  1 -
 src/libvirt_private.syms  |  1 +
 src/qemu/qemu_domain.c|  3 +--
 src/qemu/qemu_driver.c|  3 +--
 src/test/test_driver.c|  3 +--
 src/vbox/vbox_common.c|  5 ++---
 src/vz/vz_driver.c|  3 +--
 tests/domainsnapshotxml2xmltest.c | 16 +---
 10 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index cc25164261..f990ec8f90 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -101,6 +101,13 @@ typedef enum {
 VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE  = 1 << 3,
 } virDomainSnapshotParseFlags;

+typedef enum {
+VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE   = 1 << 0,
+VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL = 1 << 1,
+} virDomainSnapshotFormatFlags;
+
+unsigned int virDomainSnapshotFormatConvertXMLFlags(unsigned int flags);
+
 virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
 virCapsPtr caps,
 virDomainXMLOptionPtr 
xmlopt,
@@ -115,8 +122,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
  virDomainSnapshotDefPtr def,
  virCapsPtr caps,
  virDomainXMLOptionPtr xmlopt,
- unsigned int flags,
- int internal);
+ unsigned int flags);
 int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
 int default_snapshot,
 bool require_match);
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 1afc7de30c..b8012cb111 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -652,6 +652,19 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
 return ret;
 }

+/* Converts public VIR_DOMAIN_SNAPSHOT_XML_* into
+ * VIR_DOMAIN_SNAPSHOT_FORMAT_* flags, and silently ignores any other
+ * flags.  */
+unsigned int virDomainSnapshotFormatConvertXMLFlags(unsigned int flags)
+{
+unsigned int formatFlags = 0;
+
+if (flags & VIR_DOMAIN_SNAPSHOT_XML_SECURE)
+formatFlags |= VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE;
+
+return formatFlags;
+}
+
 static int
 virDomainSnapshotDiskDefFormat(virBufferPtr buf,
virDomainSnapshotDiskDefPtr disk,
@@ -692,15 +705,17 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
virDomainSnapshotDefPtr def,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
-   unsigned int flags,
-   int internal)
+   unsigned int flags)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 size_t i;
+int domainflags = VIR_DOMAIN_DEF_FORMAT_INACTIVE;

-virCheckFlags(VIR_DOMAIN_DEF_FORMAT_SECURE, NULL);
+virCheckFlags(VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE |
+  VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL, NULL);

-flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
+if (flags & VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE)
+domainflags |= VIR_DOMAIN_DEF_FORMAT_SECURE;

 virBufferAddLit(, "\n");
 virBufferAdjustIndent(, 2);
@@ -742,7 +757,8 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
 }

 if (def->dom) {
-if (virDomainDefFormatInternal(def->dom, caps, flags, , xmlopt) < 
0)
+if (virDomainDefFormatInternal(def->dom, caps, domainflags, ,
+   xmlopt) < 0)
 goto error;
 } 

[libvirt] [PATCH 3/7] snapshot: Refactor virDomainSnapshotDefFormat

2019-02-20 Thread Eric Blake
Split out an internal helper that produces format into a
virBuffer, similar to what domain_conf.c does, and making
the next patch easier to write.

Signed-off-by: Eric Blake 
---
 src/conf/snapshot_conf.c | 103 ++-
 1 file changed, 59 insertions(+), 44 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index b8012cb111..b7b5873cbe 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -700,92 +700,107 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
 }


-char *
-virDomainSnapshotDefFormat(const char *domain_uuid,
-   virDomainSnapshotDefPtr def,
-   virCapsPtr caps,
-   virDomainXMLOptionPtr xmlopt,
-   unsigned int flags)
+static int
+virDomainSnapshotDefFormatInternal(virBufferPtr buf,
+   const char *domain_uuid,
+   virDomainSnapshotDefPtr def,
+   virCapsPtr caps,
+   virDomainXMLOptionPtr xmlopt,
+   unsigned int flags)
 {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
 size_t i;
 int domainflags = VIR_DOMAIN_DEF_FORMAT_INACTIVE;

-virCheckFlags(VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE |
-  VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL, NULL);
-
 if (flags & VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE)
 domainflags |= VIR_DOMAIN_DEF_FORMAT_SECURE;

-virBufferAddLit(, "\n");
-virBufferAdjustIndent(, 2);
+virBufferAddLit(buf, "\n");
+virBufferAdjustIndent(buf, 2);

-virBufferEscapeString(, "%s\n", def->name);
+virBufferEscapeString(buf, "%s\n", def->name);
 if (def->description)
-virBufferEscapeString(, "%s\n",
+virBufferEscapeString(buf, "%s\n",
   def->description);
-virBufferAsprintf(, "%s\n",
+virBufferAsprintf(buf, "%s\n",
   virDomainSnapshotStateTypeToString(def->state));

 if (def->parent) {
-virBufferAddLit(, "\n");
-virBufferAdjustIndent(, 2);
-virBufferEscapeString(, "%s\n", def->parent);
-virBufferAdjustIndent(, -2);
-virBufferAddLit(, "\n");
+virBufferAddLit(buf, "\n");
+virBufferAdjustIndent(buf, 2);
+virBufferEscapeString(buf, "%s\n", def->parent);
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, "\n");
 }

-virBufferAsprintf(, "%lld\n",
+virBufferAsprintf(buf, "%lld\n",
   def->creationTime);

 if (def->memory) {
-virBufferAsprintf(, "memory));
-virBufferEscapeString(, " file='%s'", def->file);
-virBufferAddLit(, "/>\n");
+virBufferEscapeString(buf, " file='%s'", def->file);
+virBufferAddLit(buf, "/>\n");
 }

 if (def->ndisks) {
-virBufferAddLit(, "\n");
-virBufferAdjustIndent(, 2);
+virBufferAddLit(buf, "\n");
+virBufferAdjustIndent(buf, 2);
 for (i = 0; i < def->ndisks; i++) {
-if (virDomainSnapshotDiskDefFormat(, >disks[i], xmlopt) < 
0)
+if (virDomainSnapshotDiskDefFormat(buf, >disks[i], xmlopt) < 
0)
 goto error;
 }
-virBufferAdjustIndent(, -2);
-virBufferAddLit(, "\n");
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, "\n");
 }

 if (def->dom) {
-if (virDomainDefFormatInternal(def->dom, caps, domainflags, ,
+if (virDomainDefFormatInternal(def->dom, caps, domainflags, buf,
xmlopt) < 0)
 goto error;
 } else if (domain_uuid) {
-virBufferAddLit(, "\n");
-virBufferAdjustIndent(, 2);
-virBufferAsprintf(, "%s\n", domain_uuid);
-virBufferAdjustIndent(, -2);
-virBufferAddLit(, "\n");
+virBufferAddLit(buf, "\n");
+virBufferAdjustIndent(buf, 2);
+virBufferAsprintf(buf, "%s\n", domain_uuid);
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, "\n");
 }

-if (virSaveCookieFormatBuf(, def->cookie,
+if (virSaveCookieFormatBuf(buf, def->cookie,
virDomainXMLOptionGetSaveCookie(xmlopt)) < 0)
 goto error;

 if (flags & VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL)
-virBufferAsprintf(, "%d\n", def->current);
+virBufferAsprintf(buf, "%d\n", def->current);

-virBufferAdjustIndent(, -2);
-virBufferAddLit(, "\n");
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, "\n");

-if (virBufferCheckError() < 0)
-return NULL;
+if (virBufferCheckError(buf) < 0)
+goto error;

-return virBufferContentAndReset();
+return 0;

  error:
-virBufferFreeAndReset();
-return NULL;
+virBufferFreeAndReset(buf);
+return -1;
+}
+
+char *
+virDomainSnapshotDefFormat(const char *domain_uuid,
+

[libvirt] [PATCH 6/7] domain: Add VIR_DOMAIN_XML_SNAPSHOTS flag

2019-02-20 Thread Eric Blake
Right now, copying the state of a transient domain with snapshots
from one host to another requires multiple API calls on both
machines - on the host: get the domain XML, get a list of the
snapshots, and then for each snapshot get the snapshot's XML;
then on the destination: create the domain, then multiple
domain snapshot create calls with the REDEFINE flag.  This
patch aims to make the process use fewer APIs by making it
possible to grab the XML for all snapshots at the same time as
grabbing the domain XML.  Note that we had to do the modification
to virDomainGetXMLDesc(), rather than virDomainSnapshotGetXMLDesc(),
since the latter requires a single non-NULL snapshot object,
whereas we want the list of all snapshots for the domain (even
if the list has 0 elements).

The new information is provided as:


  ...
  
  

  ...


  ...

  


For now, I did not modify the schema to permit this information
during virDomainDefineXML; it is still necessary to use
virDomainSnapshotCreateXML with VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE
multiple times to recreate the added state output here.

Unfortunately, libvirt versions between 1.2.12 and 5.0.0 will
silently ignore the new flag, rather than diagnosing that they
don't support it; but at least silent lack of snapshots from
an older server is not a security hole.

Plumb the new flag into the test and qemu driver, and into virsh
dumpxml.

Signed-off-by: Eric Blake 
---
 include/libvirt/libvirt-domain.h |  1 +
 src/conf/domain_conf.c   | 13 -
 src/libvirt-domain.c |  5 +
 src/qemu/qemu_domain.c   | 23 +--
 src/qemu/qemu_driver.c   |  4 ++--
 src/test/test_driver.c   |  7 ---
 tools/virsh-domain.c |  7 +++
 7 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 1d5bdb545d..a8ebb68388 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1570,6 +1570,7 @@ typedef enum {
 VIR_DOMAIN_XML_INACTIVE = (1 << 1), /* dump inactive domain 
information */
 VIR_DOMAIN_XML_UPDATE_CPU   = (1 << 2), /* update guest CPU requirements 
according to host CPU */
 VIR_DOMAIN_XML_MIGRATABLE   = (1 << 3), /* dump XML suitable for migration 
*/
+VIR_DOMAIN_XML_SNAPSHOTS= (1 << 4), /* include all snapshots in the 
dump */
 } virDomainXMLFlags;

 typedef enum {
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ae496834ee..88cb2d8ae5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29109,11 +29109,12 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 return -1;
 }

-/* Converts VIR_DOMAIN_XML_COMMON_FLAGS into VIR_DOMAIN_DEF_FORMAT_*
- * flags, and silently ignores any other flags.  Note that the caller
- * should validate the set of flags it is willing to accept; see also
- * the comment on VIR_DOMAIN_XML_COMMON_FLAGS about security
- * considerations with adding new flags. */
+/* Converts VIR_DOMAIN_XML_COMMON_FLAGS and VIR_DOMAIN_XML_SNAPSHOTS
+ * into VIR_DOMAIN_DEF_FORMAT_* flags, and silently ignores any other
+ * flags.  Note that the caller should validate the set of flags it is
+ * willing to accept; see also the comment on
+ * VIR_DOMAIN_XML_COMMON_FLAGS about security considerations with
+ * adding new flags. */
 unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags)
 {
 unsigned int formatFlags = 0;
@@ -29124,6 +29125,8 @@ unsigned int virDomainDefFormatConvertXMLFlags(unsigned 
int flags)
 formatFlags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 if (flags & VIR_DOMAIN_XML_MIGRATABLE)
 formatFlags |= VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
+if (flags & VIR_DOMAIN_XML_SNAPSHOTS)
+formatFlags |= VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS;

 return formatFlags;
 }
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 072b92b717..2691698bd5 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -2570,6 +2570,11 @@ virDomainGetControlInfo(virDomainPtr domain,
  * XML might not validate against the schema, so it is mainly for
  * internal use.
  *
+ * If @flags contains VIR_DOMAIN_XML_SNAPSHOTS, the XML will include
+ * an additional  child element describing all snapshots
+ * belonging to the domain, including an attribute current='name' if
+ * one of those snapshots is current.
+ *
  * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
  * the caller must free() the returned value.
  */
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 51d1b19c00..da0fde78a6 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7715,6 +7715,7 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,

 static int
 qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
+   virDomainObjPtr vm,
virDomainDefPtr def,

[libvirt] [PATCH 0/7] bulk snapshot list/redefine (incremental backup saga)

2019-02-20 Thread Eric Blake
While looking at my work on incremental backups, Nir raised a good
point: if we want to recreate a set of known checkpoints on one
machine that will be taking over a domain from another machine,
my initial proposal required making multiple API calls to list the
XML for each checkpoint on the source, and then more API calls to
redefine each checkpoint on the destination; it also had the drawback
that the list has to be presented in topological order (the API won't
let you define a child checkpoint if the parent is not defined first).
He asked if I could instead add bulk APIs, for getting the XML for
all checkpoints at once, and then for redefining all checkpoints at
once.

Since my checkpoint code borrows heavily from concepts in the snapshot
code, I chose to tackle the problem by starting with this series, which
does the same thing for snapshots as what I plan to do for checkpoints.
That is, since this patch series adds virDomainGetXMLDesc(,
VIR_DOMAIN_XML_SNAPSHOTS) and virDomainSnapshotCreateXML(,
VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST), the checkpoint series
will add virDOmainGetXMLDesc(, VIR_DOMAIN_XML_CHECKPOINTS) and
virDomainCheckpointCreateXML(, VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE_LIST)
with very similar code.

Note that I'm posting the series now to start review; the bulk
query is fully implemented (patch 6), while the bulk redefine still
needs more work (patch 7 defines the API, but the actual implementation
is trickier, so I'll be posting additional patches later once I get
them working).  Patch 1 is a revision of work posted previously in a
different series where all other patches of that series are now on
mainline.  Also available at:

https://repo.or.cz/libvirt/ericb.git/shortlog/refs/tags/snapshot-bulk-v1

Eric Blake (7):
  domain: Document VIR_DOMAIN_XML_MIGRATABLE
  snapshot: Give virDomainSnapshotDefFormat its own flags
  snapshot: Refactor virDomainSnapshotDefFormat
  snapshot: Add virDomainSnapshotObjListFormat
  domain: Expand virDomainDefFormatInternal with snapshots
  domain: Add VIR_DOMAIN_XML_SNAPSHOTS flag
  snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST flag

 include/libvirt/libvirt-domain-snapshot.h |   3 +
 include/libvirt/libvirt-domain.h  |   1 +
 src/conf/domain_conf.h|   8 ++
 src/conf/snapshot_conf.h  |  18 ++-
 src/conf/domain_conf.c|  71 --
 src/conf/snapshot_conf.c  | 162 --
 src/esx/esx_driver.c  |   1 -
 src/libvirt-domain-snapshot.c |  21 ++-
 src/libvirt-domain.c  |  14 ++
 src/libvirt_private.syms  |   2 +
 src/network/bridge_driver.c   |   3 +-
 src/qemu/qemu_domain.c|  24 +++-
 src/qemu/qemu_driver.c|   7 +-
 src/test/test_driver.c|  10 +-
 src/vbox/vbox_common.c|   5 +-
 src/vz/vz_driver.c|   3 +-
 tests/domainsnapshotxml2xmltest.c |  16 ++-
 tools/virsh-domain.c  |   7 +
 tools/virsh-snapshot.c|  13 ++
 19 files changed, 293 insertions(+), 96 deletions(-)

-- 
2.20.1

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


[libvirt] [PATCH 1/7] domain: Document VIR_DOMAIN_XML_MIGRATABLE

2019-02-20 Thread Eric Blake
Commit 28f8dfdc (1.0.0) added a flag to virDomainGetXMLDesc, but
failed to document its effects.  And considering that the
MIGRATABLE flag has been the source of past bugs (CVE-2014-7823,
fixed in commit b1674ad5 (1.2.11), or even cf2d4c60 (1.2.13) where
flag mismatch broke virsh edit), make the wording wishy-washy
enough to discourage using the flag casually, by mentioning that
the resulting XML is more for internal use than for validation
against the schema.

Signed-off-by: Eric Blake 
---
 src/libvirt-domain.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index e2ed8b2772..072b92b717 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -2561,6 +2561,15 @@ virDomainGetControlInfo(virDomainPtr domain,
  * describing CPU capabilities is modified to match actual
  * capabilities of the host.
  *
+ * If @flags contains VIR_DOMAIN_XML_MIGRATABLE, the XML is altered to
+ * assist in migrations, since the source and destination may be
+ * running different libvirt versions.  This may include trimming
+ * redundant or default information that might confuse an older
+ * recipient, or exposing internal details that aid a newer recipient;
+ * this flag is rejected on read-only connections, and the resulting
+ * XML might not validate against the schema, so it is mainly for
+ * internal use.
+ *
  * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
  * the caller must free() the returned value.
  */
-- 
2.20.1

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


Re: [libvirt] [PATCH 3/4] conf: Fix XML ctxt swap in virDomainNetDefParseXML

2019-02-20 Thread John Ferlan



On 2/20/19 10:42 AM, Ján Tomko wrote:
> On Wed, Feb 20, 2019 at 09:46:58AM -0500, John Ferlan wrote:
>> Alter the logic to return @tmpnode to ctxt->node in both the error
>> and non-error path when calling virDomainNetIPInfoParseXML.
>>
> 
> What is the motivation here?
> 
> On error, ctxt->node will be restored anyway to 'oldnode'.
> 

Coverity whined, but I can drop this one and just keep local Coverity
happy.  If someday someone extracts this out and it's a problem, then
they can fix it then.

John

> Jano
> 
>> Signed-off-by: John Ferlan 
>> ---
>> src/conf/domain_conf.c | 7 ---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index ddcb76f05d..d550b467f7 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -11356,10 +11356,11 @@
>> virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
>>     xmlNodePtr tmpnode = ctxt->node;
>>
>>     ctxt->node = cur;
>> -    if (virDomainNetIPInfoParseXML(_("interface host IP"),
>> -   ctxt, >hostIP) < 0)
>> -    goto error;
>> +    rv = virDomainNetIPInfoParseXML(_("interface host IP"),
>> +    ctxt, >hostIP);
>>     ctxt->node = tmpnode;
>> +    if (rv < 0)
>> +    goto error;
>>     }
>>     if (!macaddr && virXMLNodeNameEqual(cur, "mac")) {
>>     macaddr = virXMLPropString(cur, "address");
>> -- 
>> 2.20.1

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


Re: [libvirt] [PATCH 4/4] conf: Use VIR_AUTOFREE in domain_conf

2019-02-20 Thread Ján Tomko

On Wed, Feb 20, 2019 at 09:46:59AM -0500, John Ferlan wrote:

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.



At this scale, separating the AUTOFREE conversion and the return values
would really make this easier to read.

Also, this fails compilation with clang.


Signed-off-by: John Ferlan 
---
src/conf/domain_conf.c | 1890 ++--
1 file changed, 660 insertions(+), 1230 deletions(-)




@@ -7138,11 +7092,11 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr 
xmlopt ATTRIBUTE_UNUSED,
xmlNodePtr alias = NULL;
xmlNodePtr boot = NULL;
xmlNodePtr rom = NULL;
-char *type = NULL;
-char *romenabled = NULL;
-char *rombar = NULL;
-char *aliasStr = NULL;
int ret = -1;
+VIR_AUTOFREE(char *) type = NULL;


conf/domain_conf.c:7096:26: error: unused variable 'type' 
[-Werror,-Wunused-variable]
   VIR_AUTOFREE(char *) type = NULL;
^


+VIR_AUTOFREE(char *) romenabled = NULL;
+VIR_AUTOFREE(char *) rombar = NULL;
+VIR_AUTOFREE(char *) aliasStr = NULL;

virDomainDeviceInfoClear(info);

@@ -13013,15 +12748,15 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlXPathContextPtr ctxt,
unsigned int flags)
{
-char *type = NULL;
-char *path = NULL;
-char *model = NULL;
-char *backend = NULL;
-char *version = NULL;
virDomainTPMDefPtr def;
xmlNodePtr save = ctxt->node;
-xmlNodePtr *backends = NULL;
int nbackends;
+VIR_AUTOFREE(char *) type = NULL;


conf/domain_conf.c:12754:26: error: unused variable 'type' 
[-Werror,-Wunused-variable]
   VIR_AUTOFREE(char *) type = NULL;
^


+VIR_AUTOFREE(char *) path = NULL;
+VIR_AUTOFREE(char *) model = NULL;
+VIR_AUTOFREE(char *) backend = NULL;
+VIR_AUTOFREE(char *) version = NULL;
+VIR_AUTOFREE(xmlNodePtr *) backends = NULL;

if (VIR_ALLOC(def) < 0)
return NULL;
@@ -18549,7 +18093,8 @@ virDomainHugepagesParseXML(xmlNodePtr node,
{
int ret = -1;
xmlNodePtr oldnode = ctxt->node;
-char *unit = NULL, *nodeset = NULL;
+VIR_AUTOFREE(char *) unit = NULL;


conf/domain_conf.c:18096:26: error: unused variable 'unit' 
[-Werror,-Wunused-variable]
   VIR_AUTOFREE(char *) unit = NULL;
^


+VIR_AUTOFREE(char *) nodeset = NULL;

ctxt->node = node;



Jano


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

[libvirt] [PATCH 3/4] util: implement virCgroupV2(Set|Get)CpusetCpus

2019-02-20 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroupv2.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index f3aa6ebc48..25afab1cad 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1600,6 +1600,28 @@ virCgroupV2GetCpusetMemoryMigrate(virCgroupPtr group 
ATTRIBUTE_UNUSED,
 }
 
 
+static int
+virCgroupV2SetCpusetCpus(virCgroupPtr group,
+ const char *cpus)
+{
+return virCgroupSetValueStr(group,
+VIR_CGROUP_CONTROLLER_CPUSET,
+"cpuset.cpus",
+cpus);
+}
+
+
+static int
+virCgroupV2GetCpusetCpus(virCgroupPtr group,
+ char **cpus)
+{
+return virCgroupGetValueStr(group,
+VIR_CGROUP_CONTROLLER_CPUSET,
+"cpuset.cpus",
+cpus);
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
 .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -1664,6 +1686,8 @@ virCgroupBackend virCgroupV2Backend = {
 .getCpusetMems = virCgroupV2GetCpusetMems,
 .setCpusetMemoryMigrate = virCgroupV2SetCpusetMemoryMigrate,
 .getCpusetMemoryMigrate = virCgroupV2GetCpusetMemoryMigrate,
+.setCpusetCpus = virCgroupV2SetCpusetCpus,
+.getCpusetCpus = virCgroupV2GetCpusetCpus,
 };
 
 
-- 
2.20.1

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


[libvirt] [PATCH 2/4] util: implement virCgroupV2(Set|Get)CpusetMemoryMigrate

2019-02-20 Thread Pavel Hrdina
Cgroups v2 don't have memory_migrate interface and the migration is
enabled by default.

Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroupv2.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 4cfbd52f2d..f3aa6ebc48 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1583,6 +1583,23 @@ virCgroupV2GetCpusetMems(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV2SetCpusetMemoryMigrate(virCgroupPtr group ATTRIBUTE_UNUSED,
+  bool migrate ATTRIBUTE_UNUSED)
+{
+return 0;
+}
+
+
+static int
+virCgroupV2GetCpusetMemoryMigrate(virCgroupPtr group ATTRIBUTE_UNUSED,
+  bool *migrate)
+{
+*migrate = true;
+return 0;
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
 .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -1645,6 +1662,8 @@ virCgroupBackend virCgroupV2Backend = {
 
 .setCpusetMems = virCgroupV2SetCpusetMems,
 .getCpusetMems = virCgroupV2GetCpusetMems,
+.setCpusetMemoryMigrate = virCgroupV2SetCpusetMemoryMigrate,
+.getCpusetMemoryMigrate = virCgroupV2GetCpusetMemoryMigrate,
 };
 
 
-- 
2.20.1

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


[libvirt] [PATCH 1/4] util: implement virCgroupV2(Set|Get)CpusetMems

2019-02-20 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroupv2.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index e0fa8e1cc0..4cfbd52f2d 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1561,6 +1561,28 @@ virCgroupV2GetCpuacctStat(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV2SetCpusetMems(virCgroupPtr group,
+ const char *mems)
+{
+return virCgroupSetValueStr(group,
+VIR_CGROUP_CONTROLLER_CPUSET,
+"cpuset.mems",
+mems);
+}
+
+
+static int
+virCgroupV2GetCpusetMems(virCgroupPtr group,
+ char **mems)
+{
+return virCgroupGetValueStr(group,
+VIR_CGROUP_CONTROLLER_CPUSET,
+"cpuset.mems",
+mems);
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
 .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -1620,6 +1642,9 @@ virCgroupBackend virCgroupV2Backend = {
 
 .getCpuacctUsage = virCgroupV2GetCpuacctUsage,
 .getCpuacctStat = virCgroupV2GetCpuacctStat,
+
+.setCpusetMems = virCgroupV2SetCpusetMems,
+.getCpusetMems = virCgroupV2GetCpusetMems,
 };
 
 
-- 
2.20.1

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


[libvirt] [PATCH 0/4] implement cgroups v2 cpuset controller support

2019-02-20 Thread Pavel Hrdina
Pavel Hrdina (4):
  util: implement virCgroupV2(Set|Get)CpusetMems
  util: implement virCgroupV2(Set|Get)CpusetMemoryMigrate
  util: implement virCgroupV2(Set|Get)CpusetCpus
  util: enable cgroups v2 cpuset controller for threads

 src/util/vircgroupv2.c | 74 ++
 1 file changed, 74 insertions(+)

-- 
2.20.1

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


[libvirt] [PATCH 3/4] conf: Fix XML ctxt swap in virDomainNetDefParseXML

2019-02-20 Thread John Ferlan
Alter the logic to return @tmpnode to ctxt->node in both the error
and non-error path when calling virDomainNetIPInfoParseXML.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ddcb76f05d..d550b467f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11356,10 +11356,11 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
 xmlNodePtr tmpnode = ctxt->node;
 
 ctxt->node = cur;
-if (virDomainNetIPInfoParseXML(_("interface host IP"),
-   ctxt, >hostIP) < 0)
-goto error;
+rv = virDomainNetIPInfoParseXML(_("interface host IP"),
+ctxt, >hostIP);
 ctxt->node = tmpnode;
+if (rv < 0)
+goto error;
 }
 if (!macaddr && virXMLNodeNameEqual(cur, "mac")) {
 macaddr = virXMLPropString(cur, "address");
-- 
2.20.1

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


[libvirt] [PATCH 2/4] conf: Use VIR_AUTOPTR(virBitmap) in domain_conf

2019-02-20 Thread John Ferlan
Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan 
---
 src/conf/domain_conf.c | 53 --
 1 file changed, 20 insertions(+), 33 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ceeb247ef4..ddcb76f05d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1803,8 +1803,8 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
  virBitmapPtr autoCpuset)
 {
 int maxvcpus = virDomainDefGetVcpusMax(def);
-virBitmapPtr allcpumap = NULL;
 size_t i;
+VIR_AUTOPTR(virBitmap) allcpumap = NULL;
 
 if (hostcpus < 0)
 return -1;
@@ -1831,7 +1831,6 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
 virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen);
 }
 
-virBitmapFree(allcpumap);
 return i;
 }
 
@@ -2984,11 +2983,10 @@ static int
 virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 unsigned int iothreads)
 {
-int retval = -1;
 size_t i;
 ssize_t nxt = -1;
 virDomainIOThreadIDDefPtr iothrid = NULL;
-virBitmapPtr thrmap = NULL;
+VIR_AUTOPTR(virBitmap) thrmap = NULL;
 
 /* Same value (either 0 or some number), then we have none to fill in or
  * the iothreadid array was filled from the XML
@@ -2998,7 +2996,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 
 /* iothread's are numbered starting at 1, account for that */
 if (!(thrmap = virBitmapNew(iothreads + 1)))
-goto error;
+return -1;
 virBitmapSetAll(thrmap);
 
 /* Clear 0 since we don't use it, then mark those which are
@@ -3010,27 +3008,23 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
 
 /* resize array */
 if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
-goto error;
+return -1;
 
 /* Populate iothreadids[] using the set bit number from thrmap */
 while (def->niothreadids < iothreads) {
 if ((nxt = virBitmapNextSetBit(thrmap, nxt)) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to populate iothreadids"));
-goto error;
+return -1;
 }
 if (VIR_ALLOC(iothrid) < 0)
-goto error;
+return -1;
 iothrid->iothread_id = nxt;
 iothrid->autofill = true;
 def->iothreadids[def->niothreadids++] = iothrid;
 }
 
-retval = 0;
-
- error:
-virBitmapFree(thrmap);
-return retval;
+return 0;
 }
 
 
@@ -18327,9 +18321,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 {
 int ret = -1;
 virDomainIOThreadIDDefPtr iothrid;
-virBitmapPtr cpumask = NULL;
 unsigned int iothreadid;
 char *tmp = NULL;
+VIR_AUTOPTR(virBitmap) cpumask = NULL;
 
 if (!(tmp = virXMLPropString(node, "iothread"))) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -18385,7 +18379,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 
  cleanup:
 VIR_FREE(tmp);
-virBitmapFree(cpumask);
 return ret;
 }
 
@@ -18397,8 +18390,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 static virBitmapPtr
 virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 {
-virBitmapPtr def = NULL;
+virBitmapPtr ret = NULL;
 char *tmp = NULL;
+VIR_AUTOPTR(virBitmap) def = NULL;
 
 if (!(tmp = virXMLPropString(node, "cpuset"))) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -18412,14 +18406,14 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 if (virBitmapIsAllClear(def)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid value of 'cpuset': %s"), tmp);
-virBitmapFree(def);
-def = NULL;
 goto cleanup;
 }
 
+VIR_STEAL_PTR(ret, def);
+
  cleanup:
 VIR_FREE(tmp);
-return def;
+return ret;
 }
 
 
@@ -18778,35 +18772,30 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
 virDomainDefPtr def)
 {
 ssize_t next = -1;
-virBitmapPtr map = NULL;
 virDomainThreadSchedParamPtr sched;
 virProcessSchedPolicy policy;
 int priority;
-int ret = -1;
+VIR_AUTOPTR(virBitmap) map = NULL;
 
 if (!(map = virDomainSchedulerParse(node, name, , )))
-goto cleanup;
+return -1;
 
 while ((next = virBitmapNextSetBit(map, next)) > -1) {
 if (!(sched = func(def, next)))
-goto cleanup;
+return -1;
 
 if (sched->policy != VIR_PROC_POLICY_NONE) {
 virReportError(VIR_ERR_XML_DETAIL,
_("%ssched attributes 'vcpus' must not overlap"),
name);
-goto cleanup;
+return -1;
 }
 
 sched->policy = policy;
 sched->priority = priority;
 }
 
-ret = 0;
-
- cleanup:
-virBitmapFree(map);
-return ret;
+

[libvirt] [PATCH 0/4] Alter domain_conf to make use of autofree

2019-02-20 Thread John Ferlan
Adding to the recent hype for autofree...  It's more than just saving
a few lines - in some cases the code is easier to read too. The last
patch is really long - I suppose it could be broken up as could perhaps
domain_conf into more easily process-able units.

John Ferlan (4):
  conf: Use VIR_STEAL_PTR in domain_conf
  conf: Use VIR_AUTOPTR(virBitmap) in domain_conf
  conf: Fix XML ctxt swap in virDomainNetDefParseXML
  conf: Use VIR_AUTOFREE in domain_conf

 src/conf/domain_conf.c | 2108 ++--
 1 file changed, 737 insertions(+), 1371 deletions(-)

-- 
2.20.1

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


[libvirt] [PATCH v4 3/4] util: Move error reporting back to virFileWrapperFdClose()

2019-02-20 Thread Andrea Bolognani
virFileWrapperFdFree(), like all free functions, is supposed
to only release allocated resources, so error reporting is
better suited for virFileWrapperFdClose().

This reverts commit b0c3e931804a86cd7146db0164ab4843039c410b.

Signed-off-by: Andrea Bolognani 
---
 src/util/virfile.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 42add5a2cd..d35206b0dd 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -337,6 +337,9 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
 
 ret = virCommandWait(wfd->cmd, NULL);
 
+if (wfd->err_msg && *wfd->err_msg)
+VIR_WARN("iohelper reports: %s", wfd->err_msg);
+
 wfd->closed = true;
 
 return ret;
@@ -357,11 +360,6 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd)
 if (!wfd)
 return;
 
-if (wfd->err_msg && *wfd->err_msg)
-VIR_WARN("iohelper reports: %s", wfd->err_msg);
-
-virCommandAbort(wfd->cmd);
-
 VIR_FREE(wfd->err_msg);
 virCommandFree(wfd->cmd);
 VIR_FREE(wfd);
-- 
2.20.1

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


[libvirt] [PATCH v4 1/4] util: Make it safe to call virFileWrapperFdClose() multiple times

2019-02-20 Thread Andrea Bolognani
We'll want to use this function in the cleanup path soon,
and in order to be able to do that we need to make sure we
can call it multiple times on the same virFileWrapperFd
without side effects.

Signed-off-by: Andrea Bolognani 
---
 src/util/virfile.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 271bf5e796..42add5a2cd 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -175,6 +175,7 @@ virFileDirectFdFlag(void)
 /* Opaque type for managing a wrapper around a fd.  For now,
  * read-write is not supported, just a single direction.  */
 struct _virFileWrapperFd {
+bool closed; /* Whether virFileWrapperFdClose() has been already called */
 virCommandPtr cmd; /* Child iohelper process to do the I/O.  */
 char *err_msg; /* stderr of @cmd */
 };
@@ -323,16 +324,21 @@ virFileWrapperFdNew(int *fd ATTRIBUTE_UNUSED,
  * callers can conditionally create a virFileWrapperFd wrapper but
  * unconditionally call the cleanup code.  To avoid deadlock, only
  * call this after closing the fd resulting from virFileWrapperFdNew().
+ *
+ * This function can be safely called multiple times on the same @wfd.
  */
 int
 virFileWrapperFdClose(virFileWrapperFdPtr wfd)
 {
 int ret;
 
-if (!wfd)
+if (!wfd || wfd->closed)
 return 0;
 
 ret = virCommandWait(wfd->cmd, NULL);
+
+wfd->closed = true;
+
 return ret;
 }
 
-- 
2.20.1

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


[libvirt] [PATCH v4 0/4] qemu: Report better error on dump/migrate failure

2019-02-20 Thread Andrea Bolognani
Changes from [v3]:

* Make sure errors from virFileWrapperFdClose() result in an
  overall failure being bubbled up;
* don't call virReportError() unless the function is going to
  report the failure through its return code as well;
* revert b0c3e931804a more thoroughly.

Changes from [v2]:

* Move error reporting from virFileWrapperFdFree() to
  virFileWrapperFdClose().

Changes from [v1]:

* Use VIR_FREE() followed by VIR_ALLOC_N() instead of manually
  setting the last (and only) byte of the array returned by
  VIR_REALLOC_N() to zero.

[v3] https://www.redhat.com/archives/libvir-list/2019-February/msg01069.html
[v2] https://www.redhat.com/archives/libvir-list/2019-February/msg00782.html
[v1] https://www.redhat.com/archives/libvir-list/2019-February/msg00156.html

Andrea Bolognani (4):
  util: Make it safe to call virFileWrapperFdClose() multiple times
  qemu: Always call virFileWrapperFdClose()
  util: Move error reporting back to virFileWrapperFdClose()
  util: Report error in virFileWrapperFdClose()

 src/qemu/qemu_driver.c | 16 ++--
 src/util/virfile.c | 22 --
 2 files changed, 26 insertions(+), 12 deletions(-)

-- 
2.20.1

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


Re: [libvirt] [PATCH v2 3/3] testutils: Explicitly name virTestCompare*() arguments

2019-02-20 Thread Ján Tomko

On Wed, Feb 20, 2019 at 02:20:10PM +0100, Michal Privoznik wrote:

Currently, some arguments are called strcontent and strsrc, or
content and src or some other combination. This makes it
impossible to see at the first glance what argument is supposed
to represent 'expected' value and which one represents 'actual'
value. Rename the arguments to make it obvious.

Signed-off-by: Michal Privoznik 
Reviewed-by: John Ferlan 
---
tests/testutils.c | 34 +-
tests/testutils.h | 10 +-
2 files changed, 18 insertions(+), 26 deletions(-)



Reviewed-by: Ján Tomko 

Jano


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

[libvirt] [PATCH v4 4/4] util: Report error in virFileWrapperFdClose()

2019-02-20 Thread Andrea Bolognani
libvirt_iohelper is used internally by the virFileWrapperFd APIs;
more specifically, in the QEMU driver we have the doCoreDump() and
qemuDomainSaveMemory() helper functions as users, and those in turn
end up being called by the implementation of several driver APIs.

By calling virReportError() if libvirt_iohelper has failed, we
overwrite whatever generic error message QEMU might have raised
with the more useful one generated by the helper program.

After this commit, the user will be able to see the error directly
instead of having to dig in the journal or libvirtd log.

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

Signed-off-by: Andrea Bolognani 
---
 src/util/virfile.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index d35206b0dd..31030c7b34 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -337,8 +337,14 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
 
 ret = virCommandWait(wfd->cmd, NULL);
 
-if (wfd->err_msg && *wfd->err_msg)
-VIR_WARN("iohelper reports: %s", wfd->err_msg);
+/* If the command used to process I/O has failed and produced some
+ * messages on stderr, it's fair to assume those will be more
+ * relevant to the user than whatever eg. QEMU can figure out on its
+ * own having no knowledge of the fact a command is handling its I/O
+ * in the first place, so it's okay if we end up discarding an
+ * existing error here */
+if (ret < 0 && wfd->err_msg && *wfd->err_msg)
+virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg);
 
 wfd->closed = true;
 
-- 
2.20.1

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


[libvirt] [PATCH v4 2/4] qemu: Always call virFileWrapperFdClose()

2019-02-20 Thread Andrea Bolognani
Right now we're reporting errors in virFileWrapperFdFree(),
but that's hardly the appropriate place to do so, as free
functions are supposed to do nothing more than release
allocated resources.

We want to move that code back into virFileWrapperFdClose(),
but before we can do that we need to make sure the function
is actually called every time we're done processing the
wrapped file. The cleanup path is the obvious candidate.

In a couple of cases we can just move the call, but for the
remaining ones we need to duplicate it instead in order not
to alter the existing behavior. We do, however, make sure
that in all cases a failure to properly close the wrapper
results in the overall operation being reported as failed.

Signed-off-by: Andrea Bolognani 
---
 src/qemu/qemu_driver.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fe1b7801e9..323c7824be 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3231,6 +3231,8 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
 
  cleanup:
 VIR_FORCE_CLOSE(fd);
+if (qemuFileWrapperFDClose(vm, wrapperFd) < 0)
+ret = -1;
 virFileWrapperFdFree(wrapperFd);
 virObjectUnref(cfg);
 
@@ -3834,9 +3836,11 @@ doCoreDump(virQEMUDriverPtr driver,
 
  cleanup:
 VIR_FORCE_CLOSE(fd);
+if (qemuFileWrapperFDClose(vm, wrapperFd) < 0)
+ret = -1;
+virFileWrapperFdFree(wrapperFd);
 if (ret != 0)
 unlink(path);
-virFileWrapperFdFree(wrapperFd);
 VIR_FREE(compressedpath);
 virObjectUnref(cfg);
 return ret;
@@ -7043,17 +7047,17 @@ qemuDomainRestoreFlags(virConnectPtr conn,
 
 ret = qemuDomainSaveImageStartVM(conn, driver, vm, , data, path,
  false, QEMU_ASYNC_JOB_START);
-if (virFileWrapperFdClose(wrapperFd) < 0)
-VIR_WARN("Failed to close %s", path);
 
 qemuProcessEndJob(driver, vm);
 
  cleanup:
 virDomainDefFree(def);
 VIR_FORCE_CLOSE(fd);
+if (virFileWrapperFdClose(wrapperFd) < 0)
+ret = -1;
+virFileWrapperFdFree(wrapperFd);
 virQEMUSaveDataFree(data);
 VIR_FREE(xmlout);
-virFileWrapperFdFree(wrapperFd);
 if (vm && ret < 0)
 qemuDomainRemoveInactiveJob(driver, vm);
 virDomainObjEndAPI();
@@ -7316,14 +7320,14 @@ qemuDomainObjRestore(virConnectPtr conn,
 
 ret = qemuDomainSaveImageStartVM(conn, driver, vm, , data, path,
  start_paused, asyncJob);
-if (virFileWrapperFdClose(wrapperFd) < 0)
-VIR_WARN("Failed to close %s", path);
 
  cleanup:
 virQEMUSaveDataFree(data);
 VIR_FREE(xmlout);
 virDomainDefFree(def);
 VIR_FORCE_CLOSE(fd);
+if (virFileWrapperFdClose(wrapperFd) < 0)
+ret = -1;
 virFileWrapperFdFree(wrapperFd);
 return ret;
 }
-- 
2.20.1

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


Re: [libvirt] [PATCH v2 2/3] virTestCompareToULL: Rename local variables

2019-02-20 Thread Ján Tomko

On Wed, Feb 20, 2019 at 02:20:09PM +0100, Michal Privoznik wrote:

The current naming makes it hard for me to see which holds the
expected value and which holds the actual value. Rename them to
make it obvious.

Signed-off-by: Michal Privoznik 
---
tests/testutils.c | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)



Reviewed-by: Ján Tomko 

Jano


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

Re: [libvirt] [PATCH v2 1/3] virTestCompareToULL: Use VIR_AUTOFREE()

2019-02-20 Thread Ján Tomko

On Wed, Feb 20, 2019 at 02:20:08PM +0100, Michal Privoznik wrote:

In order to save a few lines of code, and also since it's hype
let's use VIR_AUTOFREE() for the two strings we allocate there.

Signed-off-by: Michal Privoznik 
---
tests/testutils.c | 17 +
1 file changed, 5 insertions(+), 12 deletions(-)



Reviewed-by: Ján Tomko 

Jano


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

Re: [libvirt] [PATCH v2 2/3] virTestCompareToULL: Rename local variables

2019-02-20 Thread Martin Kletzander

On Wed, Feb 20, 2019 at 02:20:09PM +0100, Michal Privoznik wrote:

The current naming makes it hard for me to see which holds the
expected value and which holds the actual value. Rename them to
make it obvious.



Well, the naming was confusing because of the function parameters, so I would
mainly focus on those as from a caller this is still weird naming.

I heard that Andrea already reviewed the whole series (as I can't see it because
our ML is acting up again), so this is just an extra hint.


Signed-off-by: Michal Privoznik 
---
tests/testutils.c | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index ac86418653..01f3e8bb93 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -822,16 +822,16 @@ int
virTestCompareToULL(unsigned long long content,
unsigned long long src)
{
-VIR_AUTOFREE(char *) strcontent = NULL;
-VIR_AUTOFREE(char *) strsrc = NULL;
+VIR_AUTOFREE(char *) expectStr = NULL;
+VIR_AUTOFREE(char *) actualStr = NULL;

-if (virAsprintf(, "%llu", content) < 0)
+if (virAsprintf(, "%llu", content) < 0)
return -1;

-if (virAsprintf(, "%llu", src) < 0)
+if (virAsprintf(, "%llu", src) < 0)
return -1;

-return virTestCompareToString(strcontent, strsrc);
+return virTestCompareToString(expectStr, actualStr);
}

/*
--
2.19.2

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


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

Re: [libvirt] [PATCH v2 3/3] testutils: Explicitly name virTestCompare*() arguments

2019-02-20 Thread Andrea Bolognani
On Wed, 2019-02-20 at 14:20 +0100, Michal Privoznik wrote:
[...]
>  /*
> - * @param strcontent: String input content
> - * @param filename: File to compare strcontent against
> + * @param actual: String input content
> + * @param filename: File to compare @actual against
>   *
> - * If @strcontent is NULL, it's treated as an empty string.
> + * If @actual is NULL, it's treated as an empty string.
>   */
>  int
> -virTestCompareToFile(const char *strcontent,
> +virTestCompareToFile(const char *actual,
>   const char *filename)

Agree with John that 'actual' being the first argument rather
than the second one here is pretty weird, but we can take care of
that in a follow-up commit. This change is already a massive
improvement over the status quo :)

[...]
> @@ -814,36 +814,28 @@ virTestCompareToFile(const char *strcontent,
>  return ret;
>  }
>  
> -/*
> - * @param content: Input content
> - * @param src: Source to compare @content against
> - */

Not sure why you removed the comments for this function and
virTestCompareToString() rather than just updating them as you've
done for the one above, but with the new names for the arguments
it's pretty much self-explanatory so I'm totally fine with it.

Reviewed-by: Andrea Bolognani 

-- 
Andrea Bolognani / Red Hat / Virtualization

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


Re: [libvirt] [PATCH] testutils: Explicitly name virTestCompare*() arguments

2019-02-20 Thread Andrea Bolognani
On Wed, 2019-02-20 at 14:06 +0100, Michal Privoznik wrote:
> On 2/20/19 1:56 PM, Andrea Bolognani wrote:
> > There is barely ever a reason *not* to split changes into smaller,
> > independent units; having to write "at the same time" in the commit
> > message should be your hint that you're doing it wrong ;)
> 
> Let me see, the whole sentence reads as follows:
> 
>  At the same time, rework virTestCompareToULL a bit so that local
>  variables are named in the same fashion.
> 
> I don't see any problem with that.

Okay, full disclosure: I clearly didn't pay enough attention while
reading the commit message and thought the "at the same time" bit
referred to the VIR_AUTOFREE() conversion. My bad.

The overall point still stands, though.

> But okay, I'll send v2 splitting this 
> tiny patch into even smaller ones :-P

I'll check those out right away :)

-- 
Andrea Bolognani / Red Hat / Virtualization

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


[libvirt] [PATCH v2 1/3] virTestCompareToULL: Use VIR_AUTOFREE()

2019-02-20 Thread Michal Privoznik
In order to save a few lines of code, and also since it's hype
let's use VIR_AUTOFREE() for the two strings we allocate there.

Signed-off-by: Michal Privoznik 
---
 tests/testutils.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index d2219ad21e..ac86418653 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -822,23 +822,16 @@ int
 virTestCompareToULL(unsigned long long content,
 unsigned long long src)
 {
-char *strcontent = NULL;
-char *strsrc = NULL;
-int ret = -1;
+VIR_AUTOFREE(char *) strcontent = NULL;
+VIR_AUTOFREE(char *) strsrc = NULL;
 
 if (virAsprintf(, "%llu", content) < 0)
-goto cleanup;
+return -1;
 
 if (virAsprintf(, "%llu", src) < 0)
-goto cleanup;
+return -1;
 
-ret = virTestCompareToString(strcontent, strsrc);
-
- cleanup:
-VIR_FREE(strcontent);
-VIR_FREE(strsrc);
-
-return ret;
+return virTestCompareToString(strcontent, strsrc);
 }
 
 /*
-- 
2.19.2

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


[libvirt] [PATCH v2 0/3] Couple of testuitls.c almost trivial fixes

2019-02-20 Thread Michal Privoznik
This is v2 of:

https://www.redhat.com/archives/libvir-list/2019-February/msg01077.html

diff to v1:
- Split one patch into smaller ones
- Made myself a new coffee meanwhile

Michal Prívozník (3):
  virTestCompareToULL: Use VIR_AUTOFREE()
  virTestCompareToULL: Rename local variables
  testutils: Explicitly name virTestCompare*() arguments

 tests/testutils.c | 51 +--
 tests/testutils.h | 10 +-
 2 files changed, 23 insertions(+), 38 deletions(-)

-- 
2.19.2

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

[libvirt] [PATCH v2 2/3] virTestCompareToULL: Rename local variables

2019-02-20 Thread Michal Privoznik
The current naming makes it hard for me to see which holds the
expected value and which holds the actual value. Rename them to
make it obvious.

Signed-off-by: Michal Privoznik 
---
 tests/testutils.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index ac86418653..01f3e8bb93 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -822,16 +822,16 @@ int
 virTestCompareToULL(unsigned long long content,
 unsigned long long src)
 {
-VIR_AUTOFREE(char *) strcontent = NULL;
-VIR_AUTOFREE(char *) strsrc = NULL;
+VIR_AUTOFREE(char *) expectStr = NULL;
+VIR_AUTOFREE(char *) actualStr = NULL;
 
-if (virAsprintf(, "%llu", content) < 0)
+if (virAsprintf(, "%llu", content) < 0)
 return -1;
 
-if (virAsprintf(, "%llu", src) < 0)
+if (virAsprintf(, "%llu", src) < 0)
 return -1;
 
-return virTestCompareToString(strcontent, strsrc);
+return virTestCompareToString(expectStr, actualStr);
 }
 
 /*
-- 
2.19.2

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


[libvirt] [PATCH v2 3/3] testutils: Explicitly name virTestCompare*() arguments

2019-02-20 Thread Michal Privoznik
Currently, some arguments are called strcontent and strsrc, or
content and src or some other combination. This makes it
impossible to see at the first glance what argument is supposed
to represent 'expected' value and which one represents 'actual'
value. Rename the arguments to make it obvious.

Signed-off-by: Michal Privoznik 
Reviewed-by: John Ferlan 
---
 tests/testutils.c | 34 +-
 tests/testutils.h | 10 +-
 2 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index 01f3e8bb93..13bb9630df 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -767,19 +767,19 @@ int virTestDifferenceBin(FILE *stream,
 }
 
 /*
- * @param strcontent: String input content
- * @param filename: File to compare strcontent against
+ * @param actual: String input content
+ * @param filename: File to compare @actual against
  *
- * If @strcontent is NULL, it's treated as an empty string.
+ * If @actual is NULL, it's treated as an empty string.
  */
 int
-virTestCompareToFile(const char *strcontent,
+virTestCompareToFile(const char *actual,
  const char *filename)
 {
 int ret = -1;
 char *filecontent = NULL;
 char *fixedcontent = NULL;
-const char *cmpcontent = strcontent;
+const char *cmpcontent = actual;
 
 if (!cmpcontent)
 cmpcontent = "";
@@ -814,36 +814,28 @@ virTestCompareToFile(const char *strcontent,
 return ret;
 }
 
-/*
- * @param content: Input content
- * @param src: Source to compare @content against
- */
 int
-virTestCompareToULL(unsigned long long content,
-unsigned long long src)
+virTestCompareToULL(unsigned long long expect,
+unsigned long long actual)
 {
 VIR_AUTOFREE(char *) expectStr = NULL;
 VIR_AUTOFREE(char *) actualStr = NULL;
 
-if (virAsprintf(, "%llu", content) < 0)
+if (virAsprintf(, "%llu", expect) < 0)
 return -1;
 
-if (virAsprintf(, "%llu", src) < 0)
+if (virAsprintf(, "%llu", actual) < 0)
 return -1;
 
 return virTestCompareToString(expectStr, actualStr);
 }
 
-/*
- * @param strcontent: String input content
- * @param strsrc: String source to compare strcontent against
- */
 int
-virTestCompareToString(const char *strcontent,
-   const char *strsrc)
+virTestCompareToString(const char *expect,
+   const char *actual)
 {
-if (STRNEQ_NULLABLE(strcontent, strsrc)) {
-virTestDifference(stderr, strcontent, strsrc);
+if (STRNEQ_NULLABLE(expect, actual)) {
+virTestDifference(stderr, expect, actual);
 return -1;
 }
 
diff --git a/tests/testutils.h b/tests/testutils.h
index 658f9053ad..d0a259e2d4 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -76,12 +76,12 @@ int virTestDifferenceBin(FILE *stream,
  const char *expect,
  const char *actual,
  size_t length);
-int virTestCompareToFile(const char *strcontent,
+int virTestCompareToFile(const char *actual,
  const char *filename);
-int virTestCompareToString(const char *strcontent,
-   const char *strsrc);
-int virTestCompareToULL(unsigned long long content,
-unsigned long long src);
+int virTestCompareToString(const char *expect,
+   const char *actual);
+int virTestCompareToULL(unsigned long long expect,
+unsigned long long actual);
 
 unsigned int virTestGetDebug(void);
 unsigned int virTestGetVerbose(void);
-- 
2.19.2

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


Re: [libvirt] [PATCH v3 4/4] util: Report error in virFileWrapperFdClose()

2019-02-20 Thread Daniel P . Berrangé
On Wed, Feb 20, 2019 at 01:34:15PM +0100, Andrea Bolognani wrote:
> On Tue, 2019-02-19 at 16:58 +, Daniel P. Berrangé wrote:
> > On Tue, Feb 19, 2019 at 05:52:31PM +0100, Andrea Bolognani wrote:
> [...]
> > > @@ -337,8 +337,12 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
> > >  
> > >  ret = virCommandWait(wfd->cmd, NULL);
> > >  
> > > +/* If the command used to process IO has produced errors, it's fair
> > > + * to assume those will be more relevant to the user than whatever
> > > + * eg. QEMU can figure out on its own, so it's okay if we end up
> > > + * discarding an existing error */
> > >  if (wfd->err_msg && *wfd->err_msg)
> > > -VIR_WARN("iohelper reports: %s", wfd->err_msg);
> > > +virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg);
> > 
> > ret needs to be set to -1 in this case
> 
> I expect that a command who produced output on stderr also exited
> with a non-zero return code, but explicitly erroring out if the
> former condition is detected can't possibly hurt I guess.

The alternative is to change the conditional to

   if (ret != 0 && wfd->err_msg && *wfd->err_msg)
   ...


If we think there's a risk of the command printing stuff to stderr in
a non-error scenario.

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

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

Re: [libvirt] [PATCH v3 4/4] util: Report error in virFileWrapperFdClose()

2019-02-20 Thread Andrea Bolognani
On Tue, 2019-02-19 at 16:58 +, Daniel P. Berrangé wrote:
> On Tue, Feb 19, 2019 at 05:52:31PM +0100, Andrea Bolognani wrote:
[...]
> > @@ -337,8 +337,12 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
> >  
> >  ret = virCommandWait(wfd->cmd, NULL);
> >  
> > +/* If the command used to process IO has produced errors, it's fair
> > + * to assume those will be more relevant to the user than whatever
> > + * eg. QEMU can figure out on its own, so it's okay if we end up
> > + * discarding an existing error */
> >  if (wfd->err_msg && *wfd->err_msg)
> > -VIR_WARN("iohelper reports: %s", wfd->err_msg);
> > +virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg);
> 
> ret needs to be set to -1 in this case

I expect that a command who produced output on stderr also exited
with a non-zero return code, but explicitly erroring out if the
former condition is detected can't possibly hurt I guess.

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH] testutils: Explicitly name virTestCompare*() arguments

2019-02-20 Thread John Ferlan



On 2/20/19 2:37 AM, Michal Privoznik wrote:
> On 2/19/19 9:19 PM, John Ferlan wrote:
>> Assuming extraction (sigh) of the VIR_AUTOFREE,
>>
>> Reviewed-by: John Ferlan
>>
> 
> While I'd definitely want this to be split into two patches if it was
> fixing something under src/, but this is under tests/ and therefore I
> did not bother. The reason for splitting a patch into smaller
> semanticaly divided patches is to help distro maintainers to ease
> backports. I don't think they will need to backport this patch, nor will
> they want only a part of it.

Just going with precedent I've seen for other patches regardless of
where they're found in the tree. Personally, I'm fine with doing it all
at once.  But I think perhaps some one should take the time to write
down what the "house rules" are on the hacking page. Makes it easier
that way.

Go ahead with one patch -

John

> 
> But I can do the split if you still want me to.
> 
> I'm postponing the push for now.
> 
> Thanks,
> Michal

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


Re: [libvirt] [PATCH v3 3/4] util: Move error reporting back to virFileWrapperFdClose()

2019-02-20 Thread Andrea Bolognani
On Tue, 2019-02-19 at 16:59 +, Daniel P. Berrangé wrote:
> On Tue, Feb 19, 2019 at 05:52:30PM +0100, Andrea Bolognani wrote:
> > virFileWrapperFdFree(), like all free functions, is supposed
> > to only release allocated resources, so error reporting is
> > better suited for virFileWrapperFdClose().
> > 
> > This reverts most of commit b0c3e931804a.
> > 
> > Signed-off-by: Andrea Bolognani 
> > ---
> >  src/util/virfile.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/util/virfile.c b/src/util/virfile.c
> > index 42add5a2cd..8e045279f0 100644
> > --- a/src/util/virfile.c
> > +++ b/src/util/virfile.c
> > @@ -337,6 +337,9 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
> >  
> >  ret = virCommandWait(wfd->cmd, NULL);
> >  
> > +if (wfd->err_msg && *wfd->err_msg)
> > +VIR_WARN("iohelper reports: %s", wfd->err_msg);
> > +
> >  wfd->closed = true;
> >  
> >  return ret;
> > @@ -357,9 +360,6 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd)
> >  if (!wfd)
> >  return;
> >  
> > -if (wfd->err_msg && *wfd->err_msg)
> > -VIR_WARN("iohelper reports: %s", wfd->err_msg);
> > -
> >  virCommandAbort(wfd->cmd);
> 
> It feels like this could be reverted too. We already call virCommandFree
> which I think should call Abort for us - though not 100% confident since
> the scenario in which "reap = true" is set is quite complex.

According to virCommandRunAsync()'s documentation

  There are two approaches to child process cleanup.
  1. Use auto-cleanup, by passing NULL for pid.  The child will be
  auto-reaped by virCommandFree, unless you reap it earlier via
  virCommandWait or virCommandAbort.

We call virCommandRunAsync() with pid=NULL in virFileWrapperFdNew(),
and then both call virCommandWait() in virFileWrapperFdClose() *and*
virCommandFree() in virFileWrapperFdFree(), so I think you're right
that we don't need to call virCommandAbort() explicitly and we can
simply revert all of b0c3e931804a.

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH v3 2/4] qemu: Always call virFileWrapperFdClose()

2019-02-20 Thread Daniel P . Berrangé
On Wed, Feb 20, 2019 at 01:16:34PM +0100, Andrea Bolognani wrote:
> On Tue, 2019-02-19 at 17:01 +, Daniel P. Berrangé wrote:
> > On Tue, Feb 19, 2019 at 05:52:29PM +0100, Andrea Bolognani wrote:
> [...]
> > > @@ -3231,6 +3231,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
> > >  
> > >   cleanup:
> > >  VIR_FORCE_CLOSE(fd);
> > > +qemuFileWrapperFDClose(vm, wrapperFd);
> > 
> > Don't we need to check & propagate the return status of this,
> > otherwise callers would mistakenly think qemuDomainSaveMemory
> > has succeeeded, despite qemuFileWrapperFDClose having raised
> > an error. Likewise all the other places below.
> 
> In cases where qemuFileWrapperFDClose() returning an error was not
> considered an overall failure in the existing code, I have preserved
> that behavior.

FWIW, I consider that existing code to be buggy. It is akin to ignoring
the return status of close(). Data you think you've written can in fact
be lost. 

We usually only ignore close() return value if we're already in an
error cleanup scenario. Any success codepaths should always honour
the close() status.

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

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

Re: [libvirt] [PATCH v3 2/4] qemu: Always call virFileWrapperFdClose()

2019-02-20 Thread Andrea Bolognani
On Tue, 2019-02-19 at 17:01 +, Daniel P. Berrangé wrote:
> On Tue, Feb 19, 2019 at 05:52:29PM +0100, Andrea Bolognani wrote:
[...]
> > @@ -3231,6 +3231,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
> >  
> >   cleanup:
> >  VIR_FORCE_CLOSE(fd);
> > +qemuFileWrapperFDClose(vm, wrapperFd);
> 
> Don't we need to check & propagate the return status of this,
> otherwise callers would mistakenly think qemuDomainSaveMemory
> has succeeeded, despite qemuFileWrapperFDClose having raised
> an error. Likewise all the other places below.

In cases where qemuFileWrapperFDClose() returning an error was not
considered an overall failure in the existing code, I have preserved
that behavior.

Then again, we're ultimately going to call virReportError() from it
instead of just logging a message with VIR_WARN(), so perhaps not
returning an overall failure would be confusing...

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [glib PATCH 09/15] po: minimize id ilo is it ja ka kk km kn ko

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/id.mini.po|  20 +
 po/id.po | 153 ---
 po/ilo.mini.po   |  20 +
 po/ilo.po| 153 ---
 po/is.mini.po|  20 +
 po/is.po | 153 ---
 po/it.mini.po|  20 +
 po/it.po | 153 ---
 po/{ja.po => ja.mini.po} | 141 
 po/ka.mini.po|  20 +
 po/ka.po | 153 ---
 po/kk.mini.po|  20 +
 po/kk.po | 153 ---
 po/km.mini.po|  20 +
 po/km.po | 153 ---
 po/kn.mini.po|  20 +
 po/kn.po | 153 ---
 po/ko.mini.po|  20 +
 po/ko.po | 153 ---
 19 files changed, 225 insertions(+), 1473 deletions(-)
 create mode 100644 po/id.mini.po
 delete mode 100644 po/id.po
 create mode 100644 po/ilo.mini.po
 delete mode 100644 po/ilo.po
 create mode 100644 po/is.mini.po
 delete mode 100644 po/is.po
 create mode 100644 po/it.mini.po
 delete mode 100644 po/it.po
 rename po/{ja.po => ja.mini.po} (55%)
 create mode 100644 po/ka.mini.po
 delete mode 100644 po/ka.po
 create mode 100644 po/kk.mini.po
 delete mode 100644 po/kk.po
 create mode 100644 po/km.mini.po
 delete mode 100644 po/km.po
 create mode 100644 po/kn.mini.po
 delete mode 100644 po/kn.po
 create mode 100644 po/ko.mini.po
 delete mode 100644 po/ko.po

diff --git a/po/id.mini.po b/po/id.mini.po
new file mode 100644
index 000..66423de
--- /dev/null
+++ b/po/id.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:21+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Indonesian (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/id/)\n"
+"Language: id\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/id.po b/po/id.po
deleted file mode 100644
index 314ff45..000
--- a/po/id.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:21+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Indonesian (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/id/)\n"
-"Language: id\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: 

[libvirt] [glib PATCH 02/15] po: remove language list from zanata configuration

2019-02-20 Thread Daniel P . Berrangé
The  element in zanata.xml is no longer relevant as this info
is recorded server side.

Signed-off-by: Daniel P. Berrangé 
---
 po/zanata.xml | 99 ---
 1 file changed, 99 deletions(-)

diff --git a/po/zanata.xml b/po/zanata.xml
index 70cc22a..042c695 100644
--- a/po/zanata.xml
+++ b/po/zanata.xml
@@ -4,103 +4,4 @@
   libvirt-glib
   master
   gettext
-
-  
-sq
-ar
-as
-ast
-bal
-eu
-bn
-bn-IN
-brx
-bs
-br
-bg
-ca
-zh-CN
-zh-HK
-zh-TW
-kw
-kw-GB
-cs
-da
-nl
-en-GB
-eo
-et
-fi
-fr
-gl
-ka
-de
-el
-gu
-he
-hi
-hu
-is
-id
-ia
-it
-ja
-kn
-kk
-km
-ky
-ko
-lt
-nds
-mk
-mai
-ms
-ml
-mr
-mn
-ne
-nb
-nn
-or
-pa
-fa
-pl
-pt
-pt-BR
-ro
-ru
-sr
-sr@latin
-si
-sk
-sl
-es
-sv
-tg
-ta
-te
-bo
-tr
-uk
-ur
-wba
-cy
-lv
-kw@uccor
-kw@kkcor
-af
-am
-be
-hr
-de-CH
-th
-vi
-zu
-ilo
-nso
-tw
-yo
-anp
-  
-
 
-- 
2.20.1

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

[libvirt] [glib PATCH 05/15] po: minimize af am anp ar as ast bal be bg bn_IN

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/af.mini.po|  20 ++
 po/af.po | 153 --
 po/am.mini.po|  20 ++
 po/am.po | 153 --
 po/anp.mini.po   |  19 ++
 po/anp.po| 152 --
 po/ar.mini.po|  21 +++
 po/ar.po | 154 ---
 po/as.mini.po|  20 ++
 po/as.po | 153 --
 po/ast.mini.po   |  20 ++
 po/ast.po| 153 --
 po/bal.mini.po   |  20 ++
 po/bal.po| 153 --
 po/be.mini.po|  21 +++
 po/be.po | 154 ---
 po/bg.mini.po|  20 ++
 po/bg.po | 153 --
 po/bn_IN.mini.po |  20 ++
 po/bn_IN.po  | 153 --
 20 files changed, 201 insertions(+), 1531 deletions(-)
 create mode 100644 po/af.mini.po
 delete mode 100644 po/af.po
 create mode 100644 po/am.mini.po
 delete mode 100644 po/am.po
 create mode 100644 po/anp.mini.po
 delete mode 100644 po/anp.po
 create mode 100644 po/ar.mini.po
 delete mode 100644 po/ar.po
 create mode 100644 po/as.mini.po
 delete mode 100644 po/as.po
 create mode 100644 po/ast.mini.po
 delete mode 100644 po/ast.po
 create mode 100644 po/bal.mini.po
 delete mode 100644 po/bal.po
 create mode 100644 po/be.mini.po
 delete mode 100644 po/be.po
 create mode 100644 po/bg.mini.po
 delete mode 100644 po/bg.po
 create mode 100644 po/bn_IN.mini.po
 delete mode 100644 po/bn_IN.po

diff --git a/po/af.mini.po b/po/af.mini.po
new file mode 100644
index 000..4e27273
--- /dev/null
+++ b/po/af.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:19+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Afrikaans (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/af/)\n"
+"Language: af\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/af.po b/po/af.po
deleted file mode 100644
index 9dd2a27..000
--- a/po/af.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:19+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Afrikaans (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/af/)\n"
-"Language: af\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: 

[libvirt] [glib PATCH 13/15] po: minimize sq sr@latin sr sv ta te tg th tr tw

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/sq.mini.po   |  20 ++
 po/sq.po| 153 ---
 po/sr.mini.po   |  21 ++
 po/sr.po| 154 
 po/s...@latin.mini.po |  21 ++
 po/s...@latin.po  | 154 
 po/sv.mini.po   |  20 ++
 po/sv.po| 153 ---
 po/ta.mini.po   |  20 ++
 po/ta.po| 153 ---
 po/te.mini.po   |  20 ++
 po/te.po| 153 ---
 po/tg.mini.po   |  20 ++
 po/tg.po| 153 ---
 po/th.mini.po   |  20 ++
 po/th.po| 153 ---
 po/tr.mini.po   |  20 ++
 po/tr.po| 153 ---
 po/tw.mini.po   |  19 ++
 po/tw.po| 152 ---
 20 files changed, 201 insertions(+), 1531 deletions(-)
 create mode 100644 po/sq.mini.po
 delete mode 100644 po/sq.po
 create mode 100644 po/sr.mini.po
 delete mode 100644 po/sr.po
 create mode 100644 po/s...@latin.mini.po
 delete mode 100644 po/s...@latin.po
 create mode 100644 po/sv.mini.po
 delete mode 100644 po/sv.po
 create mode 100644 po/ta.mini.po
 delete mode 100644 po/ta.po
 create mode 100644 po/te.mini.po
 delete mode 100644 po/te.po
 create mode 100644 po/tg.mini.po
 delete mode 100644 po/tg.po
 create mode 100644 po/th.mini.po
 delete mode 100644 po/th.po
 create mode 100644 po/tr.mini.po
 delete mode 100644 po/tr.po
 create mode 100644 po/tw.mini.po
 delete mode 100644 po/tw.po

diff --git a/po/sq.mini.po b/po/sq.mini.po
new file mode 100644
index 000..86e21c7
--- /dev/null
+++ b/po/sq.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:23+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Albanian (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/sq/)\n"
+"Language: sq\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/sq.po b/po/sq.po
deleted file mode 100644
index 515c763..000
--- a/po/sq.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:23+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Albanian (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/sq/)\n"
-"Language: sq\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: 

[libvirt] [glib PATCH 00/15] po: improve translation handling

2019-02-20 Thread Daniel P . Berrangé
This applies the same improvements previously done in libvirt:

  https://www.redhat.com/archives/libvir-list/2018-April/msg01004.html
  
https://www.berrange.com/posts/2018/11/29/improved-translation-po-file-handling-by-ditching-gettext-autotools-integration/

The key problems with our current approach are:

 - The pot & po files stored in GIT contain huge set of
   annotations about source file names & line numbers.
   These are out of date as soon as a change is commited
   to git following a translation refresh. This makes
   diffs impossible to meaningfully review, as they are
   98% noise, 2% signal.

 - The po file messages are sorted by source location,
   so when we move code between files, or rename files,
   the po file message order changes for no good reason.
   This makes diffs even more impossible to review.

 - The po files contain entries for all messages even
   if most have no translation, bloating size of po/
   data stored in git

 - Whenever 'make dist' is run, it alters all the pot
   and po files, so developers need to then reset their
   content to match git HEAD manually. This is caused
   by having auto-generated content (source file locations)
   mixed in with the static content (the actual translated
   strings)

After this series, we only minimized po files in git, with
the redundated & outdated source locations info stripped.
This stripped info is re-added automatically during build
to create the real .po files, that we distribute, and/or
upload to translators in Zanata.

As a result the po directory is smaller in size, and
when refreshing from Zanata, we have git commits that
clearly show *only* the altered translations, nothing
else. The importance of this cannot be overstated - by
having these clear diffs when doing this change in libvirt,
I discovered a serious bug in the Zanata client that has
been screwing up translations in every project that uses
Zanata by adding bogus "fuzzy" annotations.

The particularly attractive statistic:

 194 files changed, 2607 insertions(+), 14146 deletions(-)

Daniel P. Berrangé (15):
  po: provide custom make rules for po file management
  po: remove language list from zanata configuration
  po: add rules for integration with zanata
  po: minimize & canonicalize translations stored in git
  po: minimize af am anp ar as ast bal be bg bn_IN
  po: minimize bn bo br brx bs ca cs cy da de_CH
  po: minimize de el en_GB eo es et eu fa fi
  po: minimize fr gl gu he hi hr hu ia
  po: minimize id ilo is it ja ka kk km kn ko
  po: minimize kw_GB kw@kkcor kw kw@uccor ky lt lv mai mk ml
  po: minimize mn mr ms nb nds ne nl nn nso
  po: minimize or pa pl pt_BR pt ro ru si sk sl
  po: minimize sq sr@latin sr sv ta te tg th tr tw
  po: minimize uk ur vi wba yo zh_CN zh_HK zh_TW zu
  po: refresh translations from zanata

 .gitignore |  10 +--
 autogen.sh |   3 +-
 build-aux/minimize-po.pl   |  37 
 configure.ac   |   8 +-
 libvirt-gconfig/Makefile.am|   1 +
 libvirt-glib/Makefile.am   |   1 +
 libvirt-gobject/Makefile.am|   1 +
 m4/virt-gettext.m4 |   5 --
 m4/virt-nls.m4 |  45 ++
 po/Makefile.am | 111 +++
 po/{POTFILES.in => POTFILES}   |   0
 po/README.md   |  76 
 po/af.mini.po  |  20 +
 po/af.po   | 153 
 po/am.mini.po  |  20 +
 po/am.po   | 153 
 po/anp.mini.po |  19 
 po/anp.po  | 152 ---
 po/ar.mini.po  |  21 +
 po/ar.po   | 154 
 po/as.mini.po  |  20 +
 po/as.po   | 153 
 po/ast.mini.po |  20 +
 po/ast.po  | 153 
 po/bal.mini.po |  20 +
 po/bal.po  | 153 
 po/be.mini.po  |  21 +
 po/be.po   | 154 
 po/bg.mini.po  |  20 +
 po/bg.po   | 153 
 po/bn.mini.po  |  20 +
 po/bn.po   | 153 
 po/bn_IN.mini.po   |  20 +
 po/bn_IN.po| 153 
 po/bo.mini.po  |  20 +
 po/bo.po   | 153 
 po/br.mini.po  |  20 +
 po/br.po   | 153 
 po/brx.mini.po |  20 +
 po/brx.po  | 153 
 po/bs.mini.po  

[libvirt] [glib PATCH 03/15] po: add rules for integration with zanata

2019-02-20 Thread Daniel P . Berrangé
Add rules to handle pushing libvirt-glib.pot to zanata, and refreshing .po
files with new content from zanata.

Signed-off-by: Daniel P. Berrangé 
---
 po/Makefile.am | 8 
 1 file changed, 8 insertions(+)

diff --git a/po/Makefile.am b/po/Makefile.am
index 279fc47..d37014b 100644
--- a/po/Makefile.am
+++ b/po/Makefile.am
@@ -60,6 +60,14 @@ update-po: $(POFILES)
 
 update-gmo: $(GMOFILES)
 
+push-pot: $(POTFILE)
+   zanata push --push-type=source
+
+pull-po: $(POTFILE)
+   zanata pull --create-skeletons
+   $(MAKE) update-po
+   $(MAKE) update-gmo
+
 $(POTFILE): POTFILES $(POTFILE_DEPS)
$(XGETTEXT) -o $@-t $(XGETTEXT_ARGS) \
  --files-from=$(abs_srcdir)/POTFILES
-- 
2.20.1

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

[libvirt] [glib PATCH 14/15] po: minimize uk ur vi wba yo zh_CN zh_HK zh_TW zu

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/{uk.po => uk.mini.po} | 152 +++---
 po/ur.mini.po|  20 +
 po/ur.po | 153 ---
 po/vi.mini.po|  20 +
 po/vi.po | 153 ---
 po/wba.mini.po   |  19 +
 po/wba.po| 152 --
 po/yo.mini.po|  19 +
 po/yo.po | 152 --
 po/zh_CN.mini.po |  20 +
 po/zh_CN.po  | 153 ---
 po/zh_HK.mini.po |  20 +
 po/zh_HK.po  | 153 ---
 po/zh_TW.mini.po |  20 +
 po/zh_TW.po  | 153 ---
 po/zu.mini.po|  20 +
 po/zu.po | 153 ---
 17 files changed, 216 insertions(+), 1316 deletions(-)
 rename po/{uk.po => uk.mini.po} (65%)
 create mode 100644 po/ur.mini.po
 delete mode 100644 po/ur.po
 create mode 100644 po/vi.mini.po
 delete mode 100644 po/vi.po
 create mode 100644 po/wba.mini.po
 delete mode 100644 po/wba.po
 create mode 100644 po/yo.mini.po
 delete mode 100644 po/yo.po
 create mode 100644 po/zh_CN.mini.po
 delete mode 100644 po/zh_CN.po
 create mode 100644 po/zh_HK.mini.po
 delete mode 100644 po/zh_HK.po
 create mode 100644 po/zh_TW.mini.po
 delete mode 100644 po/zh_TW.po
 create mode 100644 po/zu.mini.po
 delete mode 100644 po/zu.po

diff --git a/po/uk.po b/po/uk.mini.po
similarity index 65%
rename from po/uk.po
rename to po/uk.mini.po
index bd37f63..a0ab0ff 100644
--- a/po/uk.po
+++ b/po/uk.mini.po
@@ -1,5 +1,5 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
 #
 # Translators:
@@ -8,9 +8,9 @@
 # Yuri Chornoivan , 2017. #zanata
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
 "PO-Revision-Date: 2017-12-06 12:39+\n"
 "Last-Translator: Yuri Chornoivan \n"
 "Language-Team: Ukrainian (http://www.transifex.com/projects/p/libvirt-glib/;
@@ -23,135 +23,99 @@ msgstr ""
 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
 "X-Generator: Zanata 4.6.2\n"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr "Немає документа XML для обробки"
+#, c-format
+msgid "Connection %s is already open"
+msgstr "З’єднання %s вже відкрито"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr "Не вдалося обробити налаштування"
+msgid "Connection is not open"
+msgstr "З'єднання не відкрито"
+
+msgid "Connection is not opened"
+msgstr "З’єднання не відкрито"
+
+msgid "Failed to create domain"
+msgstr "Не вдалося створити домен"
+
+msgid "Failed to create storage pool"
+msgstr "Не вдалося створити резервне сховище"
+
+msgid "Failed to fetch list of domains"
+msgstr "Не вдалося отримати список доменів"
+
+msgid "Failed to fetch list of interfaces"
+msgstr "Не вдалося отримати список інтерфейсів"
+
+msgid "Failed to fetch list of networks"
+msgstr "Не вдалося отримати список мереж"
+
+msgid "Failed to fetch list of pools"
+msgstr "Не вдалося отримати список буферів"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
 #, c-format
-msgid "XML data has no '%s' node"
-msgstr "У даних XML немає вузла «%s»"
+msgid "Got virStreamRecv error in %s"
+msgstr "Отримано повідомлення про помилку virStreamRecv у %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
 msgid "No XML document associated with this config object"
 msgstr "З цим об’єктом налаштування не пов’язано жодного документа XML"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
+msgid "No XML document to parse"
+msgstr "Немає документа XML для обробки"
+
 msgid "No XML schema associated with this config object"
 msgstr "З цим об’єктом налаштування не пов’язано жодної схеми XML"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
 #, c-format
 msgid "Unable to create RNG parser for %s"
 msgstr "Не вдалося створити обробник RNG для %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr "Не вдалося обробити RNG, %s"
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
 #, c-format
 msgid "Unable to create RNG validation context %s"
 msgstr "Не вдалося створити контекст перевірки RNG, %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr "Не вдалося перевірити документи"
-
-#: 

[libvirt] [glib PATCH 08/15] po: minimize fr gl gu he hi hr hu ia

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/{fr.po => fr.mini.po} | 156 +++
 po/gl.mini.po|  20 +
 po/gl.po | 153 --
 po/gu.mini.po|  20 +
 po/gu.po | 153 --
 po/he.mini.po|  20 +
 po/he.po | 153 --
 po/{hi.po => hi.mini.po} | 141 +++
 po/hr.mini.po|  21 ++
 po/hr.po | 154 --
 po/hu.mini.po|  20 +
 po/hu.po | 153 --
 po/ia.mini.po|  20 +
 po/ia.po | 153 --
 14 files changed, 225 insertions(+), 1112 deletions(-)
 rename po/{fr.po => fr.mini.po} (58%)
 create mode 100644 po/gl.mini.po
 delete mode 100644 po/gl.po
 create mode 100644 po/gu.mini.po
 delete mode 100644 po/gu.po
 create mode 100644 po/he.mini.po
 delete mode 100644 po/he.po
 rename po/{hi.po => hi.mini.po} (62%)
 create mode 100644 po/hr.mini.po
 delete mode 100644 po/hr.po
 create mode 100644 po/hu.mini.po
 delete mode 100644 po/hu.po
 create mode 100644 po/ia.mini.po
 delete mode 100644 po/ia.po

diff --git a/po/fr.po b/po/fr.mini.po
similarity index 58%
rename from po/fr.po
rename to po/fr.mini.po
index f5a8978..c61b518 100644
--- a/po/fr.po
+++ b/po/fr.mini.po
@@ -1,16 +1,17 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
 #
 # Translators:
 # Jérôme Fenal , 2013
 # Jean-Baptiste Holcroft , 2016. #zanata
+# Jean-Baptiste Holcroft , 2019. #zanata
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2016-07-15 05:10+\n"
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2019-01-21 08:05+\n"
 "Last-Translator: Jean-Baptiste Holcroft \n"
 "Language-Team: French (http://www.transifex.com/projects/p/libvirt-glib/;
 "language/fr/)\n"
@@ -21,135 +22,96 @@ msgstr ""
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 "X-Generator: Zanata 4.6.2\n"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr "Aucun document XML à analyser"
+#, c-format
+msgid "Connection %s is already open"
+msgstr "La connexion %s est déjà ouverte"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr "Impossible d'analyser la configuration"
+msgid "Connection is not open"
+msgstr "La connexion n'est pas ouverte"
+
+msgid "Connection is not opened"
+msgstr "La connexion n'est pas ouverte"
+
+msgid "Failed to create domain"
+msgstr "Échec de la création du domaine"
+
+msgid "Failed to create storage pool"
+msgstr "Échec de la création du pool de stockage"
+
+msgid "Failed to fetch list of domains"
+msgstr "Impossible de récupérer la liste des domaines"
+
+msgid "Failed to fetch list of interfaces"
+msgstr "Impossible de récupérer la liste des interfaces"
+
+msgid "Failed to fetch list of networks"
+msgstr "Impossible de récupérer la liste des réseaux"
+
+msgid "Failed to fetch list of pools"
+msgstr "Impossible de récupérer la liste des pools"
 
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
 #, c-format
-msgid "XML data has no '%s' node"
-msgstr "Les données XML n'ont pas de nœud « %s »"
+msgid "Got virStreamRecv error in %s"
+msgstr "Erreur virStreamRecv survenue dans %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
 msgid "No XML document associated with this config object"
 msgstr "Aucun document XML associé avec cet objet de configuration"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
+msgid "No XML document to parse"
+msgstr "Aucun document XML à analyser"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
 #, c-format
 msgid "Unable to create RNG parser for %s"
 msgstr "Impossible de créer l'analyseur RNG pour %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr "Impossible d'analyser le RNG %s"
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
 #, c-format
 msgid "Unable to create RNG validation context %s"
 msgstr "Impossible de créer un contexte de validation RNG %s"
 
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr "Impossible de valider le document"
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr "La connexion %s est déjà ouverte"
-
-#: 

[libvirt] [glib PATCH 11/15] po: minimize mn mr ms nb nds ne nl nn nso

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/mn.mini.po  |  20 +++
 po/mn.po   | 153 -
 po/mr.mini.po  |  20 +++
 po/mr.po   | 153 -
 po/ms.mini.po  |  20 +++
 po/ms.po   | 153 -
 po/nb.mini.po  |  20 +++
 po/nb.po   | 153 -
 po/nds.mini.po |  20 +++
 po/nds.po  | 153 -
 po/ne.mini.po  |  20 +++
 po/ne.po   | 153 -
 po/nl.mini.po  |  20 +++
 po/nl.po   | 153 -
 po/nn.mini.po  |  20 +++
 po/nn.po   | 153 -
 po/nso.mini.po |  20 +++
 po/nso.po  | 153 -
 18 files changed, 180 insertions(+), 1377 deletions(-)
 create mode 100644 po/mn.mini.po
 delete mode 100644 po/mn.po
 create mode 100644 po/mr.mini.po
 delete mode 100644 po/mr.po
 create mode 100644 po/ms.mini.po
 delete mode 100644 po/ms.po
 create mode 100644 po/nb.mini.po
 delete mode 100644 po/nb.po
 create mode 100644 po/nds.mini.po
 delete mode 100644 po/nds.po
 create mode 100644 po/ne.mini.po
 delete mode 100644 po/ne.po
 create mode 100644 po/nl.mini.po
 delete mode 100644 po/nl.po
 create mode 100644 po/nn.mini.po
 delete mode 100644 po/nn.po
 create mode 100644 po/nso.mini.po
 delete mode 100644 po/nso.po

diff --git a/po/mn.mini.po b/po/mn.mini.po
new file mode 100644
index 000..be36862
--- /dev/null
+++ b/po/mn.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:22+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Mongolian (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/mn/)\n"
+"Language: mn\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/mn.po b/po/mn.po
deleted file mode 100644
index 9d6a13b..000
--- a/po/mn.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:22+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Mongolian (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/mn/)\n"
-"Language: mn\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1761
-msgid "Connection is not open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:742
-msgid "Failed to fetch list of 

[libvirt] [glib PATCH 01/15] po: provide custom make rules for po file management

2019-02-20 Thread Daniel P . Berrangé
Historically we have relied on intltool to install a standard
po/Makefile.in.in which has very limited scope for customization.
intltool is deprecated in favour of standard gettextize tools,
but these share the same disadvantages.

Writing make rules for po file management is no more difficult
than any other rules libvirt-glib has, so stop using intltool
and don't use gettextize ether.

Signed-off-by: Daniel P. Berrangé 
---
 .gitignore   |   7 ---
 autogen.sh   |   3 +-
 configure.ac |   8 ++-
 libvirt-gconfig/Makefile.am  |   1 +
 libvirt-glib/Makefile.am |   1 +
 libvirt-gobject/Makefile.am  |   1 +
 m4/virt-gettext.m4   |   5 --
 m4/virt-nls.m4   |  45 
 po/Makefile.am   | 101 +++
 po/{POTFILES.in => POTFILES} |   0
 po/README.md |  38 +
 11 files changed, 191 insertions(+), 19 deletions(-)
 delete mode 100644 m4/virt-gettext.m4
 create mode 100644 m4/virt-nls.m4
 create mode 100644 po/Makefile.am
 rename po/{POTFILES.in => POTFILES} (100%)
 create mode 100644 po/README.md

diff --git a/.gitignore b/.gitignore
index 116bb12..9301e0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,14 +83,7 @@ libvirt-gconfig/tests/test-capabilities-parse
 libvirt-gconfig/tests/test-domain-create
 libvirt-gconfig/tests/test-domain-parse
 .tx/
-po/Makefile
-po/Makefile.in
-po/Makefile.in.in
-po/POTFILES
-po/libvirt-glib.pot
-po/stamp-it
 po/*.gmo
-po/.zanata-cache/
 tests/test-events
 tests/test-gconfig
 tests/*.log
diff --git a/autogen.sh b/autogen.sh
index 4f7135f..3b593ce 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -10,7 +10,7 @@ cd $srcdir
 
 DIE=0
 
-for prog in intltoolize autoreconf automake autoconf libtoolize
+for prog in autoreconf automake autoconf libtoolize
 do
 ($prog --version) < /dev/null > /dev/null 2>&1 || {
 echo
@@ -35,7 +35,6 @@ fi
 touch ChangeLog AUTHORS
 
 mkdir -p build-aux
-intltoolize --force
 autoreconf -if
 
 cd $THEDIR
diff --git a/configure.ac b/configure.ac
index dc743bb..6b66f5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,10 +112,8 @@ PKG_CHECK_MODULES(GOBJECT2, gobject-2.0 >= $GLIB2_REQUIRED)
 PKG_CHECK_MODULES(GIO2, gio-2.0 >= $GLIB2_REQUIRED)
 PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
 
-LIBVIRT_GLIB_GETTEXT
-dnl Should be in m4/virt-gettext.m4 but intltoolize is too
-dnl dumb to find it there
-IT_PROG_INTLTOOL([0.35.0])
+LIBVIRT_GLIB_ARG_NLS
+LIBVIRT_GLIB_CHECK_NLS
 
 
 GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
@@ -218,7 +216,7 @@ AC_OUTPUT(Makefile
   docs/libvirt-glib/version.xml
   docs/libvirt-gobject/Makefile
   docs/libvirt-gconfig/Makefile
-  po/Makefile.in
+  po/Makefile
   tests/Makefile
   libvirt-glib-1.0.pc
   libvirt-gconfig-1.0.pc
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index cfcc0e4..b976e4d 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -201,6 +201,7 @@ libvirt_gconfig_1_0_la_SOURCES = \
 nodist_libvirt_gconfig_1_0_la_SOURCES = \
$(GCONFIG_GENERATED_FILES)
 libvirt_gconfig_1_0_la_CFLAGS = \
+   -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GConfig\"" \
-DDATADIR="\"$(datadir)\"" \
-DLIBVIRT_GCONFIG_BUILD \
diff --git a/libvirt-glib/Makefile.am b/libvirt-glib/Makefile.am
index 12a390f..fa52352 100644
--- a/libvirt-glib/Makefile.am
+++ b/libvirt-glib/Makefile.am
@@ -16,6 +16,7 @@ libvirt_glib_1_0_la_SOURCES = \
libvirt-glib-main.c
 libvirt_glib_1_0_la_CFLAGS = \
-DLIBVIRT_GLIB_BUILD \
+   -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GLib\"" \
-DLOCALEDIR="\"$(datadir)/locale\"" \
$(COVERAGE_CFLAGS) \
diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 5e130ee..210c753 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -66,6 +66,7 @@ libvirt_gobject_1_0_la_SOURCES = \
 nodist_libvirt_gobject_1_0_la_SOURCES = \
$(GOBJECT_GENERATED_FILES)
 libvirt_gobject_1_0_la_CFLAGS = \
+   -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GObject\"" \
-DDATADIR="\"$(datadir)\"" \
-DLIBVIRT_GOBJECT_BUILD \
diff --git a/m4/virt-gettext.m4 b/m4/virt-gettext.m4
deleted file mode 100644
index 07c0920..000
--- a/m4/virt-gettext.m4
+++ /dev/null
@@ -1,5 +0,0 @@
-AC_DEFUN([LIBVIRT_GLIB_GETTEXT],[
-GETTEXT_PACKAGE=libvirt-glib
-AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],"$GETTEXT_PACKAGE", [GETTEXT package 
name])
-])
diff --git a/m4/virt-nls.m4 b/m4/virt-nls.m4
new file 

[libvirt] [glib PATCH 07/15] po: minimize de el en_GB eo es et eu fa fi

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/de.mini.po  |  20 +
 po/de.po   | 153 
 po/el.mini.po  |  20 +
 po/el.po   | 153 
 po/{en_GB.po => en_GB.mini.po} | 141 ++
 po/eo.mini.po  |  20 +
 po/eo.po   | 153 
 po/{es.po => es.mini.po}   | 153 
 po/et.mini.po  |  20 +
 po/et.po   | 153 
 po/eu.mini.po  |  20 +
 po/eu.po   | 153 
 po/fa.mini.po  |  20 +
 po/fa.po   | 153 
 po/fi.mini.po  |  44 ++
 po/fi.po   | 154 -
 16 files changed, 266 insertions(+), 1264 deletions(-)
 create mode 100644 po/de.mini.po
 delete mode 100644 po/de.po
 create mode 100644 po/el.mini.po
 delete mode 100644 po/el.po
 rename po/{en_GB.po => en_GB.mini.po} (51%)
 create mode 100644 po/eo.mini.po
 delete mode 100644 po/eo.po
 rename po/{es.po => es.mini.po} (59%)
 create mode 100644 po/et.mini.po
 delete mode 100644 po/et.po
 create mode 100644 po/eu.mini.po
 delete mode 100644 po/eu.po
 create mode 100644 po/fa.mini.po
 delete mode 100644 po/fa.po
 create mode 100644 po/fi.mini.po
 delete mode 100644 po/fi.po

diff --git a/po/de.mini.po b/po/de.mini.po
new file mode 100644
index 000..b231b64
--- /dev/null
+++ b/po/de.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:20+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: German (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/de/)\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/de.po b/po/de.po
deleted file mode 100644
index 33b3225..000
--- a/po/de.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:20+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: German (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/de/)\n"
-"Language: de\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1761
-msgid "Connection is not open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:742
-msgid "Failed to fetch list of domains"
-msgstr ""

[libvirt] [glib PATCH 12/15] po: minimize or pa pl pt_BR pt ro ru si sk sl

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/or.mini.po  |  20 +
 po/or.po   | 153 
 po/pa.mini.po  |  20 +
 po/pa.po   | 153 
 po/{pl.po => pl.mini.po}   | 152 
 po/pt.mini.po  |  20 +
 po/pt.po   | 153 
 po/{pt_BR.po => pt_BR.mini.po} | 141 ++
 po/ro.mini.po  |  21 +
 po/ro.po   | 154 
 po/ru.mini.po  |  26 ++
 po/ru.po   | 155 -
 po/si.mini.po  |  20 +
 po/si.po   | 153 
 po/sk.mini.po  |  20 +
 po/sk.po   | 153 
 po/sl.mini.po  |  21 +
 po/sl.po   | 154 
 18 files changed, 271 insertions(+), 1418 deletions(-)
 create mode 100644 po/or.mini.po
 delete mode 100644 po/or.po
 create mode 100644 po/pa.mini.po
 delete mode 100644 po/pa.po
 rename po/{pl.po => pl.mini.po} (62%)
 create mode 100644 po/pt.mini.po
 delete mode 100644 po/pt.po
 rename po/{pt_BR.po => pt_BR.mini.po} (54%)
 create mode 100644 po/ro.mini.po
 delete mode 100644 po/ro.po
 create mode 100644 po/ru.mini.po
 delete mode 100644 po/ru.po
 create mode 100644 po/si.mini.po
 delete mode 100644 po/si.po
 create mode 100644 po/sk.mini.po
 delete mode 100644 po/sk.po
 create mode 100644 po/sl.mini.po
 delete mode 100644 po/sl.po

diff --git a/po/or.mini.po b/po/or.mini.po
new file mode 100644
index 000..a07a167
--- /dev/null
+++ b/po/or.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:22+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Oriya (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/or/)\n"
+"Language: or\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/or.po b/po/or.po
deleted file mode 100644
index 7eba353..000
--- a/po/or.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:22+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Oriya (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/or/)\n"
-"Language: or\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: 

[libvirt] [glib PATCH 06/15] po: minimize bn bo br brx bs ca cs cy da de_CH

2019-02-20 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 po/bn.mini.po|  20 +
 po/bn.po | 153 -
 po/bo.mini.po|  20 +
 po/bo.po | 153 -
 po/br.mini.po|  20 +
 po/br.po | 153 -
 po/brx.mini.po   |  20 +
 po/brx.po| 153 -
 po/bs.mini.po|  21 ++
 po/bs.po | 154 --
 po/{ca.po => ca.mini.po} | 152 ++---
 po/{cs.po => cs.mini.po} | 158 +++
 po/cy.mini.po|  21 ++
 po/cy.po | 154 --
 po/da.mini.po|  20 +
 po/da.po | 153 -
 po/de_CH.mini.po |  20 +
 po/de_CH.po  | 153 -
 18 files changed, 281 insertions(+), 1417 deletions(-)
 create mode 100644 po/bn.mini.po
 delete mode 100644 po/bn.po
 create mode 100644 po/bo.mini.po
 delete mode 100644 po/bo.po
 create mode 100644 po/br.mini.po
 delete mode 100644 po/br.po
 create mode 100644 po/brx.mini.po
 delete mode 100644 po/brx.po
 create mode 100644 po/bs.mini.po
 delete mode 100644 po/bs.po
 rename po/{ca.po => ca.mini.po} (62%)
 rename po/{cs.po => cs.mini.po} (57%)
 create mode 100644 po/cy.mini.po
 delete mode 100644 po/cy.po
 create mode 100644 po/da.mini.po
 delete mode 100644 po/da.po
 create mode 100644 po/de_CH.mini.po
 delete mode 100644 po/de_CH.po

diff --git a/po/bn.mini.po b/po/bn.mini.po
new file mode 100644
index 000..3657a5c
--- /dev/null
+++ b/po/bn.mini.po
@@ -0,0 +1,20 @@
+# Libvirt package strings.
+# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: libvirt-glib 2.0.0\n"
+"Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n;
+"POT-Creation-Date: 2019-02-19 18:35+\n"
+"PO-Revision-Date: 2014-12-17 12:19+\n"
+"Last-Translator: Copied by Zanata \n"
+"Language-Team: Bengali (http://www.transifex.com/projects/p/libvirt-glib/;
+"language/bn/)\n"
+"Language: bn\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Zanata 4.6.2\n"
diff --git a/po/bn.po b/po/bn.po
deleted file mode 100644
index b08bf7d..000
--- a/po/bn.po
+++ /dev/null
@@ -1,153 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-10 10:55+0100\n"
-"PO-Revision-Date: 2014-12-17 12:19+\n"
-"Last-Translator: Copied by Zanata \n"
-"Language-Team: Bengali (http://www.transifex.com/projects/p/libvirt-glib/;
-"language/bn/)\n"
-"Language: bn\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Zanata 4.6.2\n"
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:141
-msgid "No XML document to parse"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:149
-msgid "Unable to parse configuration"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-helpers.c:157
-#, c-format
-msgid "XML data has no '%s' node"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:206
-msgid "No XML document associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:214
-msgid "No XML schema associated with this config object"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:223
-#, c-format
-msgid "Unable to create RNG parser for %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:233
-#, c-format
-msgid "Unable to parse RNG %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:245
-#, c-format
-msgid "Unable to create RNG validation context %s"
-msgstr ""
-
-#: ../libvirt-gconfig/libvirt-gconfig-object.c:255
-msgid "Unable to validate doc"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:438
-#, c-format
-msgid "Connection %s is already open"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:453
-#, c-format
-msgid "Unable to open %s"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:464
-msgid "Unable to get connection URI"
-msgstr ""
-
-#: ../libvirt-gobject/libvirt-gobject-connection.c:729
-#: ../libvirt-gobject/libvirt-gobject-connection.c:817
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1504
-#: ../libvirt-gobject/libvirt-gobject-connection.c:1761
-msgid "Connection is not 

[libvirt] [libvirt-php] [PATCH 1/1] Add function libvirt_domain_undefine_flags and libvirt_domain_snapshot_create_xml

2019-02-20 Thread Zhensheng Yuan
Hi,

I created a patch for libvirt-php to support virDomainUndefineFlags and
create snapshot from XML string.
The test case file is
"examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php".
Hoping this is useful for libvirt-php.



>From e753d0014e8ce8cbcafb0fbd92159a6cc9f32168 Mon Sep 17 00:00:00 2001
From: Zhensheng Yuan 
Date: Wed, 20 Feb 2019 18:25:05 +0800
Subject: [libvirt-php PATCH] Add function libvirt_domain_undefine_flags and
 libvirt_domain_snapshot_create_xml

---
 ...lags_and_snapshot_create_xml_test_case.php | 136 ++
 src/libvirt-domain.c  |  23 +++
 src/libvirt-domain.h  |   2 +
 src/libvirt-php.c |  12 ++
 src/libvirt-snapshot.c|  35 +
 src/libvirt-snapshot.h|   2 +
 6 files changed, 210 insertions(+)
 create mode 100644
examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php

diff --git
a/examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
b/examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
new file mode 100644
index 000..e6590ae
--- /dev/null
+++ b/examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
@@ -0,0 +1,136 @@
+assertEquals(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, 1);
+$this->assertEquals(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, 2);
+$this->assertEquals(VIR_DOMAIN_UNDEFINE_NVRAM, 4);
+$this->assertEquals(VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, 8);
+}
+
+public function testSnapshotAndUndefineFlags()
+{
+$libvirtResource = libvirt_connect("test:///default", false);
+$this->assertTrue(is_resource($libvirtResource));
+
+$domainResource = libvirt_domain_define_xml($libvirtResource,
$this->getDomainXML());
+$this->assertTrue(is_resource($domainResource));
+
+// Create a snapshot named snapshot1
+$snapshotResource =
libvirt_domain_snapshot_create_xml($domainResource, <<
+  snapshot1
+
+EOF
+, VIR_SNAPSHOT_CREATE_LIVE | VIR_SNAPSHOT_CREATE_ATOMIC);
+$this->assertTrue(is_resource($snapshotResource));
+
+// Domain with snapshot can not be undefined directly
+$this->assertFalse(@libvirt_domain_undefine($domainResource));
+
+// Use VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA flag to undefine the
domain
+$this->assertTrue(libvirt_domain_undefine_flags($domainResource,
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA));
+}
+
+private function getDomainXML()
+{
+return <<
+  Test
+  1024
+  8
+  
+
+  
+  
+hvm
+/usr/share/ovmf/OVMF.fd
+/var/lib/libvirt/qemu/nvram/guest_VARS.fd
+
+
+
+  
+  
+
+  
+  
+
+
+  
+  
+  
+
+
+  
+  
+  
+  
+102400
+  
+
+
+  
+  
+  
+
+
+  
+  
+  
+  
+
+  
+  
+
+
+  
+
+
+
+  
+
+
+  
+  
+
+  
+  
+  
+
+
+
+
+  
+  
+  
+
+  
+  destroy
+  restart
+  restart
+  
+1000
+
+  /dev/sda
+  1000
+  10240
+  10240
+
+  
+
+EOF
+;
+}
+}
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 8b8bb45..e2dc33e 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1467,6 +1467,29 @@ PHP_FUNCTION(libvirt_domain_undefine)
 RETURN_TRUE;
 }

+/*
+ * Function name:   libvirt_domain_undefine_flags
+ * Description: Function is used to undefine(with flags) the domain
identified by it's resource
+ * Arguments:   @res [resource]: libvirt domain resource, e.g. from
libvirt_domain_lookup_by_*()
+ *  @flags [int]: optional flags
+ * Returns: TRUE for success, FALSE on error
+ */
+PHP_FUNCTION(libvirt_domain_undefine_flags)
+{
+php_libvirt_domain *domain = NULL;
+zval *zdomain;
+int retval;
+zend_long flags = 0;
+
+GET_DOMAIN_FROM_ARGS("r|l", , );
+
+retval = virDomainUndefineFlags(domain->domain, flags);
+DPRINTF("%s: virDomainUndefineFlags(%p) returned %d\n", PHPFUNC,
domain->domain, retval);
+if (retval != 0)
+RETURN_FALSE;
+RETURN_TRUE;
+}
+
 /*
  * Function name:   libvirt_domain_reboot
  * Since version:   0.4.1(-1)
diff --git a/src/libvirt-domain.h b/src/libvirt-domain.h
index dc0ab46..6d98544 100644
--- a/src/libvirt-domain.h
+++ b/src/libvirt-domain.h
@@ -73,6 +73,7 @@
 PHP_FE(libvirt_domain_suspend,   arginfo_libvirt_conn)
 \
 PHP_FE(libvirt_domain_managedsave,   arginfo_libvirt_conn)
 \
 PHP_FE(libvirt_domain_undefine,  arginfo_libvirt_conn)
 \
+PHP_FE(libvirt_domain_undefine_flags,
arginfo_libvirt_conn_flags)   \
 PHP_FE(libvirt_domain_reboot,
arginfo_libvirt_conn_flags)   \
 PHP_FE(libvirt_domain_define_xml,

[libvirt] [PATCH 0/2] udev: Remove udev handle from main loop when udev thread stops

2019-02-20 Thread Marc Hartmayer
Changelog:
 + RFC -> v1:
  - Remove the event handle in the error path of nodeStateInitializeEnumerate
  - Added patch 2: wake up udev thread in case of an error

Marc Hartmayer (2):
  udev: nodeStateInitializeEnumerate: remove watch handle in case of an
error
  udev: wake up the udev thread for stopping it

 src/node_device/node_device_udev.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.17.0

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


[libvirt] [PATCH 1/2] udev: nodeStateInitializeEnumerate: remove watch handle in case of an error

2019-02-20 Thread Marc Hartmayer
If the udev thread is stopped, it must be ensured that the watch
handle is also removed from the main loop.

Signed-off-by: Marc Hartmayer 
---
 src/node_device/node_device_udev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/node_device/node_device_udev.c 
b/src/node_device/node_device_udev.c
index 54f372cd4a9f..4dd2e9004fd7 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1802,6 +1802,8 @@ nodeStateInitializeEnumerate(void *opaque)
 
  error:
 virObjectLock(priv);
+ignore_value(virEventRemoveHandle(priv->watch));
+priv->watch = -1;
 priv->threadQuit = true;
 virObjectUnlock(priv);
 }
-- 
2.17.0

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


[libvirt] [PATCH 2/2] udev: wake up the udev thread for stopping it

2019-02-20 Thread Marc Hartmayer
Signal the udev thread the change of `priv->threadQuit` by using the
thread condition.

Signed-off-by: Marc Hartmayer 
---
 src/node_device/node_device_udev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/node_device/node_device_udev.c 
b/src/node_device/node_device_udev.c
index 4dd2e9004fd7..32e762009f1c 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1805,6 +1805,7 @@ nodeStateInitializeEnumerate(void *opaque)
 ignore_value(virEventRemoveHandle(priv->watch));
 priv->watch = -1;
 priv->threadQuit = true;
+virCondSignal(>threadCond);
 virObjectUnlock(priv);
 }
 
-- 
2.17.0

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


Re: [libvirt] [RFC PATCH] udev: Remove udev handle from main loop when udev thread stops

2019-02-20 Thread Marc Hartmayer
On Tue, Feb 12, 2019 at 09:46 PM +0100, John Ferlan  wrote:
> On 2/7/19 11:08 AM, Marc Hartmayer wrote:
>> Commit "nodedev: Move device enumumeration out of nodeStateInitialize"
>> (9f0ae0b18e3e620) has moved the heavy task of device enumeration into
>> a separate thread. The problem with this commit is that there is a
>> functionality change in the cleanup when udevEnumerateDevices
>> fails. Before commit 9f0ae0b18e3e620, the entire driver was cleaned up
>> by calling nodeStateCleanup (defined in node_device_udev.c) which
>> resulted in libvirtd stopping with the error message
>> 'daemonRunStateInit:800 : Driver state initialization failed'. With
>> the commit 9f0ae0b18e3e620 there is only a signal to the udev thread
>> that it must stop. This means that for example the watch handle isn't
>> removed from the main loop and this can result in the main loop
>> consuming 100% CPU time as soon as a new udev event occurs.
>>
>> This patch proposes a simple solution to the described problem. In
>> case the udev thread stops the watch handle is removed from the main
>> loop.
>>
>> Fixes: 9f0ae0b18e3e620 ("nodedev: Move device enumumeration out of 
>> nodeStateInitialize")
>> Signed-off-by: Marc Hartmayer 
>> ---
>>
>> Note: I'm not sure whether we should stop libvirtd (as it would have
>>   been done before) or if this patch is already sufficient.
>>
>> ---
>>  src/node_device/node_device_udev.c | 7 +++
>>  1 file changed, 7 insertions(+)
>>
>
> What you have seems reasonable - although I wonder if it would be better
> to remove the event handle in the error of nodeStateInitializeEnumerate.
>
> I think the assumption made was that by setting threadQuit that the next
> event have some sort of failure through udevEventMonitorSanityCheck
> which removes the EventHandle too. Although I cannot be sure it's been
> too long to remember for sure ;-)
>
> Furthermore, should nodeStateCleanup be altered to check for priv->watch
> == -1 and thus not worry about the code to set threadQuit, signal, and
> joining the thread.

A simple check for `priv->threadQuit` is probably even more useful since
it’s not safe that the watch callback is set.

I’ll send a v2 with the changes you suggested.

>
> John
>
> BTW: I'm subscribed to the list, no need to CC...
>
>> diff --git a/src/node_device/node_device_udev.c 
>> b/src/node_device/node_device_udev.c
>> index b1e5f00067e8..299f55260129 100644
>> --- a/src/node_device/node_device_udev.c
>> +++ b/src/node_device/node_device_udev.c
>> @@ -1628,6 +1628,13 @@ udevEventHandleThread(void *opaque ATTRIBUTE_UNUSED)
>>  }
>>
>>  if (priv->threadQuit) {
>> +if (priv->watch != -1) {
>> +/* Since the udev thread getting stopped remove the
>> + * watch handle from the main loop */
>> +virEventRemoveHandle(priv->watch);
>> +priv->watch = -1;
>> +}
>> +
>>  virObjectUnlock(priv);
>>  return;
>>  }
>>
>
--
Kind regards / Beste Grüße
   Marc Hartmayer

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


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

[libvirt] [PATCH 2/2] qemu: Replace virDomainChrSourceDefFree with virObjectUnref

2019-02-20 Thread Marc Hartmayer
Replace virDomainChrSourceDefFree with virObjectUnref.

Signed-off-by: Marc Hartmayer 
Reviewed-by: Boris Fiuczynski 
---
 cfg.mk|  1 -
 src/conf/domain_conf.c| 17 +
 src/conf/domain_conf.h|  1 -
 src/libvirt_private.syms  |  1 -
 src/qemu/qemu_domain.c|  4 ++--
 src/qemu/qemu_parse_command.c |  4 ++--
 src/qemu/qemu_process.c   |  5 ++---
 7 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index c2524de5fc6b..7762422da764 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -120,7 +120,6 @@ useless_free_options = \
   --name=virConfFreeValue \
   --name=virDomainActualNetDefFree \
   --name=virDomainChrDefFree \
-  --name=virDomainChrSourceDefFree \
   --name=virDomainControllerDefFree \
   --name=virDomainDefFree \
   --name=virDomainDeviceDefFree \
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 56c437ca0a34..5b61656d89b9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2194,7 +2194,7 @@ virDomainNetDefClear(virDomainNetDefPtr def)
 
 switch (def->type) {
 case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
-virDomainChrSourceDefFree(def->data.vhostuser);
+virObjectUnref(def->data.vhostuser);
 def->data.vhostuser = NULL;
 break;
 
@@ -2433,13 +2433,6 @@ virDomainChrSourceDefDispose(void *obj)
 }
 
 
-void
-virDomainChrSourceDefFree(virDomainChrSourceDefPtr def)
-{
-virObjectUnref(def);
-}
-
-
 /* virDomainChrSourceDefIsEqual:
  * @src: Source
  * @tgt: Target
@@ -2530,7 +2523,7 @@ void virDomainChrDefFree(virDomainChrDefPtr def)
 break;
 }
 
-virDomainChrSourceDefFree(def->source);
+virObjectUnref(def->source);
 virDomainDeviceInfoClear(>info);
 
 VIR_FREE(def);
@@ -2553,7 +2546,7 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefPtr 
def)
 break;
 
 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
-virDomainChrSourceDefFree(def->data.passthru);
+virObjectUnref(def->data.passthru);
 break;
 
 default:
@@ -2812,7 +2805,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def)
 if (!def)
 return;
 
-virDomainChrSourceDefFree(def->source);
+virObjectUnref(def->source);
 virDomainDeviceInfoClear(>info);
 
 VIR_FREE(def);
@@ -26562,7 +26555,7 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
 VIR_FREE(def->source.file);
 break;
 case VIR_DOMAIN_RNG_BACKEND_EGD:
-virDomainChrSourceDefFree(def->source.chardev);
+virObjectUnref(def->source.chardev);
 break;
 case VIR_DOMAIN_RNG_BACKEND_LAST:
 break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9bccd8bcd15c..f205fc872328 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2911,7 +2911,6 @@ void virDomainNetDefClear(virDomainNetDefPtr def);
 void virDomainNetDefFree(virDomainNetDefPtr def);
 void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
 void virDomainChrDefFree(virDomainChrDefPtr def);
-void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
 int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
   virDomainChrSourceDefPtr src);
 void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b720acdc939d..e5c9ccdbe497 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -221,7 +221,6 @@ virDomainChrSerialTargetTypeFromString;
 virDomainChrSerialTargetTypeToString;
 virDomainChrSourceDefClear;
 virDomainChrSourceDefCopy;
-virDomainChrSourceDefFree;
 virDomainChrSourceDefGetPath;
 virDomainChrSourceDefNew;
 virDomainChrSpicevmcTypeFromString;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bbd4a5efe8d8..9996098494d7 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2063,7 +2063,7 @@ qemuDomainObjPrivateFree(void *data)
 
 qemuDomainObjPrivateDataClear(priv);
 
-virDomainChrSourceDefFree(priv->monConfig);
+virObjectUnref(priv->monConfig);
 qemuDomainObjFreeJob(priv);
 VIR_FREE(priv->lockState);
 VIR_FREE(priv->origname);
@@ -3084,7 +3084,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
 VIR_FREE(tmp);
 virBitmapFree(priv->namespaces);
 priv->namespaces = NULL;
-virDomainChrSourceDefFree(priv->monConfig);
+virObjectUnref(priv->monConfig);
 priv->monConfig = NULL;
 virStringListFree(priv->qemuDevices);
 priv->qemuDevices = NULL;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 81691cb85ee1..49b34b1c178e 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -2495,7 +2495,7 @@ qemuParseCommandLine(virFileCachePtr capsCache,
 goto error;
 
 if (qemuParseCommandLineChr(chr, val) < 0) {
-virDomainChrSourceDefFree(chr);
+virObjectUnref(chr);
   

[libvirt] [PATCH 0/2] Get rid of virDomainChrSourceDefFree

2019-02-20 Thread Marc Hartmayer
Marc Hartmayer (2):
  qemu: Use refcounting for priv->monConfig
  qemu: Replace virDomainChrSourceDefFree with virObjectUnref

 cfg.mk|  1 -
 src/conf/domain_conf.c| 17 +
 src/conf/domain_conf.h|  1 -
 src/libvirt_private.syms  |  1 -
 src/qemu/qemu_domain.c|  4 ++--
 src/qemu/qemu_driver.c|  5 +
 src/qemu/qemu_parse_command.c |  4 ++--
 src/qemu/qemu_process.c   | 11 +--
 8 files changed, 15 insertions(+), 29 deletions(-)

-- 
2.17.0

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