[libvirt] [PATCH 1/2] qemu: cold-plug of sound

2019-10-14 Thread Jidong Xia
With this patch users can cold plug some sound devices.
use "virsh attach-device vm sound.xml --config" command.
Consider the following sound.xml for a domain:

 


Signed-off-by: Jidong Xia 
---
 src/qemu/qemu_driver.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bc0ede2..8e7156c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8266,6 +8266,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
 {
 virDomainDiskDefPtr disk;
 virDomainNetDefPtr net;
+virDomainSoundDefPtr sound;
 virDomainHostdevDefPtr hostdev;
 virDomainLeaseDefPtr lease;
 virDomainControllerDefPtr controller;
@@ -8300,6 +8301,13 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
 dev->data.net = NULL;
 break;

+case VIR_DOMAIN_DEVICE_SOUND:
+sound = dev->data.sound;
+if (VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound) < 0)
+return -1;
+dev->data.sound = NULL;
+break;
+
 case VIR_DOMAIN_DEVICE_HOSTDEV:
 hostdev = dev->data.hostdev;
 if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
@@ -8434,7 +8442,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
 VIR_STEAL_PTR(vmdef->vsock, dev->data.vsock);
 break;

-case VIR_DOMAIN_DEVICE_SOUND:
 case VIR_DOMAIN_DEVICE_VIDEO:
 case VIR_DOMAIN_DEVICE_GRAPHICS:
 case VIR_DOMAIN_DEVICE_HUB:
--
1.8.3.1



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


[libvirt] [virttools-planet PATCH] Add Fabiano Fidencio to Planet Virt-Tools

2019-10-14 Thread Fabiano Fidêncio
Signed-off-by: Fabiano Fidêncio 
---
 updater/virt-tools/config.ini | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/updater/virt-tools/config.ini b/updater/virt-tools/config.ini
index 6b4b5ec..9375c82 100644
--- a/updater/virt-tools/config.ini
+++ b/updater/virt-tools/config.ini
@@ -194,3 +194,6 @@ name = Stefano Garzarella
 face = sgarzare.png
 facewidth = 89
 faceheight = 96
+
+[https://fidencio.org/tags/virt/index.xml]
+name = Fabiano Fidêncio
-- 
2.23.0

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

[libvirt] [PATCH 0/2] qemu: cold-plug and cold-unplug of sound

2019-10-14 Thread Jidong Xia
With this patch users can cold plug and unplug some sound devices.

Jidong Xia (2):
  qemu: cold-plug of sound
  qemu: cold-unplug of sound

 src/conf/domain_conf.c   | 61 
 src/conf/domain_conf.h   |  2 ++
 src/libvirt_private.syms |  2 ++
 src/qemu/qemu_driver.c   | 18 --
 4 files changed, 81 insertions(+), 2 deletions(-)

--
1.8.3.1



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


[libvirt] [PATCH 2/2] qemu: cold-unplug of sound

2019-10-14 Thread Jidong Xia
With this patch users can cold unplug some sound devices.
use "virsh detach-device vm sound.xml --config" command.

Signed-off-by: Jidong Xia 
---
 src/conf/domain_conf.c   | 61 
 src/conf/domain_conf.h   |  2 ++
 src/libvirt_private.syms |  2 ++
 src/qemu/qemu_driver.c   |  9 ++-
 4 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c1705a0..4083b7c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2754,6 +2754,15 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefPtr 
def)
 VIR_FREE(def);
 }

+virDomainSoundDefPtr
+virDomainSoundDefRemove(virDomainDefPtr def, size_t idx)
+{
+virDomainSoundDefPtr ret = def->sounds[idx];
+VIR_DELETE_ELEMENT(def->sounds, idx, def->nsounds);
+return ret;
+ }
+
+
 void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def)
 {
 if (!def)
@@ -17211,6 +17220,58 @@ virDomainNetUpdate(virDomainDefPtr def,
 return 0;
 }

+/**
+ * virDomainSoundFindIdx:
+ * @def: domain definition
+ * @sound: sound definition
+ *
+ * Lookup domain's sound interface based on passed @sound
+ * definition.
+ *
+ * Return: index of match if unique match found,
+ * -1 otherwise and an error is logged.
+ */
+
+int
+virDomainSoundFindIdx(virDomainDefPtr def, virDomainSoundDefPtr sound)
+{
+size_t i;
+int matchidx = -1;
+bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&sound->info,
+  
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI);
+
+for (i = 0; i < def->nsounds; i++) {
+
+if (PCIAddrSpecified &&
+!virPCIDeviceAddressEqual(&def->sounds[i]->info.addr.pci,
+  &sound->info.addr.pci))
+continue;
+
+if (matchidx >= 0) {
+virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+   _("multiple matching devices found"));
+
+return -1;
+}
+
+matchidx = i;
+}
+
+if (matchidx < 0) {
+if (PCIAddrSpecified) {
+virReportError(VIR_ERR_DEVICE_MISSING,
+   _("no device found on %.4x:%.2x:%.2x.%.1x"),
+   sound->info.addr.pci.domain,
+   sound->info.addr.pci.bus,
+   sound->info.addr.pci.slot,
+   sound->info.addr.pci.function);
+} else {
+virReportError(VIR_ERR_DEVICE_MISSING, "%s",
+   _("no matching device found"));
+}
+}
+return matchidx;
+}

 int virDomainControllerInsert(virDomainDefPtr def,
   virDomainControllerDefPtr controller)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f7404b8..676c076 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2873,6 +2873,8 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefPtr 
def);
 void virDomainChrDefFree(virDomainChrDefPtr def);
 int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
   virDomainChrSourceDefPtr src);
+int virDomainSoundFindIdx(virDomainDefPtr def, virDomainSoundDefPtr sound);
+virDomainSoundDefPtr virDomainSoundDefRemove(virDomainDefPtr def, size_t idx);
 void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
 void virDomainSoundDefFree(virDomainSoundDefPtr def);
 void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7d62df8..c2d9175 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -579,6 +579,8 @@ virDomainSmartcardTypeToString;
 virDomainSmbiosModeTypeFromString;
 virDomainSmbiosModeTypeToString;
 virDomainSoundDefFree;
+virDomainSoundDefRemove;
+virDomainSoundFindIdx;
 virDomainSoundModelTypeFromString;
 virDomainSoundModelTypeToString;
 virDomainStartupPolicyTypeFromString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8e7156c..3281bca 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8476,6 +8476,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 {
 virDomainDiskDefPtr disk, det_disk;
 virDomainNetDefPtr net;
+virDomainSoundDefPtr sound;
 virDomainHostdevDefPtr hostdev, det_hostdev;
 virDomainLeaseDefPtr lease, det_lease;
 virDomainControllerDefPtr cont, det_cont;
@@ -8504,6 +8505,13 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 virDomainNetDefFree(virDomainNetRemove(vmdef, idx));
 break;

+case VIR_DOMAIN_DEVICE_SOUND:
+sound = dev->data.sound;
+if ((idx = virDomainSoundFindIdx(vmdef, sound)) < 0)
+return -1;
+virDomainSoundDefFree(virDomainSoundDefRemove(vmdef, idx));
+break;
+
 case VIR_DOMAIN_DEVICE_HOSTDEV: {
 hostdev = dev->data.hostdev;
 if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0)

Re: [libvirt] [PATCH v3 03/19] util: use glib memory allocation functions

2019-10-14 Thread Han Han
Not reproduced when build source before `make clean`. Please ignore that
issue

On Tue, Oct 15, 2019 at 10:20 AM Han Han  wrote:

>
>
> On Thu, Oct 10, 2019 at 6:54 PM Daniel P. Berrangé 
> wrote:
>
>> Convert the VIR_ALLOC family of APIs with use of the g_malloc family of
>> APIs. Use of VIR_ALLOC related functions should be incrementally phased
>> out over time, allowing return value checks to be dropped. Use of
>> VIR_FREE should be replaced with auto-cleanup whenever possible.
>>
>> We previously used the 'calloc-posix' gnulib module because mingw does
>> not set errno to ENOMEM on failure.
>>
>> Reviewed-by: Ján Tomko 
>> Signed-off-by: Daniel P. Berrangé 
>> ---
>>  bootstrap.conf   |   1 -
>>  docs/hacking.html.in | 106 +--
>>  src/util/viralloc.c  |  29 +++-
>>  src/util/viralloc.h  |   9 
>>  4 files changed, 27 insertions(+), 118 deletions(-)
>>
>> diff --git a/bootstrap.conf b/bootstrap.conf
>> index 358d783a6b..7d73584809 100644
>> --- a/bootstrap.conf
>> +++ b/bootstrap.conf
>> @@ -26,7 +26,6 @@ byteswap
>>  c-ctype
>>  c-strcase
>>  c-strcasestr
>> -calloc-posix
>>  canonicalize-lgpl
>>  chown
>>  clock-time
>> diff --git a/docs/hacking.html.in b/docs/hacking.html.in
>> index 2e064ced5e..8072796312 100644
>> --- a/docs/hacking.html.in
>> +++ b/docs/hacking.html.in
>> @@ -1008,102 +1008,20 @@ BAD:
>>  
>>
>>  
>> +  VIR_ALLOC, VIR_REALLOC, VIR_RESIZE_N, VIR_EXPAND_N,
>> +VIR_SHRINK_N, VIR_FREE, VIR_APPEND_ELEMENT, VIR_INSERT_ELEMENT,
>> +VIR_DELETE_ELEMENT
>> +  Prefer the GLib APIs g_new0/g_renew/g_free in most cases.
>> +There should rarely be a need to use g_malloc/g_realloc.
>> +Instead of using plain C arrays, it is preferrable to use
>> +one of the GLib types, GArray, GPtrArray or GByteArray. These
>> +all use a struct to track the array memory and size together
>> +and efficiently resize. NEVER MIX use of the
>> +classic libvirt memory allocation APIs and GLib APIs within
>> +a single method. Keep the style consistent, converting existing
>> +code to GLib style in a separate, prior commit.
>>  
>>
>> -Low level memory management
>> -
>> -
>> -  Use of the malloc/free/realloc/calloc APIs is deprecated in the
>> libvirt
>> -  codebase, because they encourage a number of serious coding bugs
>> and do
>> -  not enable compile time verification of checks for NULL. Instead
>> of these
>> -  routines, use the macros from viralloc.h.
>> -
>> -
>> -
>> -  To allocate a single object:
>> -
>> -
>> -  virDomainPtr domain;
>> -
>> -  if (VIR_ALLOC(domain) < 0)
>> -  return NULL;
>> -
>> -  
>> -
>> -  To allocate an array of objects:
>> -
>> -  virDomainPtr domains;
>> -  size_t ndomains = 10;
>> -
>> -  if (VIR_ALLOC_N(domains, ndomains) < 0)
>> -  return NULL;
>> -
>> -  
>> -
>> -  To allocate an array of object pointers:
>> -
>> -  virDomainPtr *domains;
>> -  size_t ndomains = 10;
>> -
>> -  if (VIR_ALLOC_N(domains, ndomains) < 0)
>> -  return NULL;
>> -
>> -  
>> -
>> -  To re-allocate the array of domains to be 1 element
>> -  longer (however, note that repeatedly expanding an array by 1
>> -  scales quadratically, so this is recommended only for smaller
>> -  arrays):
>> -
>> -  virDomainPtr domains;
>> -  size_t ndomains = 0;
>> -
>> -  if (VIR_EXPAND_N(domains, ndomains, 1) < 0)
>> -  return NULL;
>> -  domains[ndomains - 1] = domain;
>> -
>> -
>> -  To ensure an array has room to hold at least one more
>> -  element (this approach scales better, but requires tracking
>> -  allocation separately from usage)
>> -
>> -
>> -  virDomainPtr domains;
>> -  size_t ndomains = 0;
>> -  size_t ndomains_max = 0;
>> -
>> -  if (VIR_RESIZE_N(domains, ndomains_max, ndomains, 1) < 0)
>> -  return NULL;
>> -  domains[ndomains++] = domain;
>> -
>> -  
>> -
>> -  To trim an array of domains from its allocated size down
>> -  to the actual used size:
>> -
>> -
>> -  virDomainPtr domains;
>> -  size_t ndomains = x;
>> -  size_t ndomains_max = y;
>> -
>> -  VIR_SHRINK_N(domains, ndomains_max, ndomains_max - ndomains);
>> -
>> -
>> -  To free an array of domains:
>> -
>> -  virDomainPtr domains;
>> -  size_t ndomains = x;
>> -  size_t ndomains_max = y;
>> -  size_t i;
>> -
>> -  for (i = 0; i < ndomains; i++)
>> -  VIR_FREE(domains[i]);
>> -  VIR_FREE(domains);
>> -  ndomains_max = ndomains = 0;
>> -
>> -  
>> -
>> -
>>  File handling
>>
>>  
>> diff --git a/src/util/viralloc.c b/src/util/viralloc.c
>> index 10a8d0fb73..b8ca850764 100644
>> --- a/src/util/viralloc.c
>> +++ b/src/util/viralloc.c
>> @@ -45,10 +45,7 @@ VIR_LOG_INIT("util.alloc");
>>  int virAlloc(void *ptrptr,
>>   size_t size)
>>  {
>> -*(void **)ptrptr = calloc(1, size);
>> -if (*(void **)ptrptr == NULL)
>> -abort();
>> -
>> +

Re: [libvirt] [PATCH 1/3] conf: Set rebootTimeout valid range to 0..0xffff

2019-10-14 Thread Han Han
Hi Michal,
Any more advice update?

On Tue, Oct 8, 2019 at 8:42 PM Han Han  wrote:

>
>
> On Tue, Oct 8, 2019 at 5:50 PM Michal Privoznik 
> wrote:
>
>> On 10/8/19 10:36 AM, Han Han wrote:
>> > Adjust valid range of rebootTimeout according to qemu-4.0.0 commit
>> > ee5d0f89de3.
>> >
>> > Signed-off-by: Han Han 
>> > ---
>> >   src/conf/domain_conf.c | 6 --
>> >   1 file changed, 4 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> > index a53cd6a725..57ab254f52 100644
>> > --- a/src/conf/domain_conf.c
>> > +++ b/src/conf/domain_conf.c
>> > @@ -18090,10 +18090,12 @@ virDomainDefParseBootXML(xmlXPathContextPtr
>> ctxt,
>> >   /* that was really just for the check if it is there */
>> >
>> >   if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay)
>> < 0 ||
>> > -def->os.bios.rt_delay < -1 || def->os.bios.rt_delay >
>> 65535) {
>> > +def->os.bios.rt_delay < 0 || def->os.bios.rt_delay >
>> 65535) {
>> >   virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> >  _("invalid value for rebootTimeout, "
>> > - "must be in range [-1,65535]"));
>> > + "must be in range [0,65535]. "
>> > + "To disable reboot, "
>> > + "just remove this attribute."));
>> >   return -1;
>> >   }
>> >   def->os.bios.rt_set = true;
>> >
>>
>> Firstly¸patch 2/3 must come before 1/3 because we require patches to be
>> able to compile & run 'make syntax-check check' successfuly after every
>> single one.
>>
>> But more serious problem is, that we document that -1 is a special value
>> that disables automatic reboot. So did QEMU just lose functionality
>> there? If they have some other way to prevent automatic reboot on failed
>>
> Yes.
> The qemu commit ee5d0f89de3 says:
> " This patch checks for conversion errors properly, and reject all values
>   outside 0...0x."
> And check the definition of fw_cfg_reboot(), you can found the default
> value
> passed to pointer argument is alwarys -1 before or after the commit.
>
> Test on qemu-4.0.0:
> # qemu-system-x86_64 -boot reboot-timeout=-1 /tmp/new
> WARNING: Image format was not specified for '/tmp/new' and probing guessed
> raw.
>  Automatically detecting the format is dangerous for raw images,
> write operations on block 0 will be restricted.
>  Specify the 'raw' format explicitly to remove the restrictions.
> qemu-system-x86_64: reboot timeout is invalid,it should be a value between
> 0 and 65535
>
> # echo $?
> 1
>
>> boot, then we need to use that if user requested -1.
>>
>> Michal
>>
>
>
> --
> Best regards,
> ---
> Han Han
> Quality Engineer
> Redhat.
>
> Email: h...@redhat.com
> Phone: +861065339333
>


-- 
Best regards,
---
Han Han
Quality Engineer
Redhat.

Email: h...@redhat.com
Phone: +861065339333
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 00/30] storagefile, security: qcow2 data_file support

2019-10-14 Thread Han Han
I find the issue cannot reproduced when `make clean` before build the
source.
It is not proper to build with an unclean source dir, right?

On Tue, Oct 15, 2019 at 3:55 AM Cole Robinson  wrote:

> On 10/12/19 11:07 AM, Han Han wrote:
> >
> >
> > On Sat, Oct 12, 2019 at 1:05 AM Cole Robinson  > > wrote:
> >
> > On 10/10/19 11:25 PM, Han Han wrote:
> > > Hi Cole,
> > > I merged crobinso/qcow2-data_file branch to 37b565c00. Reserved new
> > > capabilities introduced by these to branches to resolve conflicts.
> > > Then build and test as following:
> > > # ./autogen.sh&& ./configure --without-libssh
> > > --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu
> > > --program-prefix= --disable-dependency-tracking --prefix=/usr
> > > --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
> > > --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include
> > > --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var
> > > --sharedstatedir=/var/lib --mandir=/usr/share/man
> > > --infodir=/usr/share/info --with-qemu --without-openvz
> --without-lxc
> > > --without-vbox --without-libxl --with-sasl --with-polkit
> > --with-libvirtd
> > > --without-phyp --with-esx --without-hyperv --without-vmware
> > > --without-xenapi --without-vz --without-bhyve --with-interface
> > > --with-network --with-storage-fs --with-storage-lvm
> > --with-storage-iscsi
> > > --with-storage-iscsi-direct --with-storage-scsi --with-storage-disk
> > > --with-storage-mpath --with-storage-rbd --without-storage-sheepdog
> > > --with-storage-gluster --without-storage-zfs
> > --without-storage-vstorage
> > > --with-numactl --with-numad --with-capng --without-fuse
> --with-netcf
> > > --with-selinux --with-selinux-mount=/sys/fs/selinux
> > --without-apparmor
> > > --without-hal --with-udev --with-yajl --with-sanlock --with-libpcap
> > > --with-macvtap --with-audit --with-dtrace --with-driver-modules
> > > --with-firewalld --with-firewalld-zone
> --without-wireshark-dissector
> > > --without-pm-utils --with-nss-plugin '--with-packager=Unknown,
> > > 2019-08-19-12:13:01, lab.rhel8.me 
> > '
> > > --with-packager-version=1.el8 --with-qemu-user=qemu
> > > --with-qemu-group=qemu --with-tls-priority=@LIBVIRT,SYSTEM
> > > --enable-werror --enable-expensive-tests --with-init-script=systemd
> > > --without-login-shell && make
> > >
> > > Start libvirtd and virtlogd
> > > # LD_PRELOAD="$(find src -name '*.so.*'|tr '\n' ' ')"
> > src/.libs/libvirtd
> > > # LD_PRELOAD="$(find src -name '*.so.*'|tr '\n' ' ')"
> ./src/virtlogd
> > >
> > > Then try to list all domains:
> > > # virsh list --all
> > >
> > > Libvirtd exits with segment fault:
> > > [1]30104 segmentation fault (core dumped)  LD_PRELOAD="$(find
> src
> > > -name '*.so.*'|tr '\n' ' ')" src/.libs/libvirtd
> > >
> > > Version:
> > > qemu-4.1
> > >
> > > Backtrace:
> > > (gdb) bt
> > > #0  0x7fbe57a0d1b9 in
> virDomainVirtioSerialAddrSetAddControllers
> > > (def=, def=, addrs=)
> at
> > > conf/domain_addr.c:1656
> > > #1  virDomainVirtioSerialAddrSetCreateFromDomain
> > > (def=def@entry=0x7fbde81cc3f0) at conf/domain_addr.c:1753
> > > #2  0x7fbe0179897e in qemuDomainAssignVirtioSerialAddresses
> > > (def=0x7fbde81cc3f0) at qemu/qemu_domain_address.c:3174
> > > #3  qemuDomainAssignAddresses (def=0x7fbde81cc3f0,
> > > qemuCaps=0x7fbde81d2210, driver=0x7fbde8126850, obj=0x0,
> > > newDomain=) at qemu/qemu_domain_address.c:3174
> > > #4  0x7fbe57a39e0d in virDomainDefPostParse
> > > (def=def@entry=0x7fbde81cc3f0, caps=caps@entry=0x7fbde8154d20,
> > > parseFlags=parseFlags@entry=4610, xmlopt=xmlopt@entry
> =0x7fbde83ce070,
> > >  parseOpaque=parseOpaque@entry=0x0) at conf/domain_conf.c:5858
> > > #5  0x7fbe57a525c5 in virDomainDefParseNode (xml= out>,
> > > root=0x7fbde83c5ff0, caps=0x7fbde8154d20, xmlopt=0x7fbde83ce070,
> > > parseOpaque=0x0, flags=4610) at conf/domain_conf.c:21677
> > > #6  0x7fbe57a526c8 in virDomainDefParse (xmlStr=xmlStr@entry
> =0x0,
> > > filename=, caps=caps@entry=0x7fbde8154d20,
> > > xmlopt=xmlopt@entry=0x7fbde83ce070, parseOpaque=parseOpaque@entry
> =0x0,
> > >  flags=flags@entry=4610) at conf/domain_conf.c:21628
> > > #7  0x7fbe57a528f6 in virDomainDefParseFile
> (filename= > > out>, caps=caps@entry=0x7fbde8154d20,
> > > xmlopt=xmlopt@entry=0x7fbde83ce070,
> > parseOpaque=parseOpaque@entry=0x0,
> > > flags=flags@entry=4610)
> > >  at conf/domain_conf.c:21653
> > > #8  0x7fbe57a5e16a in virDomainObjListLoadConfig (opaque=0x0,
> > > notify=0x0, name=0x7fbde81d7ff3 "pc", autostartDir=0x7fbde8124070
> > > "/etc/libvirt/qem

[libvirt] [PATCH v2] util: Block SIGPIPE until execve in child process

2019-10-14 Thread Wang Yechao
Libvirtd has set SIGPIPE to ignored, and virFork resets all signal
handlers to the defaults. But child process may write logs to
stderr/stdout, that may generate SIGPIPE if journald has stopped.

So block SIGPIPE in virFork, and unblock it before execve.

Signed-off-by: Wang Yechao 
---
v1 patch:
https://www.redhat.com/archives/libvir-list/2019-October/msg00720.html

Changes in v2:
 -  use pthread_sigmask to block SIGPIPE
---
 src/util/vircommand.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 79e1e87..bd3a582 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -321,6 +321,15 @@ virFork(void)
 virDispatchError(NULL);
 _exit(EXIT_CANCELED);
 }
+
+sigemptyset(&newmask);
+sigaddset(&newmask, SIGPIPE);
+if (pthread_sigmask(SIG_BLOCK, &newmask, NULL) != 0) {
+virReportSystemError(errno, "%s", _("cannot block SIGPIPE"));
+virDispatchError(NULL);
+_exit(EXIT_CANCELED);
+}
+
 }
 return pid;
 }
@@ -553,6 +562,7 @@ virExec(virCommandPtr cmd)
 struct sigaction waxon, waxoff;
 VIR_AUTOFREE(gid_t *) groups = NULL;
 int ngroups;
+sigset_t set;
 
 if (cmd->args[0][0] != '/') {
 if (!(binary = binarystr = virFindFileInPath(cmd->args[0]))) {
@@ -792,6 +802,13 @@ virExec(virCommandPtr cmd)
 /* Close logging again to ensure no FDs leak to child */
 virLogReset();
 
+sigemptyset(&set);
+sigaddset(&set, SIGPIPE);
+if (pthread_sigmask(SIG_SETMASK, &set, NULL) != 0) {
+virReportSystemError(errno, "%s", _("cannot unblock SIGPIPE"));
+goto fork_error;
+}
+
 if (cmd->env)
 execve(binary, cmd->args, cmd->env);
 else
-- 
1.8.3.1

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


Re: [libvirt] [PATCH v3 03/19] util: use glib memory allocation functions

2019-10-14 Thread Han Han
On Thu, Oct 10, 2019 at 6:54 PM Daniel P. Berrangé 
wrote:

> Convert the VIR_ALLOC family of APIs with use of the g_malloc family of
> APIs. Use of VIR_ALLOC related functions should be incrementally phased
> out over time, allowing return value checks to be dropped. Use of
> VIR_FREE should be replaced with auto-cleanup whenever possible.
>
> We previously used the 'calloc-posix' gnulib module because mingw does
> not set errno to ENOMEM on failure.
>
> Reviewed-by: Ján Tomko 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  bootstrap.conf   |   1 -
>  docs/hacking.html.in | 106 +--
>  src/util/viralloc.c  |  29 +++-
>  src/util/viralloc.h  |   9 
>  4 files changed, 27 insertions(+), 118 deletions(-)
>
> diff --git a/bootstrap.conf b/bootstrap.conf
> index 358d783a6b..7d73584809 100644
> --- a/bootstrap.conf
> +++ b/bootstrap.conf
> @@ -26,7 +26,6 @@ byteswap
>  c-ctype
>  c-strcase
>  c-strcasestr
> -calloc-posix
>  canonicalize-lgpl
>  chown
>  clock-time
> diff --git a/docs/hacking.html.in b/docs/hacking.html.in
> index 2e064ced5e..8072796312 100644
> --- a/docs/hacking.html.in
> +++ b/docs/hacking.html.in
> @@ -1008,102 +1008,20 @@ BAD:
>  
>
>  
> +  VIR_ALLOC, VIR_REALLOC, VIR_RESIZE_N, VIR_EXPAND_N,
> +VIR_SHRINK_N, VIR_FREE, VIR_APPEND_ELEMENT, VIR_INSERT_ELEMENT,
> +VIR_DELETE_ELEMENT
> +  Prefer the GLib APIs g_new0/g_renew/g_free in most cases.
> +There should rarely be a need to use g_malloc/g_realloc.
> +Instead of using plain C arrays, it is preferrable to use
> +one of the GLib types, GArray, GPtrArray or GByteArray. These
> +all use a struct to track the array memory and size together
> +and efficiently resize. NEVER MIX use of the
> +classic libvirt memory allocation APIs and GLib APIs within
> +a single method. Keep the style consistent, converting existing
> +code to GLib style in a separate, prior commit.
>  
>
> -Low level memory management
> -
> -
> -  Use of the malloc/free/realloc/calloc APIs is deprecated in the
> libvirt
> -  codebase, because they encourage a number of serious coding bugs
> and do
> -  not enable compile time verification of checks for NULL. Instead of
> these
> -  routines, use the macros from viralloc.h.
> -
> -
> -
> -  To allocate a single object:
> -
> -
> -  virDomainPtr domain;
> -
> -  if (VIR_ALLOC(domain) < 0)
> -  return NULL;
> -
> -  
> -
> -  To allocate an array of objects:
> -
> -  virDomainPtr domains;
> -  size_t ndomains = 10;
> -
> -  if (VIR_ALLOC_N(domains, ndomains) < 0)
> -  return NULL;
> -
> -  
> -
> -  To allocate an array of object pointers:
> -
> -  virDomainPtr *domains;
> -  size_t ndomains = 10;
> -
> -  if (VIR_ALLOC_N(domains, ndomains) < 0)
> -  return NULL;
> -
> -  
> -
> -  To re-allocate the array of domains to be 1 element
> -  longer (however, note that repeatedly expanding an array by 1
> -  scales quadratically, so this is recommended only for smaller
> -  arrays):
> -
> -  virDomainPtr domains;
> -  size_t ndomains = 0;
> -
> -  if (VIR_EXPAND_N(domains, ndomains, 1) < 0)
> -  return NULL;
> -  domains[ndomains - 1] = domain;
> -
> -
> -  To ensure an array has room to hold at least one more
> -  element (this approach scales better, but requires tracking
> -  allocation separately from usage)
> -
> -
> -  virDomainPtr domains;
> -  size_t ndomains = 0;
> -  size_t ndomains_max = 0;
> -
> -  if (VIR_RESIZE_N(domains, ndomains_max, ndomains, 1) < 0)
> -  return NULL;
> -  domains[ndomains++] = domain;
> -
> -  
> -
> -  To trim an array of domains from its allocated size down
> -  to the actual used size:
> -
> -
> -  virDomainPtr domains;
> -  size_t ndomains = x;
> -  size_t ndomains_max = y;
> -
> -  VIR_SHRINK_N(domains, ndomains_max, ndomains_max - ndomains);
> -
> -
> -  To free an array of domains:
> -
> -  virDomainPtr domains;
> -  size_t ndomains = x;
> -  size_t ndomains_max = y;
> -  size_t i;
> -
> -  for (i = 0; i < ndomains; i++)
> -  VIR_FREE(domains[i]);
> -  VIR_FREE(domains);
> -  ndomains_max = ndomains = 0;
> -
> -  
> -
> -
>  File handling
>
>  
> diff --git a/src/util/viralloc.c b/src/util/viralloc.c
> index 10a8d0fb73..b8ca850764 100644
> --- a/src/util/viralloc.c
> +++ b/src/util/viralloc.c
> @@ -45,10 +45,7 @@ VIR_LOG_INIT("util.alloc");
>  int virAlloc(void *ptrptr,
>   size_t size)
>  {
> -*(void **)ptrptr = calloc(1, size);
> -if (*(void **)ptrptr == NULL)
> -abort();
> -
> +*(void **)ptrptr = g_malloc0(size);
>  return 0;
>  }
>
> @@ -69,10 +66,7 @@ int virAllocN(void *ptrptr,
>size_t size,
>size_t count)
>  {
> -*(void**)ptrptr = calloc(count, size);
> -if (*(void**)ptrptr == NULL)
> -abort();
> -
> +*(void**)pt

[libvirt] [PATCH] libxl: Fix lock manager lock ordering

2019-10-14 Thread Jim Fehlig
The ordering of lock manager locks in the libxl driver has a flaw that was
uncovered by a migration error path. In the perform phase of migration, the
source host calls virDomainLockProcessPause to release the lock before
sending the VM to the destination host. If the send fails an attempt is made
to reacquire the lock with virDomainLockProcessResume, but that too can fail
if the destination host has not finished cleaning up the failed VM and
releasing the lock it acquired when starting to receive the VM.

This change delays calling virDomainLockProcessResume in libxlDomainStart
until the VM is successfully created, but before it is unpaused. A similar
approach is used by the qemu driver, avoiding the need to release the lock
if VM creation fails. In the migration perform phase, releasing the lock
with virDomainLockProcessPause is delayed until the VM is successfully
sent to the destination, which avoids reacquiring the lock if the send
fails.

Signed-off-by: Jim Fehlig 
---
 src/libxl/libxl_domain.c| 14 +++---
 src/libxl/libxl_migration.c | 14 +-
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 4073bf8d46..a830a19b99 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1364,13 +1364,6 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
   NULL) < 0)
 goto cleanup;
 
-if (virDomainLockProcessResume(driver->lockManager,
-  "xen:///system",
-  vm,
-  priv->lockState) < 0)
-goto cleanup;
-VIR_FREE(priv->lockState);
-
 if (libxlNetworkPrepareDevices(vm->def) < 0)
 goto cleanup_dom;
 
@@ -1453,6 +1446,13 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
 
 libxlLoggerOpenFile(cfg->logger, domid, vm->def->name, config_json);
 
+if (virDomainLockProcessResume(driver->lockManager,
+  "xen:///system",
+  vm,
+  priv->lockState) < 0)
+goto destroy_dom;
+VIR_FREE(priv->lockState);
+
 /* Always enable domain death events */
 if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW))
 goto destroy_dom;
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index a1021d499b..8e64dc5d04 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -1253,20 +1253,16 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivatePtr 
driver,
 sockfd = virNetSocketDupFD(sock, true);
 virObjectUnref(sock);
 
-if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 
0)
-VIR_WARN("Unable to release lease on %s", vm->def->name);
-VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
-
 /* suspend vm and send saved data to dst through socket fd */
 virObjectUnlock(vm);
 ret = libxlDoMigrateSrcSend(driver, vm, flags, sockfd);
 virObjectLock(vm);
 
-if (ret < 0) {
-virDomainLockProcessResume(driver->lockManager,
-   "xen:///system",
-   vm,
-   priv->lockState);
+if (ret == 0) {
+if (virDomainLockProcessPause(driver->lockManager, vm, 
&priv->lockState) < 0)
+VIR_WARN("Unable to release lease on %s", vm->def->name);
+VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
+} else {
 /*
  * Confirm phase will not be executed if perform fails. End the
  * job started in begin phase.
-- 
2.23.0


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


Re: [libvirt] Question about migration confirm phase

2019-10-14 Thread Jim Fehlig
On 10/14/19 2:18 AM, Jiri Denemark wrote:
> On Fri, Oct 11, 2019 at 23:18:29 +, Jim Fehlig wrote:
>> I've been investigating a lockd lock ordering bug in a migration error 
>> handling
>> path in the libxl driver. In the perform phase, the src calls
>> virDomainLockProcessPause to release the lock before sending the VM to dst. 
>> In
>> this case the send fails for other reasons and an attempt is made to 
>> reacquire
>> the lock with virDomainLockProcessResume. But that fails since the dst has 
>> not
>> finished cleaning up the failed VM and releasing the lock it acquired when
>> starting to receive the VM. My immediate reaction was "why not reacquire the
>> lock in the confirm phase", but then I saw my older comment a few lines 
>> later in
>> the perform phase code
>>
>>   /*
>>* Confirm phase will not be executed if perform fails. End the
>>* job started in begin phase.
>>*/
>>
>> Is that just a bug in the implementation, or is it intended to skip the 
>> confirm
>> phase if perform fails?
> 
> It's intended. The Perform phase runs on the source hosts so why should
> we call Confirm to let the source know about the failure?

To do any cleanup of the failed migration after the dst has done it's cleanup 
in 
the finish phase?

> But of course,
> the source has to cleanup after the failed migration similarly to what
> Confirm would do.

I've made slight changes to the lock ordering and it looks promising after 
initial tests. I'll post a patch after further testing. Thanks!

Regards,
Jim

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


Re: [libvirt] [PATCH 00/30] storagefile, security: qcow2 data_file support

2019-10-14 Thread Cole Robinson
On 10/12/19 11:07 AM, Han Han wrote:
> 
> 
> On Sat, Oct 12, 2019 at 1:05 AM Cole Robinson  > wrote:
> 
> On 10/10/19 11:25 PM, Han Han wrote:
> > Hi Cole,
> > I merged crobinso/qcow2-data_file branch to 37b565c00. Reserved new
> > capabilities introduced by these to branches to resolve conflicts.
> > Then build and test as following:
> > # ./autogen.sh&& ./configure --without-libssh
> > --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu
> > --program-prefix= --disable-dependency-tracking --prefix=/usr
> > --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
> > --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include
> > --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var
> > --sharedstatedir=/var/lib --mandir=/usr/share/man
> > --infodir=/usr/share/info --with-qemu --without-openvz --without-lxc
> > --without-vbox --without-libxl --with-sasl --with-polkit
> --with-libvirtd
> > --without-phyp --with-esx --without-hyperv --without-vmware
> > --without-xenapi --without-vz --without-bhyve --with-interface
> > --with-network --with-storage-fs --with-storage-lvm
> --with-storage-iscsi
> > --with-storage-iscsi-direct --with-storage-scsi --with-storage-disk
> > --with-storage-mpath --with-storage-rbd --without-storage-sheepdog
> > --with-storage-gluster --without-storage-zfs
> --without-storage-vstorage
> > --with-numactl --with-numad --with-capng --without-fuse --with-netcf
> > --with-selinux --with-selinux-mount=/sys/fs/selinux
> --without-apparmor
> > --without-hal --with-udev --with-yajl --with-sanlock --with-libpcap
> > --with-macvtap --with-audit --with-dtrace --with-driver-modules
> > --with-firewalld --with-firewalld-zone --without-wireshark-dissector
> > --without-pm-utils --with-nss-plugin '--with-packager=Unknown,
> > 2019-08-19-12:13:01, lab.rhel8.me 
> '
> > --with-packager-version=1.el8 --with-qemu-user=qemu
> > --with-qemu-group=qemu --with-tls-priority=@LIBVIRT,SYSTEM
> > --enable-werror --enable-expensive-tests --with-init-script=systemd
> > --without-login-shell && make
> >
> > Start libvirtd and virtlogd
> > # LD_PRELOAD="$(find src -name '*.so.*'|tr '\n' ' ')"
> src/.libs/libvirtd
> > # LD_PRELOAD="$(find src -name '*.so.*'|tr '\n' ' ')" ./src/virtlogd
> >
> > Then try to list all domains:
> > # virsh list --all
> >
> > Libvirtd exits with segment fault:
> > [1]    30104 segmentation fault (core dumped)  LD_PRELOAD="$(find src
> > -name '*.so.*'|tr '\n' ' ')" src/.libs/libvirtd
> >
> > Version:
> > qemu-4.1
> >
> > Backtrace:
> > (gdb) bt
> > #0  0x7fbe57a0d1b9 in virDomainVirtioSerialAddrSetAddControllers
> > (def=, def=, addrs=) at
> > conf/domain_addr.c:1656
> > #1  virDomainVirtioSerialAddrSetCreateFromDomain
> > (def=def@entry=0x7fbde81cc3f0) at conf/domain_addr.c:1753
> > #2  0x7fbe0179897e in qemuDomainAssignVirtioSerialAddresses
> > (def=0x7fbde81cc3f0) at qemu/qemu_domain_address.c:3174
> > #3  qemuDomainAssignAddresses (def=0x7fbde81cc3f0,
> > qemuCaps=0x7fbde81d2210, driver=0x7fbde8126850, obj=0x0,
> > newDomain=) at qemu/qemu_domain_address.c:3174
> > #4  0x7fbe57a39e0d in virDomainDefPostParse
> > (def=def@entry=0x7fbde81cc3f0, caps=caps@entry=0x7fbde8154d20,
> > parseFlags=parseFlags@entry=4610, xmlopt=xmlopt@entry=0x7fbde83ce070,
> >      parseOpaque=parseOpaque@entry=0x0) at conf/domain_conf.c:5858
> > #5  0x7fbe57a525c5 in virDomainDefParseNode (xml=,
> > root=0x7fbde83c5ff0, caps=0x7fbde8154d20, xmlopt=0x7fbde83ce070,
> > parseOpaque=0x0, flags=4610) at conf/domain_conf.c:21677
> > #6  0x7fbe57a526c8 in virDomainDefParse (xmlStr=xmlStr@entry=0x0,
> > filename=, caps=caps@entry=0x7fbde8154d20,
> > xmlopt=xmlopt@entry=0x7fbde83ce070, parseOpaque=parseOpaque@entry=0x0,
> >      flags=flags@entry=4610) at conf/domain_conf.c:21628
> > #7  0x7fbe57a528f6 in virDomainDefParseFile (filename= > out>, caps=caps@entry=0x7fbde8154d20,
> > xmlopt=xmlopt@entry=0x7fbde83ce070,
> parseOpaque=parseOpaque@entry=0x0,
> > flags=flags@entry=4610)
> >      at conf/domain_conf.c:21653
> > #8  0x7fbe57a5e16a in virDomainObjListLoadConfig (opaque=0x0,
> > notify=0x0, name=0x7fbde81d7ff3 "pc", autostartDir=0x7fbde8124070
> > "/etc/libvirt/qemu/autostart", configDir=0x7fbde8124050
> > "/etc/libvirt/qemu",
> >      xmlopt=0x7fbde83ce070, caps=0x7fbde8154d20,
> doms=0x7fbde8126940) at
> > conf/virdomainobjlist.c:503
> > #9  virDomainObjListLoadAllConfigs (doms=0x7fbde8126940,
> > configDir=0x7fbde8124050 "/etc/libvirt/qemu",
> > autostartDir=0x7fbde8124070 "/etc/libvirt/qemu/autostart",
> > liveStatus=liveSt

[libvirt] [PULL v2 16/19] block/qcow2-bitmap: fix and improve qcow2_reopen_bitmaps_rw

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

- Correct check for write access to file child, and in correct place
  (only if we want to write).
- Support reopen rw -> rw (which will be used in following commit),
  for example, !bdrv_dirty_bitmap_readonly() is not a corruption if
  bitmap is marked IN_USE in the image.
- Consider unexpected bitmap as a corruption and check other
  combinations of in-image and in-RAM bitmaps.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Message-id: 20190927122355.7344-9-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block/qcow2-bitmap.c | 77 +---
 1 file changed, 58 insertions(+), 19 deletions(-)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index f7dfb40256..98294a7696 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1108,18 +1108,14 @@ int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error 
**errp)
 Qcow2BitmapList *bm_list;
 Qcow2Bitmap *bm;
 GSList *ro_dirty_bitmaps = NULL;
-int ret = 0;
+int ret = -EINVAL;
+bool need_header_update = false;
 
 if (s->nb_bitmaps == 0) {
 /* No bitmaps - nothing to do */
 return 0;
 }
 
-if (!can_write(bs)) {
-error_setg(errp, "Can't write to the image on reopening bitmaps rw");
-return -EINVAL;
-}
-
 bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
s->bitmap_directory_size, errp);
 if (bm_list == NULL) {
@@ -1128,32 +1124,75 @@ int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error 
**errp)
 
 QSIMPLEQ_FOREACH(bm, bm_list, entry) {
 BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(bs, bm->name);
-if (bitmap == NULL) {
-continue;
-}
 
-if (!bdrv_dirty_bitmap_readonly(bitmap)) {
-error_setg(errp, "Bitmap %s was loaded prior to rw-reopen, but was 
"
-   "not marked as readonly. This is a bug, something went "
-   "wrong. All of the bitmaps may be corrupted", bm->name);
-ret = -EINVAL;
+if (!bitmap) {
+error_setg(errp, "Unexpected bitmap '%s' in image '%s'",
+   bm->name, bs->filename);
 goto out;
 }
 
-bm->flags |= BME_FLAG_IN_USE;
-ro_dirty_bitmaps = g_slist_append(ro_dirty_bitmaps, bitmap);
+if (!(bm->flags & BME_FLAG_IN_USE)) {
+if (!bdrv_dirty_bitmap_readonly(bitmap)) {
+error_setg(errp, "Corruption: bitmap '%s' is not marked IN_USE 
"
+   "in the image '%s' and not marked readonly in RAM",
+   bm->name, bs->filename);
+goto out;
+}
+if (bdrv_dirty_bitmap_inconsistent(bitmap)) {
+error_setg(errp, "Corruption: bitmap '%s' is inconsistent but "
+   "is not marked IN_USE in the image '%s'", bm->name,
+   bs->filename);
+goto out;
+}
+
+bm->flags |= BME_FLAG_IN_USE;
+need_header_update = true;
+} else {
+/*
+ * What if flags already has BME_FLAG_IN_USE ?
+ *
+ * 1. if we are reopening RW -> RW it's OK, of course.
+ * 2. if we are reopening RO -> RW:
+ *   2.1 if @bitmap is inconsistent, it's OK. It means that it was
+ *   inconsistent (IN_USE) when we loaded it
+ *   2.2 if @bitmap is not inconsistent. This seems to be 
impossible
+ *   and implies third party interaction. Let's error-out for
+ *   safety.
+ */
+if (bdrv_dirty_bitmap_readonly(bitmap) &&
+!bdrv_dirty_bitmap_inconsistent(bitmap))
+{
+error_setg(errp, "Corruption: bitmap '%s' is marked IN_USE "
+   "in the image '%s' but it is readonly and "
+   "consistent in RAM",
+   bm->name, bs->filename);
+goto out;
+}
+}
+
+if (bdrv_dirty_bitmap_readonly(bitmap)) {
+ro_dirty_bitmaps = g_slist_append(ro_dirty_bitmaps, bitmap);
+}
 }
 
-if (ro_dirty_bitmaps != NULL) {
+if (need_header_update) {
+if (!can_write(bs->file->bs) || !(bs->file->perm & BLK_PERM_WRITE)) {
+error_setg(errp, "Failed to reopen bitmaps rw: no write access "
+   "the protocol file");
+goto out;
+}
+
 /* in_use flags must be updated */
 ret = update_ext_header_and_dir_in_place(bs, bm_list);
 if (ret < 0) {
-error_setg_errno(errp, -ret, "Can't update bitmap directory");
+error_setg_errno(errp, -ret, "Cannot update bitmap directory");
 goto out;
 }
-g_slist_foreach(ro_dirty_bitmaps, set_readonly_helper, false);
 }
 
+g_sl

[libvirt] [PULL v2 18/19] MAINTAINERS: Add Vladimir as a reviewer for bitmaps

2019-10-14 Thread John Snow
I already try to make sure all bitmaps patches have been reviewed by both
Red Hat and Virtuozzo anyway, so this formalizes the arrangement.

Fam meanwhile is no longer as active, so I am removing him as a co-maintainer
simply to reflect the current practice.

Signed-off-by: John Snow 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
Message-id: 20191005194448.16629-2-js...@redhat.com
---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index fe4dc51b08..250ce8e7a1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1816,8 +1816,8 @@ F: qapi/transaction.json
 T: git https://repo.or.cz/qemu/armbru.git block-next
 
 Dirty Bitmaps
-M: Fam Zheng 
 M: John Snow 
+R: Vladimir Sementsov-Ogievskiy 
 L: qemu-bl...@nongnu.org
 S: Supported
 F: util/hbitmap.c
@@ -1826,7 +1826,6 @@ F: include/qemu/hbitmap.h
 F: include/block/dirty-bitmap.h
 F: tests/test-hbitmap.c
 F: docs/interop/bitmaps.rst
-T: git https://github.com/famz/qemu.git bitmaps
 T: git https://github.com/jnsnow/qemu.git bitmaps
 
 Character device backends
-- 
2.21.0

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


[libvirt] [PULL v2 09/19] block: switch reopen queue from QSIMPLEQ to QTAILQ

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

We'll need reverse-foreach in the following commit, QTAILQ support it,
so move to QTAILQ.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Max Reitz 
Message-id: 20190927122355.7344-2-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 include/block/block.h |  2 +-
 block.c   | 24 
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/block/block.h b/include/block/block.h
index 792bb826db..89606bd9f8 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -195,7 +195,7 @@ typedef struct HDGeometry {
 #define BDRV_BLOCK_EOF  0x20
 #define BDRV_BLOCK_RECURSE  0x40
 
-typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) 
BlockReopenQueue;
+typedef QTAILQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;
 
 typedef struct BDRVReopenState {
 BlockDriverState *bs;
diff --git a/block.c b/block.c
index 5721441697..0347632c6c 100644
--- a/block.c
+++ b/block.c
@@ -1719,7 +1719,7 @@ typedef struct BlockReopenQueueEntry {
  bool prepared;
  bool perms_checked;
  BDRVReopenState state;
- QSIMPLEQ_ENTRY(BlockReopenQueueEntry) entry;
+ QTAILQ_ENTRY(BlockReopenQueueEntry) entry;
 } BlockReopenQueueEntry;
 
 /*
@@ -1732,7 +1732,7 @@ static int bdrv_reopen_get_flags(BlockReopenQueue *q, 
BlockDriverState *bs)
 BlockReopenQueueEntry *entry;
 
 if (q != NULL) {
-QSIMPLEQ_FOREACH(entry, q, entry) {
+QTAILQ_FOREACH(entry, q, entry) {
 if (entry->state.bs == bs) {
 return entry->state.flags;
 }
@@ -3249,7 +3249,7 @@ static bool bdrv_recurse_has_child(BlockDriverState *bs,
  * Adds a BlockDriverState to a simple queue for an atomic, transactional
  * reopen of multiple devices.
  *
- * bs_queue can either be an existing BlockReopenQueue that has had 
QSIMPLE_INIT
+ * bs_queue can either be an existing BlockReopenQueue that has had QTAILQ_INIT
  * already performed, or alternatively may be NULL a new BlockReopenQueue will
  * be created and initialized. This newly created BlockReopenQueue should be
  * passed back in for subsequent calls that are intended to be of the same
@@ -3290,7 +3290,7 @@ static BlockReopenQueue 
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
 
 if (bs_queue == NULL) {
 bs_queue = g_new0(BlockReopenQueue, 1);
-QSIMPLEQ_INIT(bs_queue);
+QTAILQ_INIT(bs_queue);
 }
 
 if (!options) {
@@ -3298,7 +3298,7 @@ static BlockReopenQueue 
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
 }
 
 /* Check if this BlockDriverState is already in the queue */
-QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) {
+QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
 if (bs == bs_entry->state.bs) {
 break;
 }
@@ -3354,7 +3354,7 @@ static BlockReopenQueue 
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
 
 if (!bs_entry) {
 bs_entry = g_new0(BlockReopenQueueEntry, 1);
-QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);
+QTAILQ_INSERT_TAIL(bs_queue, bs_entry, entry);
 } else {
 qobject_unref(bs_entry->state.options);
 qobject_unref(bs_entry->state.explicit_options);
@@ -3455,7 +3455,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, 
Error **errp)
 
 assert(bs_queue != NULL);
 
-QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) {
+QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
 assert(bs_entry->state.bs->quiesce_counter > 0);
 if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, errp)) {
 goto cleanup;
@@ -3463,7 +3463,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, 
Error **errp)
 bs_entry->prepared = true;
 }
 
-QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) {
+QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
 BDRVReopenState *state = &bs_entry->state;
 ret = bdrv_check_perm(state->bs, bs_queue, state->perm,
   state->shared_perm, NULL, NULL, errp);
@@ -3489,13 +3489,13 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, 
Error **errp)
 /* If we reach this point, we have success and just need to apply the
  * changes
  */
-QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) {
+QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
 bdrv_reopen_commit(&bs_entry->state);
 }
 
 ret = 0;
 cleanup_perm:
-QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
+QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
 BDRVReopenState *state = &bs_entry->state;
 
 if (!bs_entry->perms_checked) {
@@ -3512,7 +3512,7 @@ cleanup_perm:
 }
 }
 cleanup:
-QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
+QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
 if (ret) {
 if (bs_entry->prepared) {
 bdrv_reopen_abort(&bs_entry->state);
@@ -3552,7 +3552,7 @@ static BlockReopenQue

[libvirt] [PULL v2 06/19] block/dirty-bitmap: add bs link

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

Add bs field to BdrvDirtyBitmap structure. Drop BlockDriverState
parameter from bitmap APIs where possible.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190916141911.5255-3-vsement...@virtuozzo.com
[Rebased on top of block-copy. --js]
Signed-off-by: John Snow 
---
 include/block/dirty-bitmap.h   | 14 +-
 block/backup.c |  8 
 block/block-copy.c |  2 +-
 block/dirty-bitmap.c   | 24 
 block/mirror.c |  4 ++--
 block/qcow2-bitmap.c   |  6 +++---
 blockdev.c |  6 +++---
 migration/block-dirty-bitmap.c |  7 +++
 migration/block.c  |  4 ++--
 9 files changed, 35 insertions(+), 40 deletions(-)

diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 973056778a..2f9b088e11 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -18,21 +18,18 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState 
*bs,
   uint32_t granularity,
   const char *name,
   Error **errp);
-int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
-   BdrvDirtyBitmap *bitmap,
+int bdrv_dirty_bitmap_create_successor(BdrvDirtyBitmap *bitmap,
Error **errp);
-BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,
-BdrvDirtyBitmap *bitmap,
+BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BdrvDirtyBitmap *bitmap,
 Error **errp);
-BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,
-   BdrvDirtyBitmap *bitmap,
+BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BdrvDirtyBitmap *bitmap,
Error **errp);
 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap);
 BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
 const char *name);
 int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitmap, uint32_t flags,
 Error **errp);
-void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
+void bdrv_release_dirty_bitmap(BdrvDirtyBitmap *bitmap);
 void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
 int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
 Error **errp);
@@ -106,8 +103,7 @@ int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap 
*bitmap, uint64_t offset,
 uint64_t bytes);
 bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap,
uint64_t *offset, uint64_t *bytes);
-BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BlockDriverState *bs,
-  BdrvDirtyBitmap *bitmap,
+BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
   Error **errp);
 
 #endif
diff --git a/block/backup.c b/block/backup.c
index 46978c1785..dddcf77f53 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -98,13 +98,13 @@ static void backup_cleanup_sync_bitmap(BackupBlockJob *job, 
int ret)
  * We succeeded, or we always intended to sync the bitmap.
  * Delete this bitmap and install the child.
  */
-bm = bdrv_dirty_bitmap_abdicate(job->source_bs, job->sync_bitmap, 
NULL);
+bm = bdrv_dirty_bitmap_abdicate(job->sync_bitmap, NULL);
 } else {
 /*
  * We failed, or we never intended to sync the bitmap anyway.
  * Merge the successor back into the parent, keeping all data.
  */
-bm = bdrv_reclaim_dirty_bitmap(job->source_bs, job->sync_bitmap, NULL);
+bm = bdrv_reclaim_dirty_bitmap(job->sync_bitmap, NULL);
 }
 
 assert(bm);
@@ -402,7 +402,7 @@ BlockJob *backup_job_create(const char *job_id, 
BlockDriverState *bs,
 }
 
 /* Create a new bitmap, and freeze/disable this one. */
-if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap, errp) < 0) {
+if (bdrv_dirty_bitmap_create_successor(sync_bitmap, errp) < 0) {
 return NULL;
 }
 }
@@ -472,7 +472,7 @@ BlockJob *backup_job_create(const char *job_id, 
BlockDriverState *bs,
 
  error:
 if (sync_bitmap) {
-bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL);
+bdrv_reclaim_dirty_bitmap(sync_bitmap, NULL);
 }
 if (job) {
 backup_clean(&job->common.job);
diff --git a/block/block-copy.c b/block/block-copy.c
index 0f76ea1e63..066e3a7274 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -60,7 +60,7 @@ void block_copy_state_free(BlockCopyState *s

[libvirt] [PULL v2 11/19] iotests: add test-case to 165 to test reopening qcow2 bitmaps to RW

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

Reopening bitmaps to RW was broken prior to previous commit. Check that
it works now.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Message-id: 20190927122355.7344-4-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 tests/qemu-iotests/165 | 57 --
 tests/qemu-iotests/165.out |  4 +--
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
index 5650dc7c87..951ea011a2 100755
--- a/tests/qemu-iotests/165
+++ b/tests/qemu-iotests/165
@@ -43,10 +43,10 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
 os.remove(disk)
 
 def mkVm(self):
-return iotests.VM().add_drive(disk)
+return iotests.VM().add_drive(disk, opts='node-name=node0')
 
 def mkVmRo(self):
-return iotests.VM().add_drive(disk, opts='readonly=on')
+return iotests.VM().add_drive(disk, opts='readonly=on,node-name=node0')
 
 def getSha256(self):
 result = self.vm.qmp('x-debug-block-dirty-bitmap-sha256',
@@ -102,6 +102,59 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
 
 self.vm.shutdown()
 
+def test_reopen_rw(self):
+self.vm = self.mkVm()
+self.vm.launch()
+self.qmpAddBitmap()
+
+# Calculate hashes
+
+self.writeRegions(regions1)
+sha256_1 = self.getSha256()
+
+self.writeRegions(regions2)
+sha256_2 = self.getSha256()
+assert sha256_1 != sha256_2 # Otherwise, it's not very interesting.
+
+result = self.vm.qmp('block-dirty-bitmap-clear', node='drive0',
+ name='bitmap0')
+self.assert_qmp(result, 'return', {})
+
+# Start with regions1
+
+self.writeRegions(regions1)
+assert sha256_1 == self.getSha256()
+
+self.vm.shutdown()
+
+self.vm = self.mkVmRo()
+self.vm.launch()
+
+assert sha256_1 == self.getSha256()
+
+# Check that we are in RO mode and can't modify bitmap.
+self.writeRegions(regions2)
+assert sha256_1 == self.getSha256()
+
+# Reopen to RW
+result = self.vm.qmp('x-blockdev-reopen', **{
+'node-name': 'node0',
+'driver': iotests.imgfmt,
+'file': {
+'driver': 'file',
+'filename': disk
+},
+'read-only': False
+})
+self.assert_qmp(result, 'return', {})
+
+# Check that bitmap is reopened to RW and we can write to it.
+self.writeRegions(regions2)
+assert sha256_2 == self.getSha256()
+
+self.vm.shutdown()
+
+
 if __name__ == '__main__':
 iotests.main(supported_fmts=['qcow2'],
  supported_protocols=['file'])
diff --git a/tests/qemu-iotests/165.out b/tests/qemu-iotests/165.out
index ae1213e6f8..fbc63e62f8 100644
--- a/tests/qemu-iotests/165.out
+++ b/tests/qemu-iotests/165.out
@@ -1,5 +1,5 @@
-.
+..
 --
-Ran 1 tests
+Ran 2 tests
 
 OK
-- 
2.21.0

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


[libvirt] [PULL v2 04/19] block/qcow2: proper locking on bitmap add/remove paths

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

qmp_block_dirty_bitmap_add and do_block_dirty_bitmap_remove do acquire
aio context since 0a6c86d024c52b. But this is not enough: we also must
lock qcow2 mutex when access in-image metadata. Especially it concerns
freeing qcow2 clusters.

To achieve this, move qcow2_can_store_new_dirty_bitmap and
qcow2_remove_persistent_dirty_bitmap to coroutine context.

Since we work in coroutines in correct aio context, we don't need
context acquiring in blockdev.c anymore, drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190920082543.23444-4-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block/qcow2.h |  11 ++--
 include/block/block_int.h |  10 ++--
 block/dirty-bitmap.c  | 102 +++---
 block/qcow2-bitmap.c  |  24 ++---
 block/qcow2.c |   5 +-
 blockdev.c|  27 +++---
 6 files changed, 131 insertions(+), 48 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 08b4c15dc4..0f3d9b088e 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -746,12 +746,13 @@ int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error 
**errp);
 int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp);
 void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
 int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
-bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs,
-  const char *name,
-  uint32_t granularity,
-  Error **errp);
-int qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char 
*name,
+bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
+ const char *name,
+ uint32_t granularity,
  Error **errp);
+int qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
+const char *name,
+Error **errp);
 
 ssize_t coroutine_fn
 qcow2_co_compress(BlockDriverState *bs, void *dest, size_t dest_size,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 6b511dd889..32fb493cbb 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -553,13 +553,13 @@ struct BlockDriver {
  * field of BlockDirtyBitmap's in case of success.
  */
 int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp);
-bool (*bdrv_can_store_new_dirty_bitmap)(BlockDriverState *bs,
-const char *name,
-uint32_t granularity,
-Error **errp);
-int (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
+bool (*bdrv_co_can_store_new_dirty_bitmap)(BlockDriverState *bs,
const char *name,
+   uint32_t granularity,
Error **errp);
+int (*bdrv_co_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
+  const char *name,
+  Error **errp);
 
 /**
  * Register/unregister a buffer for I/O. For example, when the driver is
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index d1ae2e1922..03e0872b97 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -26,6 +26,7 @@
 #include "trace.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "qemu/main-loop.h"
 
 struct BdrvDirtyBitmap {
 QemuMutex *mutex;
@@ -455,18 +456,59 @@ void bdrv_release_named_dirty_bitmaps(BlockDriverState 
*bs)
  * not fail.
  * This function doesn't release corresponding BdrvDirtyBitmap.
  */
+static int coroutine_fn
+bdrv_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
+   Error **errp)
+{
+if (bs->drv && bs->drv->bdrv_co_remove_persistent_dirty_bitmap) {
+return bs->drv->bdrv_co_remove_persistent_dirty_bitmap(bs, name, errp);
+}
+
+return 0;
+}
+
+typedef struct BdrvRemovePersistentDirtyBitmapCo {
+BlockDriverState *bs;
+const char *name;
+Error **errp;
+int ret;
+} BdrvRemovePersistentDirtyBitmapCo;
+
+static void coroutine_fn
+bdrv_co_remove_persistent_dirty_bitmap_entry(void *opaque)
+{
+BdrvRemovePersistentDirtyBitmapCo *s = opaque;
+
+s->ret = bdrv_co_remove_persistent_dirty_bitmap(s->bs, s->name, s->errp);
+aio_wait_kick();
+}
+
 int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
 Error **errp)
 {
-if (bs->drv && bs->drv->bdrv_remove_persistent_dirty_bitmap) {
-return bs->drv->bdrv

[libvirt] [PULL v2 05/19] block/dirty-bitmap: drop meta

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

Drop meta bitmaps, as they are unused.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190916141911.5255-2-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 include/block/dirty-bitmap.h |  5 
 block/dirty-bitmap.c | 46 
 2 files changed, 51 deletions(-)

diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 07503b03b5..973056778a 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -18,9 +18,6 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState 
*bs,
   uint32_t granularity,
   const char *name,
   Error **errp);
-void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap,
-   int chunk_size);
-void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap);
 int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap,
Error **errp);
@@ -54,7 +51,6 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
int64_t offset, int64_t bytes);
 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
  int64_t offset, int64_t bytes);
-BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new(BdrvDirtyBitmap *bitmap);
 BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap);
 void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter);
 
@@ -96,7 +92,6 @@ void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
 int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter);
 void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t offset);
 int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);
-int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);
 void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes);
 bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);
 bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 03e0872b97..4ecf18d5df 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -31,7 +31,6 @@
 struct BdrvDirtyBitmap {
 QemuMutex *mutex;
 HBitmap *bitmap;/* Dirty bitmap implementation */
-HBitmap *meta;  /* Meta dirty bitmap */
 bool busy;  /* Bitmap is busy, it can't be used via QMP */
 BdrvDirtyBitmap *successor; /* Anonymous child, if any. */
 char *name; /* Optional non-empty unique ID */
@@ -127,36 +126,6 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState 
*bs,
 return bitmap;
 }
 
-/* bdrv_create_meta_dirty_bitmap
- *
- * Create a meta dirty bitmap that tracks the changes of bits in @bitmap. I.e.
- * when a dirty status bit in @bitmap is changed (either from reset to set or
- * the other way around), its respective meta dirty bitmap bit will be marked
- * dirty as well.
- *
- * @bitmap: the block dirty bitmap for which to create a meta dirty bitmap.
- * @chunk_size: how many bytes of bitmap data does each bit in the meta bitmap
- * track.
- */
-void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap,
-   int chunk_size)
-{
-assert(!bitmap->meta);
-qemu_mutex_lock(bitmap->mutex);
-bitmap->meta = hbitmap_create_meta(bitmap->bitmap,
-   chunk_size * BITS_PER_BYTE);
-qemu_mutex_unlock(bitmap->mutex);
-}
-
-void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap)
-{
-assert(bitmap->meta);
-qemu_mutex_lock(bitmap->mutex);
-hbitmap_free_meta(bitmap->bitmap);
-bitmap->meta = NULL;
-qemu_mutex_unlock(bitmap->mutex);
-}
-
 int64_t bdrv_dirty_bitmap_size(const BdrvDirtyBitmap *bitmap)
 {
 return bitmap->size;
@@ -320,7 +289,6 @@ static void 
bdrv_release_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap)
 assert(!bitmap->active_iterators);
 assert(!bdrv_dirty_bitmap_busy(bitmap));
 assert(!bdrv_dirty_bitmap_has_successor(bitmap));
-assert(!bitmap->meta);
 QLIST_REMOVE(bitmap, list);
 hbitmap_free(bitmap->bitmap);
 g_free(bitmap->name);
@@ -666,15 +634,6 @@ BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap 
*bitmap)
 return iter;
 }
 
-BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new(BdrvDirtyBitmap *bitmap)
-{
-BdrvDirtyBitmapIter *iter = g_new(BdrvDirtyBitmapIter, 1);
-hbitmap_iter_init(&iter->hbi, bitmap->meta, 0);
-iter->bitmap = bitmap;
-bitmap->active_iterators++;
-return iter;
-}
-
 void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter)
 {
 if (!iter) {
@@ -821,11 +780,6 @@ int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap)
 return hbitmap_count(bitmap->bitmap);
 }
 
-int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap)
-{
-return hbitmap_count(bitmap->me

[libvirt] [PULL v2 17/19] qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_commit

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

The only reason I can imagine for this strange code at the very-end of
bdrv_reopen_commit is the fact that bs->read_only updated after
calling drv->bdrv_reopen_commit in bdrv_reopen_commit. And in the same
time, prior to previous commit, qcow2_reopen_bitmaps_rw did a wrong
check for being writable, when actually it only need writable file
child not self.

So, as it's fixed, let's move things to correct place.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Acked-by: Max Reitz 
Message-id: 20190927122355.7344-10-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 include/block/block_int.h |  6 --
 block.c   | 19 ---
 block/qcow2.c | 15 ++-
 3 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/include/block/block_int.h b/include/block/block_int.h
index 32fb493cbb..ca4ccac4c1 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -547,12 +547,6 @@ struct BlockDriver {
  uint64_t parent_perm, uint64_t parent_shared,
  uint64_t *nperm, uint64_t *nshared);
 
-/**
- * Bitmaps should be marked as 'IN_USE' in the image on reopening image
- * as rw. This handler should realize it. It also should unset readonly
- * field of BlockDirtyBitmap's in case of success.
- */
-int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp);
 bool (*bdrv_co_can_store_new_dirty_bitmap)(BlockDriverState *bs,
const char *name,
uint32_t granularity,
diff --git a/block.c b/block.c
index cf312258a9..dad5a3d8e0 100644
--- a/block.c
+++ b/block.c
@@ -3935,16 +3935,12 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
 BlockDriver *drv;
 BlockDriverState *bs;
 BdrvChild *child;
-bool old_can_write, new_can_write;
 
 assert(reopen_state != NULL);
 bs = reopen_state->bs;
 drv = bs->drv;
 assert(drv != NULL);
 
-old_can_write =
-!bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
-
 /* If there are any driver level actions to take */
 if (drv->bdrv_reopen_commit) {
 drv->bdrv_reopen_commit(reopen_state);
@@ -3988,21 +3984,6 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
 }
 
 bdrv_refresh_limits(bs, NULL);
-
-new_can_write =
-!bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
-if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) {
-Error *local_err = NULL;
-if (drv->bdrv_reopen_bitmaps_rw(bs, &local_err) < 0) {
-/* This is not fatal, bitmaps just left read-only, so all following
- * writes will fail. User can remove read-only bitmaps to unblock
- * writes.
- */
-error_reportf_err(local_err,
-  "%s: Failed to make dirty bitmaps writable: ",
-  bdrv_get_node_name(bs));
-}
-}
 }
 
 /*
diff --git a/block/qcow2.c b/block/qcow2.c
index 53a025703e..8b05933565 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1835,6 +1835,20 @@ fail:
 static void qcow2_reopen_commit(BDRVReopenState *state)
 {
 qcow2_update_options_commit(state->bs, state->opaque);
+if (state->flags & BDRV_O_RDWR) {
+Error *local_err = NULL;
+
+if (qcow2_reopen_bitmaps_rw(state->bs, &local_err) < 0) {
+/*
+ * This is not fatal, bitmaps just left read-only, so all following
+ * writes will fail. User can remove read-only bitmaps to unblock
+ * writes or retry reopen.
+ */
+error_reportf_err(local_err,
+  "%s: Failed to make dirty bitmaps writable: ",
+  bdrv_get_node_name(state->bs));
+}
+}
 g_free(state->opaque);
 }
 
@@ -5406,7 +5420,6 @@ BlockDriver bdrv_qcow2 = {
 .bdrv_detach_aio_context  = qcow2_detach_aio_context,
 .bdrv_attach_aio_context  = qcow2_attach_aio_context,
 
-.bdrv_reopen_bitmaps_rw = qcow2_reopen_bitmaps_rw,
 .bdrv_co_can_store_new_dirty_bitmap = qcow2_co_can_store_new_dirty_bitmap,
 .bdrv_co_remove_persistent_dirty_bitmap =
 qcow2_co_remove_persistent_dirty_bitmap,
-- 
2.21.0

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


[libvirt] [PULL v2 15/19] iotests: add test 260 to check bitmap life after snapshot + commit

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Message-id: 20190927122355.7344-8-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 tests/qemu-iotests/260 | 89 ++
 tests/qemu-iotests/260.out | 52 ++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 142 insertions(+)
 create mode 100755 tests/qemu-iotests/260
 create mode 100644 tests/qemu-iotests/260.out

diff --git a/tests/qemu-iotests/260 b/tests/qemu-iotests/260
new file mode 100755
index 00..4f6082c9d2
--- /dev/null
+++ b/tests/qemu-iotests/260
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# Tests for temporary external snapshot when we have bitmaps.
+#
+# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+
+import iotests
+from iotests import qemu_img_create, file_path, log, filter_qmp_event
+
+iotests.verify_image_format(supported_fmts=['qcow2'])
+
+base, top = file_path('base', 'top')
+size = 64 * 1024 * 3
+
+
+def print_bitmap(msg, vm):
+result = vm.qmp('query-block')['return'][0]
+if 'dirty-bitmaps' in result:
+bitmap = result['dirty-bitmaps'][0]
+log('{}: name={} dirty-clusters={}'.format(msg, bitmap['name'],
+bitmap['count'] // 64 // 1024))
+else:
+log(msg + ': not found')
+
+
+def test(persistent, restart):
+assert persistent or not restart
+log("\nTestcase {}persistent {} restart\n".format(
+'' if persistent else 'non-', 'with' if restart else 'without'))
+
+qemu_img_create('-f', iotests.imgfmt, base, str(size))
+
+vm = iotests.VM().add_drive(base)
+vm.launch()
+
+vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap0',
+   persistent=persistent)
+vm.hmp_qemu_io('drive0', 'write 0 64K')
+print_bitmap('initial bitmap', vm)
+
+vm.qmp_log('blockdev-snapshot-sync', device='drive0', snapshot_file=top,
+   format=iotests.imgfmt, filters=[iotests.filter_qmp_testfiles])
+vm.hmp_qemu_io('drive0', 'write 64K 512')
+print_bitmap('check that no bitmaps are in snapshot', vm)
+
+if restart:
+log("... Restart ...")
+vm.shutdown()
+vm = iotests.VM().add_drive(top)
+vm.launch()
+
+vm.qmp_log('block-commit', device='drive0', top=top,
+   filters=[iotests.filter_qmp_testfiles])
+ev = vm.events_wait((('BLOCK_JOB_READY', None),
+ ('BLOCK_JOB_COMPLETED', None)))
+log(filter_qmp_event(ev))
+if (ev['event'] == 'BLOCK_JOB_COMPLETED'):
+vm.shutdown()
+log(vm.get_log())
+exit()
+
+vm.qmp_log('block-job-complete', device='drive0')
+ev = vm.event_wait('BLOCK_JOB_COMPLETED')
+log(filter_qmp_event(ev))
+print_bitmap('check bitmap after commit', vm)
+
+vm.hmp_qemu_io('drive0', 'write 128K 64K')
+print_bitmap('check updated bitmap', vm)
+
+vm.shutdown()
+
+
+test(persistent=False, restart=False)
+test(persistent=True, restart=False)
+test(persistent=True, restart=True)
diff --git a/tests/qemu-iotests/260.out b/tests/qemu-iotests/260.out
new file mode 100644
index 00..2f0d98d036
--- /dev/null
+++ b/tests/qemu-iotests/260.out
@@ -0,0 +1,52 @@
+
+Testcase non-persistent without restart
+
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "bitmap0", "node": 
"drive0", "persistent": false}}
+{"return": {}}
+initial bitmap: name=bitmap0 dirty-clusters=1
+{"execute": "blockdev-snapshot-sync", "arguments": {"device": "drive0", 
"format": "qcow2", "snapshot-file": "TEST_DIR/PID-top"}}
+{"return": {}}
+check that no bitmaps are in snapshot: not found
+{"execute": "block-commit", "arguments": {"device": "drive0", "top": 
"TEST_DIR/PID-top"}}
+{"return": {}}
+{"data": {"device": "drive0", "len": 65536, "offset": 65536, "speed": 0, 
"type": "commit"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds": 
"USECS", "seconds": "SECS"}}
+{"execute": "block-job-complete", "arguments": {"device": "drive0"}}
+{"return": {}}
+{"data": {"device": "drive0", "len": 65536, "offset": 65536, "speed": 0, 
"type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": 
{"microseconds": "USECS", "seconds": "SECS"}}
+check bitmap after commit: name=bitmap0 dirty-clusters=2
+check updated bitmap: name=bitmap0 dirty-clusters=3
+
+Testcase persis

[libvirt] [PULL v2 13/19] block/qcow2-bitmap: drop qcow2_reopen_bitmaps_rw_hint()

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

The function is unused, drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190927122355.7344-6-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block/qcow2.h|  2 --
 block/qcow2-bitmap.c | 15 +--
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 0f3d9b088e..23a9898a54 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -740,8 +740,6 @@ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, 
BdrvCheckResult *res,
 bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp);
 Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
 Error **errp);
-int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, bool *header_updated,
- Error **errp);
 int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
 int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp);
 void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 6dfc083548..ebc1afccd3 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1102,8 +1102,7 @@ Qcow2BitmapInfoList 
*qcow2_get_bitmap_info_list(BlockDriverState *bs,
 return list;
 }
 
-int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, bool *header_updated,
- Error **errp)
+int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp)
 {
 BDRVQcow2State *s = bs->opaque;
 Qcow2BitmapList *bm_list;
@@ -,10 +1110,6 @@ int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, 
bool *header_updated,
 GSList *ro_dirty_bitmaps = NULL;
 int ret = 0;
 
-if (header_updated != NULL) {
-*header_updated = false;
-}
-
 if (s->nb_bitmaps == 0) {
 /* No bitmaps - nothing to do */
 return 0;
@@ -1156,9 +1151,6 @@ int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, 
bool *header_updated,
 error_setg_errno(errp, -ret, "Can't update bitmap directory");
 goto out;
 }
-if (header_updated != NULL) {
-*header_updated = true;
-}
 g_slist_foreach(ro_dirty_bitmaps, set_readonly_helper, false);
 }
 
@@ -1169,11 +1161,6 @@ out:
 return ret;
 }
 
-int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp)
-{
-return qcow2_reopen_bitmaps_rw_hint(bs, NULL, errp);
-}
-
 /* Checks to see if it's safe to resize bitmaps */
 int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp)
 {
-- 
2.21.0

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


[libvirt] [PULL v2 03/19] block/dirty-bitmap: return int from bdrv_remove_persistent_dirty_bitmap

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

It's more comfortable to not deal with local_err.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190920082543.23444-3-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block/qcow2.h|  5 ++---
 include/block/block_int.h|  6 +++---
 include/block/dirty-bitmap.h |  5 ++---
 block/dirty-bitmap.c |  9 +
 block/qcow2-bitmap.c | 18 ++
 blockdev.c   |  7 +++
 6 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index f51f478e34..08b4c15dc4 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -750,9 +750,8 @@ bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs,
   const char *name,
   uint32_t granularity,
   Error **errp);
-void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
-  const char *name,
-  Error **errp);
+int qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char 
*name,
+ Error **errp);
 
 ssize_t coroutine_fn
 qcow2_co_compress(BlockDriverState *bs, void *dest, size_t dest_size,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 05056b308a..6b511dd889 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -557,9 +557,9 @@ struct BlockDriver {
 const char *name,
 uint32_t granularity,
 Error **errp);
-void (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
-const char *name,
-Error **errp);
+int (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
+   const char *name,
+   Error **errp);
 
 /**
  * Register/unregister a buffer for I/O. For example, when the driver is
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 4b4b731b46..07503b03b5 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -37,9 +37,8 @@ int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitmap, 
uint32_t flags,
 Error **errp);
 void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
 void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
-void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
- const char *name,
- Error **errp);
+int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
+Error **errp);
 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
 void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap);
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 8f42015db9..d1ae2e1922 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -455,13 +455,14 @@ void bdrv_release_named_dirty_bitmaps(BlockDriverState 
*bs)
  * not fail.
  * This function doesn't release corresponding BdrvDirtyBitmap.
  */
-void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
- const char *name,
- Error **errp)
+int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
+Error **errp)
 {
 if (bs->drv && bs->drv->bdrv_remove_persistent_dirty_bitmap) {
-bs->drv->bdrv_remove_persistent_dirty_bitmap(bs, name, errp);
+return bs->drv->bdrv_remove_persistent_dirty_bitmap(bs, name, errp);
 }
+
+return 0;
 }
 
 bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index b2487101ed..9821c1628f 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1404,9 +1404,8 @@ static Qcow2Bitmap *find_bitmap_by_name(Qcow2BitmapList 
*bm_list,
 return NULL;
 }
 
-void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
-  const char *name,
-  Error **errp)
+int qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char 
*name,
+ Error **errp)
 {
 int ret;
 BDRVQcow2State *s = bs->opaque;
@@ -1416,18 +1415,19 @@ void 
qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
 if (s->nb_bitmaps == 0) {
 /* Absence of the bitmap is not an error: see explanation above
  * bd

[libvirt] [PULL v2 10/19] block: reverse order for reopen commits

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

It's needed to fix reopening qcow2 with bitmaps to RW. Currently it
can't work, as qcow2 needs write access to file child, to mark bitmaps
in-image with IN_USE flag. But usually children goes after parents in
reopen queue and file child is still RO on qcow2 reopen commit. Reverse
reopen order to fix it.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Acked-by: Max Reitz 
Acked-by: John Snow 
Message-id: 20190927122355.7344-3-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 0347632c6c..cf312258a9 100644
--- a/block.c
+++ b/block.c
@@ -3486,10 +3486,16 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, 
Error **errp)
 bs_entry->perms_checked = true;
 }
 
-/* If we reach this point, we have success and just need to apply the
- * changes
+/*
+ * If we reach this point, we have success and just need to apply the
+ * changes.
+ *
+ * Reverse order is used to comfort qcow2 driver: on commit it need to 
write
+ * IN_USE flag to the image, to mark bitmaps in the image as invalid. But
+ * children are usually goes after parents in reopen-queue, so go from last
+ * to first element.
  */
-QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
+QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) {
 bdrv_reopen_commit(&bs_entry->state);
 }
 
-- 
2.21.0

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


[libvirt] [PULL v2 02/19] block: move bdrv_can_store_new_dirty_bitmap to block/dirty-bitmap.c

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

block/dirty-bitmap.c seems to be more appropriate for it and
bdrv_remove_persistent_dirty_bitmap already in it.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190920082543.23444-2-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block.c  | 22 --
 block/dirty-bitmap.c | 22 ++
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/block.c b/block.c
index 1946fc6f57..d19a4781a3 100644
--- a/block.c
+++ b/block.c
@@ -6582,25 +6582,3 @@ void bdrv_del_child(BlockDriverState *parent_bs, 
BdrvChild *child, Error **errp)
 
 parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
 }
-
-bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
- uint32_t granularity, Error **errp)
-{
-BlockDriver *drv = bs->drv;
-
-if (!drv) {
-error_setg_errno(errp, ENOMEDIUM,
- "Can't store persistent bitmaps to %s",
- bdrv_get_device_or_node_name(bs));
-return false;
-}
-
-if (!drv->bdrv_can_store_new_dirty_bitmap) {
-error_setg_errno(errp, ENOTSUP,
- "Can't store persistent bitmaps to %s",
- bdrv_get_device_or_node_name(bs));
-return false;
-}
-
-return drv->bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp);
-}
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 134e0c9a0c..8f42015db9 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -464,6 +464,28 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState 
*bs,
 }
 }
 
+bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
+ uint32_t granularity, Error **errp)
+{
+BlockDriver *drv = bs->drv;
+
+if (!drv) {
+error_setg_errno(errp, ENOMEDIUM,
+ "Can't store persistent bitmaps to %s",
+ bdrv_get_device_or_node_name(bs));
+return false;
+}
+
+if (!drv->bdrv_can_store_new_dirty_bitmap) {
+error_setg_errno(errp, ENOTSUP,
+ "Can't store persistent bitmaps to %s",
+ bdrv_get_device_or_node_name(bs));
+return false;
+}
+
+return drv->bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp);
+}
+
 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
 {
 bdrv_dirty_bitmap_lock(bitmap);
-- 
2.21.0

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


[libvirt] [PULL v2 07/19] block/dirty-bitmap: drop BdrvDirtyBitmap.mutex

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

mutex field is just a pointer to bs->dirty_bitmap_mutex, so no needs
to store it in BdrvDirtyBitmap when we have bs pointer in it (since
previous patch).

Drop mutex field. Constantly use bdrv_dirty_bitmaps_lock/unlock in
block/dirty-bitmap.c to make it more obvious that it's not per-bitmap
lock. Still, for simplicity, leave bdrv_dirty_bitmap_lock/unlock
functions as an external API.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190916141911.5255-4-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block/dirty-bitmap.c | 84 +---
 1 file changed, 41 insertions(+), 43 deletions(-)

diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 44453ff824..4e5c87a907 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -29,7 +29,6 @@
 #include "qemu/main-loop.h"
 
 struct BdrvDirtyBitmap {
-QemuMutex *mutex;
 BlockDriverState *bs;
 HBitmap *bitmap;/* Dirty bitmap implementation */
 bool busy;  /* Bitmap is busy, it can't be used via QMP */
@@ -72,12 +71,12 @@ static inline void 
bdrv_dirty_bitmaps_unlock(BlockDriverState *bs)
 
 void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap)
 {
-qemu_mutex_lock(bitmap->mutex);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 }
 
 void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap)
 {
-qemu_mutex_unlock(bitmap->mutex);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 }
 
 /* Called with BQL or dirty_bitmap lock taken.  */
@@ -117,7 +116,6 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState 
*bs,
 }
 bitmap = g_new0(BdrvDirtyBitmap, 1);
 bitmap->bs = bs;
-bitmap->mutex = &bs->dirty_bitmap_mutex;
 bitmap->bitmap = hbitmap_alloc(bitmap_size, ctz32(granularity));
 bitmap->size = bitmap_size;
 bitmap->name = g_strdup(name);
@@ -151,9 +149,9 @@ static bool bdrv_dirty_bitmap_busy(const BdrvDirtyBitmap 
*bitmap)
 
 void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy)
 {
-qemu_mutex_lock(bitmap->mutex);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 bitmap->busy = busy;
-qemu_mutex_unlock(bitmap->mutex);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 }
 
 /* Called with BQL taken.  */
@@ -278,10 +276,10 @@ void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap 
*bitmap)
 /* Called with BQL taken. */
 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap)
 {
-assert(bitmap->mutex == bitmap->successor->mutex);
-qemu_mutex_lock(bitmap->mutex);
+assert(bitmap->bs == bitmap->successor->bs);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 bdrv_enable_dirty_bitmap_locked(bitmap->successor);
-qemu_mutex_unlock(bitmap->mutex);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 }
 
 /* Called within bdrv_dirty_bitmap_lock..unlock and with BQL taken.  */
@@ -361,9 +359,9 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BdrvDirtyBitmap 
*parent,
 {
 BdrvDirtyBitmap *ret;
 
-qemu_mutex_lock(parent->mutex);
+bdrv_dirty_bitmaps_lock(parent->bs);
 ret = bdrv_reclaim_dirty_bitmap_locked(parent, errp);
-qemu_mutex_unlock(parent->mutex);
+bdrv_dirty_bitmaps_unlock(parent->bs);
 
 return ret;
 }
@@ -543,16 +541,16 @@ bool bdrv_can_store_new_dirty_bitmap(BlockDriverState 
*bs, const char *name,
 
 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
 {
-bdrv_dirty_bitmap_lock(bitmap);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 bitmap->disabled = true;
-bdrv_dirty_bitmap_unlock(bitmap);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 }
 
 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
 {
-bdrv_dirty_bitmap_lock(bitmap);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 bdrv_enable_dirty_bitmap_locked(bitmap);
-bdrv_dirty_bitmap_unlock(bitmap);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 }
 
 BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
@@ -593,9 +591,9 @@ bool bdrv_dirty_bitmap_get_locked(BdrvDirtyBitmap *bitmap, 
int64_t offset)
 bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap *bitmap, int64_t offset)
 {
 bool ret;
-bdrv_dirty_bitmap_lock(bitmap);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 ret = bdrv_dirty_bitmap_get_locked(bitmap, offset);
-bdrv_dirty_bitmap_unlock(bitmap);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 
 return ret;
 }
@@ -660,9 +658,9 @@ void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
 void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
int64_t offset, int64_t bytes)
 {
-bdrv_dirty_bitmap_lock(bitmap);
+bdrv_dirty_bitmaps_lock(bitmap->bs);
 bdrv_set_dirty_bitmap_locked(bitmap, offset, bytes);
-bdrv_dirty_bitmap_unlock(bitmap);
+bdrv_dirty_bitmaps_unlock(bitmap->bs);
 }
 
 /* Called within bdrv_dirty_bitmap_lock..unlock */
@@ -676,15 +674,15 @@ void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap 
*bitmap,
 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
  int

[libvirt] [PULL v2 01/19] util/hbitmap: strict hbitmap_reset

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

hbitmap_reset has an unobvious property: it rounds requested region up.
It may provoke bugs, like in recently fixed write-blocking mode of
mirror: user calls reset on unaligned region, not keeping in mind that
there are possible unrelated dirty bytes, covered by rounded-up region
and information of this unrelated "dirtiness" will be lost.

Make hbitmap_reset strict: assert that arguments are aligned, allowing
only one exception when @start + @count == hb->orig_size. It's needed
to comfort users of hbitmap_next_dirty_area, which cares about
hb->orig_size.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Max Reitz 
Message-Id: <20190806152611.280389-1-vsement...@virtuozzo.com>
[Maintainer edit: Max's suggestions from on-list. --js]
[Maintainer edit: Eric's suggestion for aligned macro. --js]
Signed-off-by: John Snow 
---
 include/qemu/hbitmap.h | 5 +
 tests/test-hbitmap.c   | 2 +-
 util/hbitmap.c | 4 
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index 4afbe6292e..1bf944ca3d 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -132,6 +132,11 @@ void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t 
count);
  * @count: Number of bits to reset.
  *
  * Reset a consecutive range of bits in an HBitmap.
+ * @start and @count must be aligned to bitmap granularity. The only exception
+ * is resetting the tail of the bitmap: @count may be equal to hb->orig_size -
+ * @start, in this case @count may be not aligned. The sum of @start + @count 
is
+ * allowed to be greater than hb->orig_size, but only if @start < hb->orig_size
+ * and @start + @count = ALIGN_UP(hb->orig_size, granularity).
  */
 void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count);
 
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
index eed5d288cb..e1f867085f 100644
--- a/tests/test-hbitmap.c
+++ b/tests/test-hbitmap.c
@@ -423,7 +423,7 @@ static void test_hbitmap_granularity(TestHBitmapData *data,
 hbitmap_test_check(data, 0);
 hbitmap_test_set(data, 0, 3);
 g_assert_cmpint(hbitmap_count(data->hb), ==, 4);
-hbitmap_test_reset(data, 0, 1);
+hbitmap_test_reset(data, 0, 2);
 g_assert_cmpint(hbitmap_count(data->hb), ==, 2);
 }
 
diff --git a/util/hbitmap.c b/util/hbitmap.c
index fd44c897ab..66db87c6ff 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -476,6 +476,10 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t 
count)
 /* Compute range in the last layer.  */
 uint64_t first;
 uint64_t last = start + count - 1;
+uint64_t gran = 1ULL << hb->granularity;
+
+assert(QEMU_IS_ALIGNED(start, gran));
+assert(QEMU_IS_ALIGNED(count, gran) || (start + count == hb->orig_size));
 
 trace_hbitmap_reset(hb, start, count,
 start >> hb->granularity, last >> hb->granularity);
-- 
2.21.0

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


[libvirt] [PULL v2 00/19] Bitmaps patches

2019-10-14 Thread John Snow
The following changes since commit c760cb77e511eb05094df67c1b30029a952efa35:

  Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20191011a' 
into staging (2019-10-14 16:09:52 +0100)

are available in the Git repository at:

  https://github.com/jnsnow/qemu.git tags/bitmaps-pull-request

for you to fetch changes up to b2ca29ee390743c42a6062d44ee3b10fb51f9fa6:

  dirty-bitmaps: remove deprecated autoload parameter (2019-10-14 15:28:17 
-0400)


Pull request



John Snow (2):
  MAINTAINERS: Add Vladimir as a reviewer for bitmaps
  dirty-bitmaps: remove deprecated autoload parameter

Vladimir Sementsov-Ogievskiy (17):
  util/hbitmap: strict hbitmap_reset
  block: move bdrv_can_store_new_dirty_bitmap to block/dirty-bitmap.c
  block/dirty-bitmap: return int from
bdrv_remove_persistent_dirty_bitmap
  block/qcow2: proper locking on bitmap add/remove paths
  block/dirty-bitmap: drop meta
  block/dirty-bitmap: add bs link
  block/dirty-bitmap: drop BdrvDirtyBitmap.mutex
  block/dirty-bitmap: refactor bdrv_dirty_bitmap_next
  block: switch reopen queue from QSIMPLEQ to QTAILQ
  block: reverse order for reopen commits
  iotests: add test-case to 165 to test reopening qcow2 bitmaps to RW
  block/qcow2-bitmap: get rid of bdrv_has_changed_persistent_bitmaps
  block/qcow2-bitmap: drop qcow2_reopen_bitmaps_rw_hint()
  block/qcow2-bitmap: do not remove bitmaps on reopen-ro
  iotests: add test 260 to check bitmap life after snapshot + commit
  block/qcow2-bitmap: fix and improve qcow2_reopen_bitmaps_rw
  qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_commit

 qemu-deprecated.texi   |  20 ++-
 qapi/block-core.json   |   6 +-
 block/qcow2.h  |  19 +--
 include/block/block.h  |   2 +-
 include/block/block_int.h  |  20 +--
 include/block/dirty-bitmap.h   |  34 ++--
 include/qemu/hbitmap.h |   5 +
 block.c|  79 +++--
 block/backup.c |   8 +-
 block/block-copy.c |   2 +-
 block/dirty-bitmap.c   | 290 +++--
 block/mirror.c |   4 +-
 block/qcow2-bitmap.c   | 212 +++-
 block/qcow2.c  |  22 ++-
 blockdev.c |  40 ++---
 migration/block-dirty-bitmap.c |  11 +-
 migration/block.c  |   4 +-
 tests/test-hbitmap.c   |   2 +-
 util/hbitmap.c |   4 +
 MAINTAINERS|   3 +-
 tests/qemu-iotests/165 |  57 ++-
 tests/qemu-iotests/165.out |   4 +-
 tests/qemu-iotests/260 |  89 ++
 tests/qemu-iotests/260.out |  52 ++
 tests/qemu-iotests/group   |   1 +
 25 files changed, 623 insertions(+), 367 deletions(-)
 create mode 100755 tests/qemu-iotests/260
 create mode 100644 tests/qemu-iotests/260.out

-- 
2.21.0

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


[libvirt] [PULL v2 14/19] block/qcow2-bitmap: do not remove bitmaps on reopen-ro

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

qcow2_reopen_bitmaps_ro wants to store bitmaps and then mark them all
readonly. But the latter don't work, as
qcow2_store_persistent_dirty_bitmaps removes bitmaps after storing.
It's OK for inactivation but bad idea for reopen-ro. And this leads to
the following bug:

Assume we have persistent bitmap 'bitmap0'.
Create external snapshot
  bitmap0 is stored and therefore removed
Commit snapshot
  now we have no bitmaps
Do some writes from guest (*)
  they are not marked in bitmap
Shutdown
Start
  bitmap0 is loaded as valid, but it is actually broken! It misses
  writes (*)
Incremental backup
  it will be inconsistent

So, let's stop removing bitmaps on reopen-ro. But don't rejoice:
reopening bitmaps to rw is broken too, so the whole scenario will not
work after this patch and we can't enable corresponding test cases in
260 iotests still. Reopening bitmaps rw will be fixed in the following
patches.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190927122355.7344-7-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 block/qcow2.h|  3 ++-
 block/qcow2-bitmap.c | 49 ++--
 block/qcow2.c|  2 +-
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 23a9898a54..5cccd87162 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -742,7 +742,8 @@ Qcow2BitmapInfoList 
*qcow2_get_bitmap_info_list(BlockDriverState *bs,
 Error **errp);
 int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
 int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp);
-void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
+void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
+  bool release_stored, Error **errp);
 int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
 bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
  const char *name,
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index ebc1afccd3..f7dfb40256 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1440,7 +1440,32 @@ out:
 return ret;
 }
 
-void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
+/*
+ * qcow2_store_persistent_dirty_bitmaps
+ *
+ * Stores persistent BdrvDirtyBitmap objects.
+ *
+ * @release_stored: if true, release BdrvDirtyBitmap's after storing to the
+ * image. This is used in two cases, both via qcow2_inactivate:
+ * 1. bdrv_close: It's correct to remove bitmaps on close.
+ * 2. migration: If bitmaps are migrated through migration channel via
+ *'dirty-bitmaps' migration capability they are not handled by this code.
+ *Otherwise, it's OK to drop BdrvDirtyBitmap's and reload them on
+ *invalidation.
+ *
+ * Anyway, it's correct to remove BdrvDirtyBitmap's on inactivation, as
+ * inactivation means that we lose control on disk, and therefore on bitmaps,
+ * we should sync them and do not touch more.
+ *
+ * Contrariwise, we don't want to release any bitmaps on just reopen-to-ro,
+ * when we need to store them, as image is still under our control, and it's
+ * good to keep all the bitmaps in read-only mode. Moreover, keeping them
+ * read-only is correct because this is what would happen if we opened the node
+ * readonly to begin with, and whether we opened directly or reopened to that
+ * state shouldn't matter for the state we get afterward.
+ */
+void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
+  bool release_stored, Error **errp)
 {
 BdrvDirtyBitmap *bitmap;
 BDRVQcow2State *s = bs->opaque;
@@ -1551,20 +1576,14 @@ void 
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 g_free(tb);
 }
 
-QSIMPLEQ_FOREACH(bm, bm_list, entry) {
-/* For safety, we remove bitmap after storing.
- * We may be here in two cases:
- * 1. bdrv_close. It's ok to drop bitmap.
- * 2. inactivation. It means migration without 'dirty-bitmaps'
- *capability, so bitmaps are not marked with
- *BdrvDirtyBitmap.migration flags. It's not bad to drop them too,
- *and reload on invalidation.
- */
-if (bm->dirty_bitmap == NULL) {
-continue;
-}
+if (release_stored) {
+QSIMPLEQ_FOREACH(bm, bm_list, entry) {
+if (bm->dirty_bitmap == NULL) {
+continue;
+}
 
-bdrv_release_dirty_bitmap(bm->dirty_bitmap);
+bdrv_release_dirty_bitmap(bm->dirty_bitmap);
+}
 }
 
 success:
@@ -1592,7 +1611,7 @@ int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error 
**errp)
 BdrvDirtyBitmap *bitmap;
 Error *local_err = NULL;
 
-qcow2_store_persistent_dirty_bitmaps(bs, &local_err);
+qcow

[libvirt] [PULL v2 19/19] dirty-bitmaps: remove deprecated autoload parameter

2019-10-14 Thread John Snow
This parameter has been deprecated since 2.12.0 and is eligible for
removal. Remove this parameter as it is actually completely ignored;
let's not give false hope.

Signed-off-by: John Snow 
Reviewed-by: Eric Blake 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
Message-id: 20191002232411.29968-1-js...@redhat.com
---
 qemu-deprecated.texi | 20 +++-
 qapi/block-core.json |  6 +-
 blockdev.c   |  6 --
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 01245e0b1c..7239e0959d 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -149,11 +149,6 @@ QEMU 4.1 has three options, please migrate to one of these 
three:
 
 @section QEMU Machine Protocol (QMP) commands
 
-@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)
-
-"autoload" parameter is now ignored. All bitmaps are automatically loaded
-from qcow2 images.
-
 @subsection query-block result field dirty-bitmaps[i].status (since 4.0)
 
 The ``status'' field of the ``BlockDirtyInfo'' structure, returned by
@@ -356,3 +351,18 @@ existing CPU models.  Management software that needs 
runnability
 guarantees must resolve the CPU model aliases using te
 ``alias-of'' field returned by the ``query-cpu-definitions'' QMP
 command.
+
+
+@node Recently removed features
+@appendix Recently removed features
+
+What follows is a record of recently removed, formerly deprecated
+features that serves as a record for users who have encountered
+trouble after a recent upgrade.
+
+@section QEMU Machine Protocol (QMP) commands
+
+@subsection block-dirty-bitmap-add "autoload" parameter (since 4.2.0)
+
+The "autoload" parameter has been ignored since 2.12.0. All bitmaps
+are automatically loaded from qcow2 images.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index f66553aac7..b274aef713 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2052,10 +2052,6 @@
 #  Qcow2 disks support persistent bitmaps. Default is false for
 #  block-dirty-bitmap-add. (Since: 2.10)
 #
-# @autoload: ignored and deprecated since 2.12.
-#Currently, all dirty tracking bitmaps are loaded from Qcow2 on
-#open.
-#
 # @disabled: the bitmap is created in the disabled state, which means that
 #it will not track drive changes. The bitmap may be enabled with
 #block-dirty-bitmap-enable. Default is false. (Since: 4.0)
@@ -2064,7 +2060,7 @@
 ##
 { 'struct': 'BlockDirtyBitmapAdd',
   'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
-'*persistent': 'bool', '*autoload': 'bool', '*disabled': 'bool' } }
+'*persistent': 'bool', '*disabled': 'bool' } }
 
 ##
 # @BlockDirtyBitmapMergeSource:
diff --git a/blockdev.c b/blockdev.c
index d77e809623..03c7cd7651 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1966,7 +1966,6 @@ static void block_dirty_bitmap_add_prepare(BlkActionState 
*common,
 qmp_block_dirty_bitmap_add(action->node, action->name,
action->has_granularity, action->granularity,
action->has_persistent, action->persistent,
-   action->has_autoload, action->autoload,
action->has_disabled, action->disabled,
&local_err);
 
@@ -2858,7 +2857,6 @@ out:
 void qmp_block_dirty_bitmap_add(const char *node, const char *name,
 bool has_granularity, uint32_t granularity,
 bool has_persistent, bool persistent,
-bool has_autoload, bool autoload,
 bool has_disabled, bool disabled,
 Error **errp)
 {
@@ -2890,10 +2888,6 @@ void qmp_block_dirty_bitmap_add(const char *node, const 
char *name,
 persistent = false;
 }
 
-if (has_autoload) {
-warn_report("Autoload option is deprecated and its value is ignored");
-}
-
 if (!has_disabled) {
 disabled = false;
 }
-- 
2.21.0

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


[libvirt] [PULL v2 08/19] block/dirty-bitmap: refactor bdrv_dirty_bitmap_next

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

bdrv_dirty_bitmap_next is always used in same pattern. So, split it
into _next and _first, instead of combining two functions into one and
add FOR_EACH_DIRTY_BITMAP macro.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190916141911.5255-5-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 include/block/dirty-bitmap.h   |  9 +++--
 block.c|  4 +---
 block/dirty-bitmap.c   | 11 +++
 block/qcow2-bitmap.c   |  8 ++--
 migration/block-dirty-bitmap.c |  4 +---
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 2f9b088e11..257f0f6704 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -96,8 +96,13 @@ bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap 
*bitmap);
 bool bdrv_dirty_bitmap_get_persistence(BdrvDirtyBitmap *bitmap);
 bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap *bitmap);
 bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
-BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
-BdrvDirtyBitmap *bitmap);
+
+BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs);
+BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BdrvDirtyBitmap *bitmap);
+#define FOR_EACH_DIRTY_BITMAP(bs, bitmap) \
+for (bitmap = bdrv_dirty_bitmap_first(bs); bitmap; \
+ bitmap = bdrv_dirty_bitmap_next(bitmap))
+
 char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp);
 int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t offset,
 uint64_t bytes);
diff --git a/block.c b/block.c
index d19a4781a3..5721441697 100644
--- a/block.c
+++ b/block.c
@@ -5390,9 +5390,7 @@ static void coroutine_fn 
bdrv_co_invalidate_cache(BlockDriverState *bs,
 }
 }
 
-for (bm = bdrv_dirty_bitmap_next(bs, NULL); bm;
- bm = bdrv_dirty_bitmap_next(bs, bm))
-{
+FOR_EACH_DIRTY_BITMAP(bs, bm) {
 bdrv_dirty_bitmap_skip_store(bm, false);
 }
 
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 4e5c87a907..6065db8094 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -851,11 +851,14 @@ bool bdrv_has_changed_persistent_bitmaps(BlockDriverState 
*bs)
 return false;
 }
 
-BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
-BdrvDirtyBitmap *bitmap)
+BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs)
 {
-return bitmap == NULL ? QLIST_FIRST(&bs->dirty_bitmaps) :
-QLIST_NEXT(bitmap, list);
+return QLIST_FIRST(&bs->dirty_bitmaps);
+}
+
+BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BdrvDirtyBitmap *bitmap)
+{
+return QLIST_NEXT(bitmap, list);
 }
 
 char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 687087d2bc..99812b418b 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1488,9 +1488,7 @@ void 
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 }
 
 /* check constraints and names */
-for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap != NULL;
- bitmap = bdrv_dirty_bitmap_next(bs, bitmap))
-{
+FOR_EACH_DIRTY_BITMAP(bs, bitmap) {
 const char *name = bdrv_dirty_bitmap_name(bitmap);
 uint32_t granularity = bdrv_dirty_bitmap_granularity(bitmap);
 Qcow2Bitmap *bm;
@@ -1610,9 +1608,7 @@ int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error 
**errp)
 return -EINVAL;
 }
 
-for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap != NULL;
- bitmap = bdrv_dirty_bitmap_next(bs, bitmap))
-{
+FOR_EACH_DIRTY_BITMAP(bs, bitmap) {
 if (bdrv_dirty_bitmap_get_persistence(bitmap)) {
 bdrv_dirty_bitmap_set_readonly(bitmap, true);
 }
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index 793f249aa5..7eafface61 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -283,9 +283,7 @@ static int init_dirty_bitmap_migration(void)
 for (bs = bdrv_next_all_states(NULL); bs; bs = bdrv_next_all_states(bs)) {
 const char *name = bdrv_get_device_or_node_name(bs);
 
-for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap;
- bitmap = bdrv_dirty_bitmap_next(bs, bitmap))
-{
+FOR_EACH_DIRTY_BITMAP(bs, bitmap) {
 if (!bdrv_dirty_bitmap_name(bitmap)) {
 continue;
 }
-- 
2.21.0

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


[libvirt] [PULL v2 12/19] block/qcow2-bitmap: get rid of bdrv_has_changed_persistent_bitmaps

2019-10-14 Thread John Snow
From: Vladimir Sementsov-Ogievskiy 

Firstly, no reason to optimize failure path. Then, function name is
ambiguous: it checks for readonly and similar things, but someone may
think that it will ignore normal bitmaps which was just unchanged, and
this is in bad relation with the fact that we should drop IN_USE flag
for unchanged bitmaps in the image.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
Message-id: 20190927122355.7344-5-vsement...@virtuozzo.com
Signed-off-by: John Snow 
---
 include/block/dirty-bitmap.h |  1 -
 block/dirty-bitmap.c | 12 
 block/qcow2-bitmap.c | 23 +--
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 257f0f6704..958e7474fb 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -95,7 +95,6 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
 bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
 bool bdrv_dirty_bitmap_get_persistence(BdrvDirtyBitmap *bitmap);
 bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap *bitmap);
-bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
 
 BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs);
 BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BdrvDirtyBitmap *bitmap);
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 6065db8094..4bbb251b2c 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -839,18 +839,6 @@ bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap 
*bitmap)
 return bitmap->inconsistent;
 }
 
-bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs)
-{
-BdrvDirtyBitmap *bm;
-QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
-if (bm->persistent && !bm->readonly && !bm->skip_store) {
-return true;
-}
-}
-
-return false;
-}
-
 BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs)
 {
 return QLIST_FIRST(&bs->dirty_bitmaps);
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 99812b418b..6dfc083548 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1464,16 +1464,7 @@ void 
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 Qcow2Bitmap *bm;
 QSIMPLEQ_HEAD(, Qcow2BitmapTable) drop_tables;
 Qcow2BitmapTable *tb, *tb_next;
-
-if (!bdrv_has_changed_persistent_bitmaps(bs)) {
-/* nothing to do */
-return;
-}
-
-if (!can_write(bs)) {
-error_setg(errp, "No write access");
-return;
-}
+bool need_write = false;
 
 QSIMPLEQ_INIT(&drop_tables);
 
@@ -1499,6 +1490,8 @@ void 
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 continue;
 }
 
+need_write = true;
+
 if (check_constraints_on_bitmap(bs, name, granularity, errp) < 0) {
 error_prepend(errp, "Bitmap '%s' doesn't satisfy the constraints: 
",
   name);
@@ -1537,6 +1530,15 @@ void 
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 bm->dirty_bitmap = bitmap;
 }
 
+if (!need_write) {
+goto success;
+}
+
+if (!can_write(bs)) {
+error_setg(errp, "No write access");
+goto fail;
+}
+
 /* allocate clusters and store bitmaps */
 QSIMPLEQ_FOREACH(bm, bm_list, entry) {
 if (bm->dirty_bitmap == NULL) {
@@ -1578,6 +1580,7 @@ void 
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 bdrv_release_dirty_bitmap(bm->dirty_bitmap);
 }
 
+success:
 bitmap_list_free(bm_list);
 return;
 
-- 
2.21.0

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


Re: [libvirt] [PULL 01/19] util/hbitmap: strict hbitmap_reset

2019-10-14 Thread John Snow


On 10/11/19 7:18 PM, John Snow wrote:
> 
> 
> On 10/11/19 5:48 PM, Eric Blake wrote:
>> On 10/11/19 4:25 PM, John Snow wrote:
>>> From: Vladimir Sementsov-Ogievskiy 
>>>
>>> hbitmap_reset has an unobvious property: it rounds requested region up.
>>> It may provoke bugs, like in recently fixed write-blocking mode of
>>> mirror: user calls reset on unaligned region, not keeping in mind that
>>> there are possible unrelated dirty bytes, covered by rounded-up region
>>> and information of this unrelated "dirtiness" will be lost.
>>>
>>> Make hbitmap_reset strict: assert that arguments are aligned, allowing
>>> only one exception when @start + @count == hb->orig_size. It's needed
>>> to comfort users of hbitmap_next_dirty_area, which cares about
>>> hb->orig_size.
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy 
>>> Reviewed-by: Max Reitz 
>>> Message-Id: <20190806152611.280389-1-vsement...@virtuozzo.com>
>>> [Maintainer edit: Max's suggestions from on-list. --js]
>>> Signed-off-by: John Snow 
>>> ---
>>>   include/qemu/hbitmap.h | 5 +
>>>   tests/test-hbitmap.c   | 2 +-
>>>   util/hbitmap.c | 4 
>>>   3 files changed, 10 insertions(+), 1 deletion(-)
>>>
>>
>>> +++ b/util/hbitmap.c
>>> @@ -476,6 +476,10 @@ void hbitmap_reset(HBitmap *hb, uint64_t start,
>>> uint64_t count)
>>>   /* Compute range in the last layer.  */
>>>   uint64_t first;
>>>   uint64_t last = start + count - 1;
>>> +    uint64_t gran = 1ULL << hb->granularity;
>>> +
>>> +    assert(!(start & (gran - 1)));
>>> +    assert(!(count & (gran - 1)) || (start + count == hb->orig_size));
>>
>> I know I'm replying a bit late (since this is now a pull request), but
>> would it be worth using the dedicated macro:
>>
>> assert(QEMU_IS_ALIGNED(start, gran));
>> assert(QEMU_IS_ALIGNED(count, gran) || start + count == hb->orig_size);
>>
>> instead of open-coding it?  (I would also drop the extra () around the
>> right half of ||). If we want it, that would now be a followup patch.

I've noticed that seasoned C programmers hate extra parentheses a lot.
I've noticed that I cannot remember operator precedence enough to ever
feel like this is actually an improvement.

Something about a nice weighted tree of ((expr1) || (expr2)) feels
soothing to my weary eyes. So, if it's not terribly important, I'd
prefer to leave it as-is.

(You may feel free to counter-educate me as desired.)

>>
> 
> If the PR doesn't make it for some reason, I can amend a cleanup patch
> for the next PR.
> 

by the way: GOOD NEWS! ...

--js

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

Re: [libvirt] Add support for vhost-user-scsi-pci/vhost-user-blk-pci

2019-10-14 Thread Cole Robinson
On 10/14/19 3:12 AM, Li Feng wrote:
> Hi Cole & Michal,
> 
> I'm sorry for my late response, I just end my journey today.
> Thank your response, your suggestion is very helpful to me.
> 
> I have added Michal in this mail, Michal helps me review my initial patchset.
> (https://www.spinics.net/linux/fedora/libvir/msg191339.html)
> 

Whoops I missed that posting, I didn't realize you had sent patches!

> All concern about this feature is the XML design.
> My original XML design exposes more details of Qemu.
> 
>  
>  
>  
>  
>  
>  
> 
> As Cole's suggestion, the better design with all vhost-user-scsi/blk
> features would like this:
> 
> vhost-user-blk:
> 
> 
> 
> 
>  
> 
> 
>   function='0x0'/>
> 
> 
> vhost-user-scsi:
> 
> 
> 
> 
> 
> 
> 
> 
> 

I think my SCSI idea is wrong, sorry. vhost-user-scsi is for passing a
scsi host adapter to the VM, correct? If so, then it's not really a
, and so using the existing vhost-scsi support in  is
probably better.  could possible be used for vhost-user-blk as well

Can you provide some examples of full qemu command lines using
vhost-user-blk and vhost-user-scsi? Just linking to examples else where
is fine, but I'm wondering if there's more context

Internally we already have an abstraction for vhost-scsi:


  



The obvious extension would be


  


Internally implementing this will be weird. The  parameters are
only dictated by the hostdev type= field, but in this case they would be
dictated by the  field, and we would want to reuse the
internal chardev abstraction.

vhost-user-blk could be implemented similarly, but with type='storage'
which is the way we pass through block devices to LXC guests, but it
isn't currently supported in the qemu driver.

I dunno. Maybe Michal or danpb can provide guidance


> Conclusion:
> 1. Add new type(vhostuser) for disk label;
> 2. Add queue sub-label for disk to support multiqueue( num='4'/>) or reusing the driver label
> ( Qemu support multiqueue like this:
> -device vhost-user-scsi-pci,id=scsi0,chardev=spdk_vhost_scsi0,num_queues=4
> -device vhost-user-blk-pci,chardev=spdk_vhost_blk0,num-queues=4
> 

num-queues is already supported by libvirt for both  and 
with , so whether we use  or  you won't
need to add any new XML here.

> Another question:
> When qemu is connecting to a vhost-user-scsi controller[1],  there may
> exist multiple LUNs under one target,
> then one disklabel() will represent multiple SCSI LUNs,
> the 'dev' property() will be ignored, right?
> In other words, for vhost-user-scsi disk, it more likes a controller,
> maybe the controller label is suitable.
> 

Yes you are right, and this was my understanding. But then its not
really a  in libvirt's sense because we can't attach
emulated devices to it, so it's more a fit for the existing 
vhost-user support. Unfortunately it's not really a clean fit anywhere,
there will have to be some kind of compromise. And I'm not sure if
 or  is right for vhost-user-blk, but hopefully others
have more clear opinions.

Thanks,
Cole

> I look forward to hearing from you as soon as possible.
> 
> [1]: https://spdk.io/doc/vhost.html
> 
> Feng Li
> 
> Cole Robinson  于2019年10月10日周四 上午6:48写道:
>>
>> Sorry for the late reply, and thanks Jano for pointing out elsewhere
>> that this didn't receive a response.
>>
>> On 8/12/19 5:56 AM, Li Feng wrote:
>>> Hi Guys,
>>>
>>> And I want to add the vhost-user-scsi-pci/vhost-user-blk-pci support
>>> for libvirt.
>>>
>>> The usage in qemu like this:
>>>
>>> Vhost-SCSI
>>> -chardev socket,id=char0,path=/var/tmp/vhost.0
>>> -device vhost-user-scsi-pci,id=scsi0,chardev=char0
>>> Vhost-BLK
>>> -chardev socket,id=char1,path=/var/tmp/vhost.1
>>> -device vhost-user-blk-pci,id=blk0,chardev=char1
>>>
>>
>> Indeed that matches what I see for the qemu commits too:
>>
>> https://git.qemu.org/?p=qemu.git;a=commit;h=00343e4b54b
>> https://git.qemu.org/?p=qemu.git;a=commit;h=f12c1ebddf7
>>
>>> What type should I add for libvirt.
>>> Type1:
>>>   
>>>   >> path='/tmp/vhost-scsi.sock'>
>>>   
>>>   
>>>
>>>
>>> Type2:
>>>
>>>   
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>   
>>>
>>>
>>>   
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> function='0x0'/>
>>>   
>>>
>>
>> I think wiring this into  makes more sense.  is really an
>> abstraction for assigning a (typically) physical host device to the VM,
>> so it handles things like hiding a PCI device from the host, and passing
>> that exact device to the VM.
>>
>> In the vhost-user-scsi/blk case, the host device is just a special
>> process running on the other side of a socket, and the device
>> represented to the guest is a typical virtio device. So to me it makes
>> more sense as a  with a  that points at that socket.
>>
>> target bus=virtio vs bus=scsi is alre

Re: [libvirt] [PATCH v2 1/3] qemu: use a bigger unplug timeout for PPC64 guests

2019-10-14 Thread Cole Robinson

On 10/11/19 3:54 PM, Daniel Henrique Barboza wrote:



On 10/9/19 5:15 PM, Cole Robinson wrote:

On 9/11/19 5:05 PM, Daniel Henrique Barboza wrote:

For some architectures and setups, device removal can take
longer than the default 5 seconds. This results in commands
such as 'virsh setvcpus' to fire timeout messages even if
the operation were successful in the guest, confusing the
user.

This patch sets a new 10 seconds unplug timeout for PPC64
guests. All other archs will keep the default 5 seconds
timeout.

Instead of putting 'if PPC64' conditionals inside qemu_hotplug.c
to set the new timeout value, a new QEMU driver attribute
'unplugTimeout' was added. The timeout value is set during
qemuStateInitialize only once. All qemu_hotplug.c functions
that uses the timeout have easy access to a qemu_driver object,
thus the change to use unplugTimeout is straightforward.

The now unused 'qemuDomainRemoveDeviceWaitTime' global can't
be simply erased from qemu_hotplug.c though. Next patch will
remove it properly.



Sorry for the wrong review delay. I see this implements danpb's 
suggestion from the previous thread. The implementation seems a little 
odd to me though because it is differentiating on host arch, but this 
is about guest arch right? And probably an arbitrary number of 
options, like I imagine TCG would want a longer timeout too (though 
that's not anything you need to deal with)


I think it's sensible to say that a TCG guest would always required a
greater unplug timeout than a hardware accelerated one. However, never
thought about considering TCG guests in this patch series though. A shame.

So, considering that TCG guest exists, we can parametrize this unplug 
timeout
calculation by considering guest (not host) architecture and if it's a 
TCG or

a KVM guest. Speaking about the problem I'm trying to fix with ppc64 and
what we already have, we can roll out this unplug timeout logic like:

- pseries guest on KVM: 10 seconds
- everyone else on KVM: 5 seconds (untouched, like it is today)
 > For TCG guests, perhaps double the KVM timeout? This would need
experimentation, but double the timeout seems ok at first glance. Then we
can do:

- TCG pseries guest: 10 * 2 = 20 seconds
- TCG with every other arch guest = 5 * 2 = 10 seconds


This TCG calculation can be left alone for now as well - I can create 
the API
considering that TCG guest exists, but do not infer the timeout for it. 
Either

way works for me.



I suggest just fixing the case you care about, leave TCG as it is (the 
default 5 seconds), otherwise we may be trying to fix something that no 
one cares about in real life.


But I think conceptually the function is a better fit incase the logic 
every becomes more complicated than a single host check.




So I think this should be a function that lives in qemu_hotplug.c and 
acts on a DomainDef at least. The test suite will have to mock that in 
a qemuhotplugmock.c file, tests/qemucpumock.c is a good example to 
follow.


Just to check if we're on the same page, by 'I think this should be a 
function'

you mean the calculation of qemuDomainRemoveDeviceWaitTime that I just
mentioned above, right?



Yup that's what I meant

Thanks,
Cole

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


[libvirt] [PATCH 36/35] syntax-check: forbid ATTRIBUTE macros with a GLib replacement

2019-10-14 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 build-aux/syntax-check.mk | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index c220dadd6c..c30d575e77 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -628,6 +628,12 @@ sc_avoid_g_gnuc_unused_in_header:
halt='use G_GNUC_UNUSED in .c rather than .h files' \
  $(_sc_search_regexp)
 
+sc_prohibit_attribute_macros:
+   @prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK)' \
+   in_vc_files='\.[ch]$$' \
+   halt='use GLib macros: 
G_GNUC_{UNUSED,NORETURN,NULL_TERMINATED,WARN_UNUSED_RESULT}' \
+ $(_sc_search_regexp)
+
 sc_prohibit_int_index:
@prohibit='\<(int|unsigned)\s*\*?index\>(\s|,|;)' \
halt='use different name than 'index' for declaration' \
-- 
2.19.2

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

[libvirt] [PATCH] virhostuptime: Add linux stub for musl

2019-10-14 Thread Michal Privoznik
When we want to know the boot timestamp of the host, we can call
virHostGetBootTime(). Under the hood, it uses getutxid() which is
defined by POSIX and properly check for in configure. However,
musl took a path where it declares the function but instead of
providing any useful implementation it returns NULL meaning "no
record found". If that's the case, use our second best option -
/proc/uptime and a bit of maths.

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

Signed-off-by: Michal Privoznik 
---
 src/util/virhostuptime.c | 64 ++--
 1 file changed, 61 insertions(+), 3 deletions(-)

diff --git a/src/util/virhostuptime.c b/src/util/virhostuptime.c
index 62b781acd5..3189074d3d 100644
--- a/src/util/virhostuptime.c
+++ b/src/util/virhostuptime.c
@@ -25,16 +25,68 @@
 #endif
 
 #include "virhostuptime.h"
+#include "viralloc.h"
+#include "virfile.h"
+#include "virlog.h"
+#include "virstring.h"
+#include "virtime.h"
 #include "virthread.h"
 
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+VIR_LOG_INIT("util.virhostuptime");
+
 static unsigned long long bootTime;
 static int bootTimeErrno;
 static virOnceControl virHostGetBootTimeOnce = VIR_ONCE_CONTROL_INITIALIZER;
 
-#ifdef HAVE_GETUTXID
+#if defined(__linux__)
+# define UPTIME_FILE  "/proc/uptime"
+static int
+virHostGetBootTimeProcfs(unsigned long long *btime)
+{
+unsigned long long now;
+double up;
+g_autofree char *buf = NULL;
+char *tmp;
+
+if (virTimeMillisNow(&now) < 0)
+return -errno;
+
+/* 1KiB limit is more than enough. */
+if (virFileReadAll(UPTIME_FILE, 1024, &buf) < 0)
+return -errno;
+
+/* buf contains two doubles now:
+ *   $uptime $idle_time
+ * We're interested only in the first one */
+if (!(tmp = strchr(buf, ' '))) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("uptime file has unexpected format '%s'"),
+   buf);
+return -EINVAL;
+}
+
+*tmp = '\0';
+
+if (virStrToDouble(buf, NULL, &up) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Unable to parse sched info value '%s'"),
+   buf);
+return -EINVAL;
+}
+
+*btime = now / 1000 - up + 0.5;
+
+return 0;
+}
+#endif /* defined(__linux__) */
+
+#if defined(HAVE_GETUTXID) || defined(__linux__)
 static void
 virHostGetBootTimeOnceInit(void)
 {
+# ifdef HAVE_GETUTXID
 struct utmpx id = {.ut_type = BOOT_TIME};
 struct utmpx *res = NULL;
 
@@ -45,16 +97,22 @@ virHostGetBootTimeOnceInit(void)
 }
 
 endutxent();
+# endif /* HAVE_GETUTXID */
+
+if (bootTimeErrno == ENODATA ||
+(bootTime == 0 && bootTimeErrno == 0)) {
+bootTimeErrno = -virHostGetBootTimeProcfs(&bootTime);
+}
 }
 
-#else /* !HAVE_GETUTXID */
+#else /* !defined(HAVE_GETUTXID) && !defined(__linux__) */
 
 static void
 virHostGetBootTimeOnceInit(void)
 {
 bootTimeErrno = ENOSYS;
 }
-#endif /* HAVE_GETUTXID */
+#endif /* !defined(HAVE_GETUTXID) && !defined(__linux__) */
 
 /**
  * virHostGetBootTime:
-- 
2.21.0

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


[libvirt] [PATCH 31/35] vz: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/vz/vz_driver.c | 60 +++---
 src/vz/vz_sdk.c|  8 +++
 src/vz/vz_utils.c  |  2 +-
 3 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index eb3fcf1fcc..c5fe59376e 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -243,10 +243,10 @@ vzDomainDefAddDefaultInputDevices(virDomainDefPtr def)
 
 static int
 vzDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- unsigned int parseFlags ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED,
- void *parseOpaque ATTRIBUTE_UNUSED)
+ virCapsPtr caps G_GNUC_UNUSED,
+ unsigned int parseFlags G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED,
+ void *parseOpaque G_GNUC_UNUSED)
 {
 if (vzDomainDefAddDefaultInputDevices(def) < 0)
 return -1;
@@ -256,7 +256,7 @@ vzDomainDefPostParse(virDomainDefPtr def,
 
 static int
 vzDomainDefValidate(const virDomainDef *def,
-virCapsPtr caps ATTRIBUTE_UNUSED,
+virCapsPtr caps G_GNUC_UNUSED,
 void *opaque)
 {
 if (vzCheckUnsupportedControllers(def, opaque) < 0)
@@ -268,10 +268,10 @@ vzDomainDefValidate(const virDomainDef *def,
 static int
 vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
const virDomainDef *def,
-   virCapsPtr caps ATTRIBUTE_UNUSED,
-   unsigned int parseFlags ATTRIBUTE_UNUSED,
-   void *opaque ATTRIBUTE_UNUSED,
-   void *parseOpaque ATTRIBUTE_UNUSED)
+   virCapsPtr caps G_GNUC_UNUSED,
+   unsigned int parseFlags G_GNUC_UNUSED,
+   void *opaque G_GNUC_UNUSED,
+   void *parseOpaque G_GNUC_UNUSED)
 {
 if (dev->type == VIR_DOMAIN_DEVICE_NET &&
 (dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
@@ -286,7 +286,7 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
 static int
 vzDomainDeviceDefValidate(const virDomainDeviceDef *dev,
   const virDomainDef *def,
-  void *opaque ATTRIBUTE_UNUSED)
+  void *opaque G_GNUC_UNUSED)
 {
 if (dev->type == VIR_DOMAIN_DEVICE_DISK)
 return vzCheckUnsupportedDisk(def, dev->data.disk, opaque);
@@ -346,8 +346,8 @@ vzDriverObjNew(void)
 
 static virDrvOpenStatus
 vzConnectOpen(virConnectPtr conn,
-  virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-  virConfPtr conf ATTRIBUTE_UNUSED,
+  virConnectAuthPtr auth G_GNUC_UNUSED,
+  virConfPtr conf G_GNUC_UNUSED,
   unsigned int flags)
 {
 vzDriverPtr driver = NULL;
@@ -898,19 +898,19 @@ vzNodeGetInfo(virConnectPtr conn,
 return virCapabilitiesGetNodeInfo(nodeinfo);
 }
 
-static int vzConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int vzConnectIsEncrypted(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Encryption is not relevant / applicable to way we talk to PCS */
 return 0;
 }
 
-static int vzConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int vzConnectIsSecure(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* We run CLI tools directly so this is secure */
 return 1;
 }
 
-static int vzConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int vzConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 1;
 }
@@ -2967,8 +2967,8 @@ static int
 vzDomainMigratePrepare3Params(virConnectPtr conn,
   virTypedParameterPtr params,
   int nparams,
-  const char *cookiein ATTRIBUTE_UNUSED,
-  int cookieinlen ATTRIBUTE_UNUSED,
+  const char *cookiein G_GNUC_UNUSED,
+  int cookieinlen G_GNUC_UNUSED,
   char **cookieout,
   int *cookieoutlen,
   char **uri_out,
@@ -3030,7 +3030,7 @@ vzDomainMigratePrepare3Params(virConnectPtr conn,
 }
 
 static int
-vzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
+vzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature)
 {
 if (virConnectSupportsFeatureEnsureACL(conn) < 0)
 return -1;
@@ -3262,8 +3262,8 @@ vzDomainMigratePerform3Params(virDomainPtr domain,
   int nparams,
   const char *cookiein,
   int cookieinlen,
-  char **cookieout ATTRIBUTE_UNUSED,
-  int *cookieoutlen ATTRIBUTE_UNUSED,
+  

[libvirt] [PATCH 35/35] internal: remove no longer used ATTRIBUTE macros

2019-10-14 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 docs/apibuild.py |  2 --
 src/internal.h   | 31 ---
 2 files changed, 33 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index b11d3fd5a9..4f0d170975 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -71,8 +71,6 @@ admin_included_files = {
 }
 
 ignored_words = {
-  "ATTRIBUTE_UNUSED": (0, "macro keyword"),
-  "ATTRIBUTE_SENTINEL": (0, "macro keyword"),
   "G_GNUC_UNUSED": (0, "macro keyword"),
   "G_GNUC_NULL_TERMINATED": (0, "macro keyword"),
   "VIR_DEPRECATED": (0, "macro keyword"),
diff --git a/src/internal.h b/src/internal.h
index 56e99241b0..7737d9a209 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -93,33 +93,6 @@
 #define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
 #define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
 
-/**
- * ATTRIBUTE_UNUSED:
- *
- * Macro to flag consciously unused parameters to functions
- */
-#ifndef ATTRIBUTE_UNUSED
-# define ATTRIBUTE_UNUSED __attribute__((__unused__))
-#endif
-
-/**
- * ATTRIBUTE_NORETURN:
- *
- * Macro to indicate that a function won't return to the caller
- */
-#ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
-#endif
-
-/**
- * ATTRIBUTE_SENTINEL:
- *
- * Macro to check for NULL-terminated varargs lists
- */
-#ifndef ATTRIBUTE_SENTINEL
-# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
-#endif
-
 /**
  * ATTRIBUTE_NOINLINE:
  *
@@ -150,10 +123,6 @@
 # endif
 #endif
 
-#ifndef ATTRIBUTE_RETURN_CHECK
-# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
-#endif
-
 /**
  * ATTRIBUTE_PACKED
  *
-- 
2.19.2

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

[libvirt] [PATCH 22/35] remote: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/remote/remote_daemon.c  |  20 +-
 src/remote/remote_daemon_config.c   |   2 +-
 src/remote/remote_daemon_dispatch.c | 420 ++--
 src/remote/remote_daemon_stream.c   |   2 +-
 src/remote/remote_driver.c  | 270 +-
 5 files changed, 357 insertions(+), 357 deletions(-)

diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 7fcaa31c49..5f50d07002 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -273,8 +273,8 @@ daemonUnixSocketPaths(struct daemonConfig *config,
 }
 
 
-static void daemonErrorHandler(void *opaque ATTRIBUTE_UNUSED,
-   virErrorPtr err ATTRIBUTE_UNUSED)
+static void daemonErrorHandler(void *opaque G_GNUC_UNUSED,
+   virErrorPtr err G_GNUC_UNUSED)
 {
 /* Don't do anything, since logging infrastructure already
  * took care of reporting the error */
@@ -698,13 +698,13 @@ daemonVersion(const char *argv0)
 
 
 static void daemonShutdownHandler(virNetDaemonPtr dmn,
-  siginfo_t *sig ATTRIBUTE_UNUSED,
-  void *opaque ATTRIBUTE_UNUSED)
+  siginfo_t *sig G_GNUC_UNUSED,
+  void *opaque G_GNUC_UNUSED)
 {
 virNetDaemonQuit(dmn);
 }
 
-static void daemonReloadHandlerThread(void *opague ATTRIBUTE_UNUSED)
+static void daemonReloadHandlerThread(void *opague G_GNUC_UNUSED)
 {
 VIR_INFO("Reloading configuration on SIGHUP");
 virHookCall(VIR_HOOK_DRIVER_DAEMON, "-",
@@ -713,9 +713,9 @@ static void daemonReloadHandlerThread(void *opague 
ATTRIBUTE_UNUSED)
 VIR_WARN("Error while reloading drivers");
 }
 
-static void daemonReloadHandler(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
-siginfo_t *sig ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED)
+static void daemonReloadHandler(virNetDaemonPtr dmn G_GNUC_UNUSED,
+siginfo_t *sig G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED)
 {
 virThread thr;
 
@@ -787,7 +787,7 @@ static void daemonStop(virNetDaemonPtr dmn)
 
 
 static DBusHandlerResult
-handleSessionMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
+handleSessionMessageFunc(DBusConnection *connection G_GNUC_UNUSED,
  DBusMessage *message,
  void *opaque)
 {
@@ -805,7 +805,7 @@ handleSessionMessageFunc(DBusConnection *connection 
ATTRIBUTE_UNUSED,
 
 
 static DBusHandlerResult
-handleSystemMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
+handleSystemMessageFunc(DBusConnection *connection G_GNUC_UNUSED,
 DBusMessage *message,
 void *opaque)
 {
diff --git a/src/remote/remote_daemon_config.c 
b/src/remote/remote_daemon_config.c
index 0eecb20c34..ce5f8c5278 100644
--- a/src/remote/remote_daemon_config.c
+++ b/src/remote/remote_daemon_config.c
@@ -100,7 +100,7 @@ daemonConfigFilePath(bool privileged, char **configfile)
 }
 
 struct daemonConfig*
-daemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
+daemonConfigNew(bool privileged G_GNUC_UNUSED)
 {
 struct daemonConfig *data;
 
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 8c9390c1d2..cd929c36da 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1822,7 +1822,7 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
 }
 
 static
-void remoteRelayConnectionClosedEvent(virConnectPtr conn ATTRIBUTE_UNUSED, int 
reason, void *opaque)
+void remoteRelayConnectionClosedEvent(virConnectPtr conn G_GNUC_UNUSED, int 
reason, void *opaque)
 {
 virNetServerClientPtr client = opaque;
 
@@ -2109,7 +2109,7 @@ remoteGetStorageConn(virNetServerClientPtr client)
 
 
 void *remoteClientNew(virNetServerClientPtr client,
-  void *opaque ATTRIBUTE_UNUSED)
+  void *opaque G_GNUC_UNUSED)
 {
 struct daemonClientPrivate *priv;
 
@@ -2254,9 +2254,9 @@ remoteDispatchProbeURI(bool readonly,
 
 
 static int
-remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
+remoteDispatchConnectOpen(virNetServerPtr server G_GNUC_UNUSED,
   virNetServerClientPtr client,
-  virNetMessagePtr msg ATTRIBUTE_UNUSED,
+  virNetMessagePtr msg G_GNUC_UNUSED,
   virNetMessageErrorPtr rerr,
   struct remote_connect_open_args *args)
 {
@@ -2408,10 +2408,10 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 
 
 static int
-remoteDispatchConnectClose(virNetServerPtr server ATTRIBUTE_UNUSED,
+remoteDispatchConnectClose(virNetServerPtr server G_GNUC_UNUSED,
virNetServerClientPtr clien

[libvirt] [PATCH 34/35] gendispatch: generate G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED

2019-10-14 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/rpc/gendispatch.pl | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 9d3cc5b145..5d1583980e 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -487,8 +487,8 @@ elsif ($mode eq "server") {
 my $argtype = $call->{args};
 my $rettype = $call->{ret};
 
-my $argann = $argtype ne "void" ? "" : " ATTRIBUTE_UNUSED";
-my $retann = $rettype ne "void" ? "" : " ATTRIBUTE_UNUSED";
+my $argann = $argtype ne "void" ? "" : " G_GNUC_UNUSED";
+my $retann = $rettype ne "void" ? "" : " G_GNUC_UNUSED";
 
 # First we print out a function declaration for the
 # real dispatcher body
@@ -1027,9 +1027,9 @@ elsif ($mode eq "server") {
 
 # print functions signature
 print "static int $name(\n";
-print "virNetServerPtr server ATTRIBUTE_UNUSED,\n";
+print "virNetServerPtr server G_GNUC_UNUSED,\n";
 print "virNetServerClientPtr client,\n";
-print "virNetMessagePtr msg ATTRIBUTE_UNUSED,\n";
+print "virNetMessagePtr msg G_GNUC_UNUSED,\n";
 print "virNetMessageErrorPtr rerr";
 if ($argtype ne "void") {
 print ",\n$argtype *args";
-- 
2.19.2

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

[libvirt] [PATCH 15/35] logging: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/logging/log_daemon.c  | 18 +-
 src/logging/log_daemon_config.c   |  2 +-
 src/logging/log_daemon_dispatch.c | 22 +++---
 src/logging/log_handler.c |  6 +++---
 4 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 9621702138..e56dbf2919 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -422,8 +422,8 @@ virLogDaemonUnixSocketPaths(bool privileged,
 
 
 static void
-virLogDaemonErrorHandler(void *opaque ATTRIBUTE_UNUSED,
- virErrorPtr err ATTRIBUTE_UNUSED)
+virLogDaemonErrorHandler(void *opaque G_GNUC_UNUSED,
+ virErrorPtr err G_GNUC_UNUSED)
 {
 /* Don't do anything, since logging infrastructure already
  * took care of reporting the error */
@@ -487,16 +487,16 @@ virLogDaemonVersion(const char *argv0)
 
 static void
 virLogDaemonShutdownHandler(virNetDaemonPtr dmn,
-siginfo_t *sig ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED)
+siginfo_t *sig G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED)
 {
 virNetDaemonQuit(dmn);
 }
 
 static void
 virLogDaemonExecRestartHandler(virNetDaemonPtr dmn,
-   siginfo_t *sig ATTRIBUTE_UNUSED,
-   void *opaque ATTRIBUTE_UNUSED)
+   siginfo_t *sig G_GNUC_UNUSED,
+   void *opaque G_GNUC_UNUSED)
 {
 execRestart = true;
 virNetDaemonQuit(dmn);
@@ -593,7 +593,7 @@ virLogDaemonClientNew(virNetServerClientPtr client,
 
 static void *
 virLogDaemonClientNewPostExecRestart(virNetServerClientPtr client,
- virJSONValuePtr object ATTRIBUTE_UNUSED,
+ virJSONValuePtr object G_GNUC_UNUSED,
  void *opaque)
 {
 virLogDaemonClientPtr priv = virLogDaemonClientNew(client, opaque);
@@ -606,8 +606,8 @@ virLogDaemonClientNewPostExecRestart(virNetServerClientPtr 
client,
 
 
 static virJSONValuePtr
-virLogDaemonClientPreExecRestart(virNetServerClientPtr client ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED)
+virLogDaemonClientPreExecRestart(virNetServerClientPtr client G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED)
 {
 virJSONValuePtr object = virJSONValueNewObject();
 
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index c7dfa19b5d..9895babc2f 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -63,7 +63,7 @@ virLogDaemonConfigFilePath(bool privileged, char **configfile)
 
 
 virLogDaemonConfigPtr
-virLogDaemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
+virLogDaemonConfigNew(bool privileged G_GNUC_UNUSED)
 {
 virLogDaemonConfigPtr data;
 
diff --git a/src/logging/log_daemon_dispatch.c 
b/src/logging/log_daemon_dispatch.c
index 0442e8cd94..73b5efd5a0 100644
--- a/src/logging/log_daemon_dispatch.c
+++ b/src/logging/log_daemon_dispatch.c
@@ -37,8 +37,8 @@ VIR_LOG_INIT("logging.log_daemon_dispatch");
 #include "log_daemon_dispatch_stubs.h"
 
 static int
-virLogManagerProtocolDispatchDomainOpenLogFile(virNetServerPtr server 
ATTRIBUTE_UNUSED,
-   virNetServerClientPtr client 
ATTRIBUTE_UNUSED,
+virLogManagerProtocolDispatchDomainOpenLogFile(virNetServerPtr server 
G_GNUC_UNUSED,
+   virNetServerClientPtr client 
G_GNUC_UNUSED,
virNetMessagePtr msg,
virNetMessageErrorPtr rerr,

virLogManagerProtocolDomainOpenLogFileArgs *args,
@@ -76,9 +76,9 @@ 
virLogManagerProtocolDispatchDomainOpenLogFile(virNetServerPtr server ATTRIBUTE_
 
 
 static int
-virLogManagerProtocolDispatchDomainGetLogFilePosition(virNetServerPtr server 
ATTRIBUTE_UNUSED,
-  virNetServerClientPtr 
client ATTRIBUTE_UNUSED,
-  virNetMessagePtr msg 
ATTRIBUTE_UNUSED,
+virLogManagerProtocolDispatchDomainGetLogFilePosition(virNetServerPtr server 
G_GNUC_UNUSED,
+  virNetServerClientPtr 
client G_GNUC_UNUSED,
+  virNetMessagePtr msg 
G_GNUC_UNUSED,
   virNetMessageErrorPtr 
rerr,
   
virLogManagerProtocolDomainGetLogFilePositionArgs *args,
   
virLogManagerProtocolDomainGetLogFilePositionRet *ret)
@@ -106

[libvirt] [PATCH 18/35] node_device: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/node_device/node_device_driver.c | 14 +++---
 src/node_device/node_device_hal.c| 18 +-
 src/node_device/node_device_udev.c   | 20 ++--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/node_device/node_device_driver.c 
b/src/node_device/node_device_driver.c
index 578489c5be..f95eacf6a2 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -46,8 +46,8 @@ virNodeDeviceDriverStatePtr driver;
 
 virDrvOpenStatus
 nodeConnectOpen(virConnectPtr conn,
-virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-virConfPtr conf ATTRIBUTE_UNUSED,
+virConnectAuthPtr auth G_GNUC_UNUSED,
+virConfPtr conf G_GNUC_UNUSED,
 unsigned int flags)
 {
 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
@@ -69,27 +69,27 @@ nodeConnectOpen(virConnectPtr conn,
 return VIR_DRV_OPEN_SUCCESS;
 }
 
-int nodeConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED)
+int nodeConnectClose(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 0;
 }
 
 
-int nodeConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
+int nodeConnectIsSecure(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Trivially secure, since always inside the daemon */
 return 1;
 }
 
 
-int nodeConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
+int nodeConnectIsEncrypted(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Not encrypted, but remote driver takes care of that */
 return 0;
 }
 
 
-int nodeConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+int nodeConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 1;
 }
@@ -142,7 +142,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def)
 #else
 /* XXX: Implement me for non-linux */
 static int
-nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED)
+nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def G_GNUC_UNUSED)
 {
 return 0;
 }
diff --git a/src/node_device/node_device_hal.c 
b/src/node_device/node_device_hal.c
index c613ca5808..b046f03c83 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -520,7 +520,7 @@ dev_refresh(const char *udi)
 }
 
 static void
-device_added(LibHalContext *ctx ATTRIBUTE_UNUSED,
+device_added(LibHalContext *ctx G_GNUC_UNUSED,
  const char *udi)
 {
 VIR_DEBUG("%s", hal_name(udi));
@@ -529,7 +529,7 @@ device_added(LibHalContext *ctx ATTRIBUTE_UNUSED,
 
 
 static void
-device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED,
+device_removed(LibHalContext *ctx G_GNUC_UNUSED,
const char *udi)
 {
 const char *name = hal_name(udi);
@@ -565,7 +565,7 @@ device_cap_added(LibHalContext *ctx,
 
 
 static void
-device_cap_lost(LibHalContext *ctx ATTRIBUTE_UNUSED,
+device_cap_lost(LibHalContext *ctx G_GNUC_UNUSED,
 const char *udi,
 const char *cap)
 {
@@ -577,11 +577,11 @@ device_cap_lost(LibHalContext *ctx ATTRIBUTE_UNUSED,
 
 
 static void
-device_prop_modified(LibHalContext *ctx ATTRIBUTE_UNUSED,
+device_prop_modified(LibHalContext *ctx G_GNUC_UNUSED,
  const char *udi,
  const char *key,
- dbus_bool_t is_removed ATTRIBUTE_UNUSED,
- dbus_bool_t is_added ATTRIBUTE_UNUSED)
+ dbus_bool_t is_removed G_GNUC_UNUSED,
+ dbus_bool_t is_added G_GNUC_UNUSED)
 {
 const char *name = hal_name(udi);
 VIR_DEBUG("%s %s", name, key);
@@ -591,9 +591,9 @@ device_prop_modified(LibHalContext *ctx ATTRIBUTE_UNUSED,
 
 
 static int
-nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
-virStateInhibitCallback callback ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED)
+nodeStateInitialize(bool privileged G_GNUC_UNUSED,
+virStateInhibitCallback callback G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED)
 {
 LibHalContext *hal_ctx = NULL;
 char **udi = NULL;
diff --git a/src/node_device/node_device_udev.c 
b/src/node_device/node_device_udev.c
index 5550ee3a54..80d39e9509 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -606,7 +606,7 @@ udevProcessNetworkInterface(struct udev_device *device,
 
 
 static int
-udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
+udevProcessSCSIHost(struct udev_device *device G_GNUC_UNUSED,
 virNodeDeviceDefPtr def)
 {
 virNodeDevCapSCSIHostPtr scsi_host = &def->caps->data.scsi_host;
@@ -654,7 +654,7 @@ udevProcessSCSITarget(struct udev_device *device,
 
 
 static int
-udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED,
+udevGetSCSIType(virNodeDeviceDefPtr def G_GNUC_UNUSED,
 unsigned int type,
 char **typestring)
 {
@@ -714,7 +714,7 @@ udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED

[libvirt] [PATCH 24/35] security: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/security/security_apparmor.c |  88 
 src/security/security_dac.c  | 114 ++--
 src/security/security_manager.c  |   6 +-
 src/security/security_nop.c  | 174 +++
 src/security/security_selinux.c  |  54 +-
 src/security/security_stack.c|   8 +-
 src/security/security_util.c |   6 +-
 src/security/virt-aa-helper.c|   4 +-
 8 files changed, 227 insertions(+), 227 deletions(-)

diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 77eee9410c..da4aa3c24d 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -163,7 +163,7 @@ profile_status_file(const char *str)
  * load (add) a profile. Will create one if necessary
  */
 static int
-load_profile(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
+load_profile(virSecurityManagerPtr mgr G_GNUC_UNUSED,
  const char *profile,
  virDomainDefPtr def,
  const char *fn,
@@ -321,28 +321,28 @@ AppArmorSetSecurityHostdevLabelHelper(const char *file, 
void *opaque)
 }
 
 static int
-AppArmorSetSecurityUSBLabel(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
+AppArmorSetSecurityUSBLabel(virUSBDevicePtr dev G_GNUC_UNUSED,
 const char *file, void *opaque)
 {
 return AppArmorSetSecurityHostdevLabelHelper(file, opaque);
 }
 
 static int
-AppArmorSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
+AppArmorSetSecurityPCILabel(virPCIDevicePtr dev G_GNUC_UNUSED,
 const char *file, void *opaque)
 {
 return AppArmorSetSecurityHostdevLabelHelper(file, opaque);
 }
 
 static int
-AppArmorSetSecuritySCSILabel(virSCSIDevicePtr dev ATTRIBUTE_UNUSED,
+AppArmorSetSecuritySCSILabel(virSCSIDevicePtr dev G_GNUC_UNUSED,
  const char *file, void *opaque)
 {
 return AppArmorSetSecurityHostdevLabelHelper(file, opaque);
 }
 
 static int
-AppArmorSetSecurityHostLabel(virSCSIVHostDevicePtr dev ATTRIBUTE_UNUSED,
+AppArmorSetSecurityHostLabel(virSCSIVHostDevicePtr dev G_GNUC_UNUSED,
  const char *file, void *opaque)
 {
 return AppArmorSetSecurityHostdevLabelHelper(file, opaque);
@@ -350,7 +350,7 @@ AppArmorSetSecurityHostLabel(virSCSIVHostDevicePtr dev 
ATTRIBUTE_UNUSED,
 
 /* Called on libvirtd startup to see if AppArmor is available */
 static int
-AppArmorSecurityManagerProbe(const char *virtDriver ATTRIBUTE_UNUSED)
+AppArmorSecurityManagerProbe(const char *virtDriver G_GNUC_UNUSED)
 {
 char *template_qemu = NULL;
 char *template_lxc = NULL;
@@ -391,25 +391,25 @@ AppArmorSecurityManagerProbe(const char *virtDriver 
ATTRIBUTE_UNUSED)
  * currently not used.
  */
 static int
-AppArmorSecurityManagerOpen(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
+AppArmorSecurityManagerOpen(virSecurityManagerPtr mgr G_GNUC_UNUSED)
 {
 return 0;
 }
 
 static int
-AppArmorSecurityManagerClose(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
+AppArmorSecurityManagerClose(virSecurityManagerPtr mgr G_GNUC_UNUSED)
 {
 return 0;
 }
 
 static const char *
-AppArmorSecurityManagerGetModel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
+AppArmorSecurityManagerGetModel(virSecurityManagerPtr mgr G_GNUC_UNUSED)
 {
 return SECURITY_APPARMOR_NAME;
 }
 
 static const char *
-AppArmorSecurityManagerGetDOI(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
+AppArmorSecurityManagerGetDOI(virSecurityManagerPtr mgr G_GNUC_UNUSED)
 {
 return SECURITY_APPARMOR_VOID_DOI;
 }
@@ -421,7 +421,7 @@ AppArmorSecurityManagerGetDOI(virSecurityManagerPtr mgr 
ATTRIBUTE_UNUSED)
  * called on shutdown.
 */
 static int
-AppArmorGenSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
+AppArmorGenSecurityLabel(virSecurityManagerPtr mgr G_GNUC_UNUSED,
  virDomainDefPtr def)
 {
 int rc = -1;
@@ -488,7 +488,7 @@ static int
 AppArmorSetSecurityAllLabel(virSecurityManagerPtr mgr,
 virDomainDefPtr def,
 const char *stdin_path,
-bool chardevStdioLogd ATTRIBUTE_UNUSED)
+bool chardevStdioLogd G_GNUC_UNUSED)
 {
 virSecurityLabelDefPtr secdef = virDomainDefGetSecurityLabelDef(def,
 SECURITY_APPARMOR_NAME);
@@ -507,9 +507,9 @@ AppArmorSetSecurityAllLabel(virSecurityManagerPtr mgr,
  * running.
  */
 static int
-AppArmorGetSecurityProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
+AppArmorGetSecurityProcessLabel(virSecurityManagerPtr mgr G_GNUC_UNUSED,
 virDomainDefPtr def,
-pid_t pid ATTRIBUTE_UNUSED,
+pid_t pid G_GNUC_UNUSED,
 virSecurityLabelPtr sec)
 {
 int rc = -1;
@@ -547,7 +547,7 @@ AppArmorGetSecurityProcessLabel(virSecurityMan

[libvirt] [PATCH 30/35] vbox: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/vbox/vbox_MSCOMGlue.c | 100 +++---
 src/vbox/vbox_common.c|  38 +++
 src/vbox/vbox_driver.c|   4 +-
 src/vbox/vbox_storage.c   |   4 +-
 src/vbox/vbox_tmpl.c  |  92 +--
 5 files changed, 119 insertions(+), 119 deletions(-)

diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c
index 7208d73b53..db000385bc 100644
--- a/src/vbox/vbox_MSCOMGlue.c
+++ b/src/vbox/vbox_MSCOMGlue.c
@@ -99,45 +99,45 @@ static ISession *vboxSession;
  */
 
 static nsresult __stdcall
-vboxSupports_QueryInterface(nsISupports *pThis ATTRIBUTE_UNUSED,
-const nsID *iid ATTRIBUTE_UNUSED,
-void **resultp ATTRIBUTE_UNUSED)
+vboxSupports_QueryInterface(nsISupports *pThis G_GNUC_UNUSED,
+const nsID *iid G_GNUC_UNUSED,
+void **resultp G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxSupports_AddRef(nsISupports *pThis ATTRIBUTE_UNUSED)
+vboxSupports_AddRef(nsISupports *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxSupports_Release(nsISupports *pThis ATTRIBUTE_UNUSED)
+vboxSupports_Release(nsISupports *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxSupports_GetTypeInfoCount(nsISupports *pThis ATTRIBUTE_UNUSED)
+vboxSupports_GetTypeInfoCount(nsISupports *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxSupports_GetTypeInfo(nsISupports *pThis ATTRIBUTE_UNUSED)
+vboxSupports_GetTypeInfo(nsISupports *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxSupports_GetIDsOfNames(nsISupports *pThis ATTRIBUTE_UNUSED)
+vboxSupports_GetIDsOfNames(nsISupports *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxSupports_Invoke(nsISupports *pThis ATTRIBUTE_UNUSED)
+vboxSupports_Invoke(nsISupports *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -149,15 +149,15 @@ vboxSupports_Invoke(nsISupports *pThis ATTRIBUTE_UNUSED)
  */
 
 static nsresult __stdcall
-vboxEventTarget_PostEvent(nsIEventTarget *pThis ATTRIBUTE_UNUSED,
-  PLEvent *aEvent ATTRIBUTE_UNUSED)
+vboxEventTarget_PostEvent(nsIEventTarget *pThis G_GNUC_UNUSED,
+  PLEvent *aEvent G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxEventTarget_IsOnCurrentThread(nsIEventTarget *pThis ATTRIBUTE_UNUSED,
-  PRBool *_retval ATTRIBUTE_UNUSED)
+vboxEventTarget_IsOnCurrentThread(nsIEventTarget *pThis G_GNUC_UNUSED,
+  PRBool *_retval G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -169,133 +169,133 @@ vboxEventTarget_IsOnCurrentThread(nsIEventTarget *pThis 
ATTRIBUTE_UNUSED,
  */
 
 static nsresult __stdcall
-vboxEventQueue_InitEvent(nsIEventQueue *pThis ATTRIBUTE_UNUSED,
- PLEvent *aEvent ATTRIBUTE_UNUSED,
- void *owner ATTRIBUTE_UNUSED,
- PLHandleEventProc handler ATTRIBUTE_UNUSED,
- PLDestroyEventProc destructor ATTRIBUTE_UNUSED)
+vboxEventQueue_InitEvent(nsIEventQueue *pThis G_GNUC_UNUSED,
+ PLEvent *aEvent G_GNUC_UNUSED,
+ void *owner G_GNUC_UNUSED,
+ PLHandleEventProc handler G_GNUC_UNUSED,
+ PLDestroyEventProc destructor G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxEventQueue_PostSynchronousEvent(nsIEventQueue *pThis ATTRIBUTE_UNUSED,
-PLEvent *aEvent ATTRIBUTE_UNUSED,
-void **aResult ATTRIBUTE_UNUSED)
+vboxEventQueue_PostSynchronousEvent(nsIEventQueue *pThis G_GNUC_UNUSED,
+PLEvent *aEvent G_GNUC_UNUSED,
+void **aResult G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxEventQueue_PendingEvents(nsIEventQueue *pThis ATTRIBUTE_UNUSED,
- PRBool *_retval ATTRIBUTE_UNUSED)
+vboxEventQueue_PendingEvents(nsIEventQueue *pThis G_GNUC_UNUSED,
+ PRBool *_retval G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxEventQueue_ProcessPendingEvents(nsIEventQueue *pThis ATTRIBUTE_UNUSED)
+vboxEventQueue_ProcessPendingEvents(nsIEventQueue *pThis G_GNUC_UNUSED)
 {
 return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static nsresult __stdcall
-vboxEventQueue_EventLoop(nsIEventQueue *pThis ATTRIBUTE_UNUSED)
+vboxEventQueue_EventLoop(nsIEventQueue *pT

[libvirt] [PATCH 04/35] use G_GNUC_NULL_TERMINATED instead of ATTRIBUTE_SENTINEL

2019-10-14 Thread Ján Tomko
Prefer G_GNUC_NULL_TERMINATED which was introduced in GLib 2.8.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_agent.c| 2 +-
 src/qemu/qemu_monitor_json.c | 2 +-
 src/util/virbuffer.h | 2 +-
 src/util/vircommand.h| 4 ++--
 src/util/virfile.h   | 2 +-
 src/util/virfirewall.h   | 4 ++--
 src/util/virjson.h   | 4 ++--
 src/util/virtypedparam.h | 2 +-
 src/vz/vz_utils.h| 2 +-
 tests/domaincapstest.c   | 2 +-
 tests/qemumonitortestutils.h | 2 +-
 tests/testutils.h| 4 ++--
 12 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 0ef8b563f5..62edb665a7 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1159,7 +1159,7 @@ qemuAgentCommand(qemuAgentPtr mon,
 return ret;
 }
 
-static virJSONValuePtr ATTRIBUTE_SENTINEL
+static virJSONValuePtr G_GNUC_NULL_TERMINATED
 qemuAgentMakeCommand(const char *cmdname,
  ...)
 {
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index dbc32acb5e..6818e726c6 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -557,7 +557,7 @@ qemuMonitorJSONMakeCommandInternal(const char *cmdname,
 }
 
 
-static virJSONValuePtr ATTRIBUTE_SENTINEL
+static virJSONValuePtr G_GNUC_NULL_TERMINATED
 qemuMonitorJSONMakeCommand(const char *cmdname,
...)
 {
diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h
index d5a7a8dc33..75e26c32ff 100644
--- a/src/util/virbuffer.h
+++ b/src/util/virbuffer.h
@@ -77,7 +77,7 @@ void virBufferAsprintf(virBufferPtr buf, const char *format, 
...)
 void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap)
   ATTRIBUTE_FMT_PRINTF(2, 0);
 void virBufferStrcat(virBufferPtr buf, ...)
-  ATTRIBUTE_SENTINEL;
+  G_GNUC_NULL_TERMINATED;
 void virBufferStrcatVArgs(virBufferPtr buf, va_list ap);
 
 void virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index 1a7158d4c1..632d02bc71 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -42,7 +42,7 @@ virCommandPtr virCommandNew(const char *binary) 
ATTRIBUTE_NONNULL(1);
 virCommandPtr virCommandNewArgs(const char *const*args) ATTRIBUTE_NONNULL(1);
 
 virCommandPtr virCommandNewArgList(const char *binary, ...)
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
+ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED;
 
 virCommandPtr virCommandNewVAList(const char *binary, va_list list)
 ATTRIBUTE_NONNULL(1);
@@ -137,7 +137,7 @@ void virCommandAddArgSet(virCommandPtr cmd,
 
 void virCommandAddArgList(virCommandPtr cmd,
   ... /* const char *arg, ..., NULL */)
-ATTRIBUTE_SENTINEL;
+G_GNUC_NULL_TERMINATED;
 
 void virCommandSetWorkingDirectory(virCommandPtr cmd,
const char *pwd) ATTRIBUTE_NONNULL(2);
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 2b037b00aa..f22380550c 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -317,7 +317,7 @@ char *virFileFindMountPoint(const char *type);
 /* NB: this should be combined with virFileBuildPath */
 #define virBuildPath(path, ...) \
 virBuildPathInternal(path, __VA_ARGS__, NULL)
-int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
+int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED;
 
 int virFilePrintf(FILE *fp, const char *msg, ...)
 ATTRIBUTE_FMT_PRINTF(2, 3);
diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h
index ff4626975b..a2c0e9c26d 100644
--- a/src/util/virfirewall.h
+++ b/src/util/virfirewall.h
@@ -65,7 +65,7 @@ virFirewallRulePtr virFirewallAddRuleFull(virFirewallPtr 
firewall,
   virFirewallQueryCallback cb,
   void *opaque,
   ...)
-ATTRIBUTE_SENTINEL;
+G_GNUC_NULL_TERMINATED;
 
 void virFirewallRemoveRule(virFirewallPtr firewall,
virFirewallRulePtr rule);
@@ -88,7 +88,7 @@ void virFirewallRuleAddArgSet(virFirewallPtr firewall,
 void virFirewallRuleAddArgList(virFirewallPtr firewall,
virFirewallRulePtr rule,
...)
-ATTRIBUTE_SENTINEL;
+G_GNUC_NULL_TERMINATED;
 
 size_t virFirewallRuleGetArgCount(virFirewallRulePtr rule);
 
diff --git a/src/util/virjson.h b/src/util/virjson.h
index a5f959595f..65b8d5620a 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -48,11 +48,11 @@ void virJSONValueHashFree(void *opaque, const void *name);
 virJSONType virJSONValueGetType(const virJSONValue *value);
 
 int virJSONValueObjectCreate(virJSONValuePtr *obj, ...)
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
+ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED;
 int virJSONValueObjectCreateVArgs(virJSONValuePtr *obj, va_list args)
 ATTRIBUTE_NONNULL(1);
 int virJSONValueObjectAdd(virJSONValu

[libvirt] [PATCH 20/35] openvz: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/openvz/openvz_driver.c | 92 +++---
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 98db7fceec..408b393e30 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -112,10 +112,10 @@ openvzDomObjFromDomain(struct openvz_driver *driver,
 
 static int
 openvzDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- unsigned int parseFlags ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED,
- void *parseOpaque ATTRIBUTE_UNUSED)
+ virCapsPtr caps G_GNUC_UNUSED,
+ unsigned int parseFlags G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED,
+ void *parseOpaque G_GNUC_UNUSED)
 {
 /* fill the init path */
 if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
@@ -129,11 +129,11 @@ openvzDomainDefPostParse(virDomainDefPtr def,
 
 static int
 openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
-   const virDomainDef *def ATTRIBUTE_UNUSED,
-   virCapsPtr caps ATTRIBUTE_UNUSED,
-   unsigned int parseFlags ATTRIBUTE_UNUSED,
-   void *opaque ATTRIBUTE_UNUSED,
-   void *parseOpaque ATTRIBUTE_UNUSED)
+   const virDomainDef *def G_GNUC_UNUSED,
+   virCapsPtr caps G_GNUC_UNUSED,
+   unsigned int parseFlags G_GNUC_UNUSED,
+   void *opaque G_GNUC_UNUSED,
+   void *parseOpaque G_GNUC_UNUSED)
 {
 if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
 dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
@@ -358,7 +358,7 @@ static int openvzConnectGetVersion(virConnectPtr conn, 
unsigned long *version)
 }
 
 
-static char *openvzConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
+static char *openvzConnectGetHostname(virConnectPtr conn G_GNUC_UNUSED)
 {
 return virGetHostname();
 }
@@ -509,7 +509,7 @@ static int openvzDomainIsPersistent(virDomainPtr dom)
 return ret;
 }
 
-static int openvzDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED)
+static int openvzDomainIsUpdated(virDomainPtr dom G_GNUC_UNUSED)
 {
 return 0;
 }
@@ -1209,7 +1209,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
 return ret;
 }
 
-static int openvzConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
+static int openvzConnectGetMaxVcpus(virConnectPtr conn G_GNUC_UNUSED,
 const char *type)
 {
 if (type == NULL || STRCASEEQ(type, "openvz"))
@@ -1221,7 +1221,7 @@ static int openvzConnectGetMaxVcpus(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 }
 
 static int
-openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
+openvzDomainGetVcpusFlags(virDomainPtr dom G_GNUC_UNUSED,
   unsigned int flags)
 {
 if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
@@ -1322,8 +1322,8 @@ openvzConnectURIProbe(char **uri)
 
 
 static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
-  virConnectAuthPtr auth 
ATTRIBUTE_UNUSED,
-  virConfPtr conf ATTRIBUTE_UNUSED,
+  virConnectAuthPtr auth G_GNUC_UNUSED,
+  virConfPtr conf G_GNUC_UNUSED,
   unsigned int flags)
 {
 struct openvz_driver *driver;
@@ -1391,24 +1391,24 @@ static int openvzConnectClose(virConnectPtr conn)
 return 0;
 }
 
-static const char *openvzConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED) {
+static const char *openvzConnectGetType(virConnectPtr conn G_GNUC_UNUSED) {
 return "OpenVZ";
 }
 
-static int openvzConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int openvzConnectIsEncrypted(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Encryption is not relevant / applicable to way we talk to openvz */
 return 0;
 }
 
-static int openvzConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int openvzConnectIsSecure(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* We run CLI tools directly so this is secure */
 return 1;
 }
 
 static int
-openvzConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+openvzConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 1;
 }
@@ -1424,7 +1424,7 @@ static char *openvzConnectGetCapabilities(virConnectPtr 
conn) {
 return ret;
 }
 
-static int openvzConnectListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
+static int openvzConnectListDomains(virConnectPtr conn G_GNUC_UNUSED,

[libvirt] [PATCH 09/35] bhyve: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/bhyve/bhyve_command.c   |  6 +++---
 src/bhyve/bhyve_device.c|  4 ++--
 src/bhyve/bhyve_domain.c| 26 +-
 src/bhyve/bhyve_driver.c| 16 
 src/bhyve/bhyve_monitor.c   |  2 +-
 src/bhyve/bhyve_parse_command.c |  8 
 src/bhyve/bhyve_process.c   |  2 +-
 7 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 219e2b8d9e..912cf99683 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -286,7 +286,7 @@ bhyveBuildUSBControllerArgStr(const virDomainDef *def,
 }
 
 static int
-bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
+bhyveBuildVirtIODiskArgStr(const virDomainDef *def G_GNUC_UNUSED,
  virDomainDiskDefPtr disk,
  virCommandPtr cmd)
 {
@@ -319,7 +319,7 @@ bhyveBuildVirtIODiskArgStr(const virDomainDef *def 
ATTRIBUTE_UNUSED,
 }
 
 static int
-bhyveBuildLPCArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
+bhyveBuildLPCArgStr(const virDomainDef *def G_GNUC_UNUSED,
 virCommandPtr cmd)
 {
 virCommandAddArgList(cmd, "-s", "1,lpc", NULL);
@@ -643,7 +643,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
 }
 
 virCommandPtr
-virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
+virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver G_GNUC_UNUSED,
virDomainDefPtr def)
 {
 virCommandPtr cmd = virCommandNew(BHYVECTL);
diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 201044d9e6..4913be8422 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -31,8 +31,8 @@
 VIR_LOG_INIT("bhyve.bhyve_device");
 
 static int
-bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
-   virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
+bhyveCollectPCIAddress(virDomainDefPtr def G_GNUC_UNUSED,
+   virDomainDeviceDefPtr device G_GNUC_UNUSED,
virDomainDeviceInfoPtr info,
void *opaque)
 {
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index ed281d7c68..bc506bad66 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -32,7 +32,7 @@
 VIR_LOG_INIT("bhyve.bhyve_domain");
 
 static void *
-bhyveDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
+bhyveDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
 {
 bhyveDomainObjPrivatePtr priv;
 
@@ -74,10 +74,10 @@ bhyveDomainDefNeedsISAController(virDomainDefPtr def)
 
 static int
 bhyveDomainDefPostParse(virDomainDefPtr def,
-virCapsPtr caps ATTRIBUTE_UNUSED,
-unsigned int parseFlags ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED,
-void *parseOpaque ATTRIBUTE_UNUSED)
+virCapsPtr caps G_GNUC_UNUSED,
+unsigned int parseFlags G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED,
+void *parseOpaque G_GNUC_UNUSED)
 {
 /* Add an implicit PCI root controller */
 if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
@@ -90,7 +90,7 @@ bhyveDomainDefPostParse(virDomainDefPtr def,
 static int
 bhyveDomainDiskDefAssignAddress(bhyveConnPtr driver,
 virDomainDiskDefPtr def,
-const virDomainDef *vmdef ATTRIBUTE_UNUSED)
+const virDomainDef *vmdef G_GNUC_UNUSED)
 {
 int idx = virDiskNameToIndex(def->dst);
 
@@ -122,10 +122,10 @@ bhyveDomainDiskDefAssignAddress(bhyveConnPtr driver,
 static int
 bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
   const virDomainDef *def,
-  virCapsPtr caps ATTRIBUTE_UNUSED,
-  unsigned int parseFlags ATTRIBUTE_UNUSED,
+  virCapsPtr caps G_GNUC_UNUSED,
+  unsigned int parseFlags G_GNUC_UNUSED,
   void *opaque,
-  void *parseOpaque ATTRIBUTE_UNUSED)
+  void *parseOpaque G_GNUC_UNUSED)
 {
 bhyveConnPtr driver = opaque;
 
@@ -156,10 +156,10 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
 
 static int
 bhyveDomainDefAssignAddresses(virDomainDef *def,
-  virCapsPtr caps ATTRIBUTE_UNUSED,
-  unsigned int parseFlags ATTRIBUTE_UNUSED,
-  void *opaque ATTRIBUTE_UNUSED,
-  void *parseOpaque ATTRIBUTE_UNUSED)
+  virCapsPtr caps G_GNUC_UNUSED,
+  unsigned int parseFlags G_GNUC_UNUSED,
+  void *opaque

[libvirt] [PATCH 00/35] Use more of GLib's macros

2019-10-14 Thread Ján Tomko
We do not need to define MIN and MAX if we include glib.h
and it also provides some macros for __attribute__'s

Ján Tomko (35):
  util: remove MIN and MAX macros
  apibuild: ignore GLib macros too
  use G_GNUC_NORETURN instead of ATTRIBUTE_NORETURN
  use G_GNUC_NULL_TERMINATED instead of ATTRIBUTE_SENTINEL
  Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK
  examples: use G_GNUC_UNUSED
  access: use G_GNUC_UNUSED
  admin: use G_GNUC_UNUSED
  bhyve: use G_GNUC_UNUSED
  conf: use G_GNUC_UNUSED
  cpu: use G_GNUC_UNUSED
  esx: use G_GNUC_UNUSED
  libxl: use G_GNUC_UNUSED
  locking: use G_GNUC_UNUSED
  logging: use G_GNUC_UNUSED
  lxc: use G_GNUC_UNUSED
  network: use G_GNUC_UNUSED
  node_device: use G_GNUC_UNUSED
  nwfilter: use G_GNUC_UNUSED
  openvz: use G_GNUC_UNUSED
  qemu: use G_GNUC_UNUSED
  remote: use G_GNUC_UNUSED
  rpc: use G_GNUC_UNUSED
  security: use G_GNUC_UNUSED
  storage: use G_GNUC_UNUSED
  test: use G_GNUC_UNUSED
  tests: use G_GNUC_UNUSED
  tools: use G_GNUC_UNUSED
  util: use G_GNUC_UNUSED
  vbox: use G_GNUC_UNUSED
  vz: use G_GNUC_UNUSED
  Use G_GNUC_UNUSED everywhere
  syntax-check: check for G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED
  gendispatch: generate G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED
  internal: remove no longer used ATTRIBUTE macros

 build-aux/syntax-check.mk |  12 +-
 docs/apibuild.py  |   4 +-
 examples/c/misc/event-test.c  | 140 +++
 src/access/viraccessdrivernop.c   |  90 ++---
 src/access/viraccessdriverpolkit.c|   4 +-
 src/admin/admin_remote.c  |   4 +-
 src/admin/admin_server_dispatch.c |  62 +--
 src/bhyve/bhyve_command.c |   6 +-
 src/bhyve/bhyve_device.c  |   4 +-
 src/bhyve/bhyve_domain.c  |  26 +-
 src/bhyve/bhyve_driver.c  |  16 +-
 src/bhyve/bhyve_monitor.c |   2 +-
 src/bhyve/bhyve_parse_command.c   |   8 +-
 src/bhyve/bhyve_process.c |   2 +-
 src/conf/capabilities.c   |   6 +-
 src/conf/device_conf.h|   2 +-
 src/conf/domain_addr.c|  22 +-
 src/conf/domain_audit.c   |   2 +-
 src/conf/domain_capabilities.c|   2 +-
 src/conf/domain_conf.c|  30 +-
 src/conf/domain_conf.h|  38 +-
 src/conf/domain_event.c   |   2 +-
 src/conf/netdev_bandwidth_conf.h  |   2 +-
 src/conf/network_conf.c   |  80 ++--
 src/conf/node_device_conf.c   |  10 +-
 src/conf/nwfilter_conf.c  |  50 +--
 src/conf/nwfilter_params.c|   2 +-
 src/conf/object_event.c   |   2 +-
 src/conf/virchrdev.c  |  10 +-
 src/conf/virdomaincheckpointobjlist.c |   2 +-
 src/conf/virdomainmomentobjlist.c |   6 +-
 src/conf/virdomainobjlist.c   |  12 +-
 src/conf/virinterfaceobj.c|  10 +-
 src/conf/virnetworkobj.c  |  18 +-
 src/conf/virnetworkobj.h  |   2 +-
 src/conf/virnodedeviceobj.c   |  16 +-
 src/conf/virnwfilterbindingobjlist.c  |   4 +-
 src/conf/virsecretobj.c   |   8 +-
 src/conf/virstorageobj.c  |  22 +-
 src/cpu/cpu_arm.c |  14 +-
 src/cpu/cpu_ppc64.c   |  10 +-
 src/cpu/cpu_s390.c|   6 +-
 src/cpu/cpu_x86.c |   4 +-
 src/driver.h  |  18 +-
 src/esx/esx_driver.c  |  32 +-
 src/esx/esx_interface_driver.c|  10 +-
 src/esx/esx_network_driver.c  |  16 +-
 src/esx/esx_storage_backend_iscsi.c   |  16 +-
 src/esx/esx_storage_driver.c  |  16 +-
 src/esx/esx_vi.c  |  20 +-
 src/esx/esx_vi_types.c|   4 +-
 src/hyperv/hyperv_driver.c|  12 +-
 src/hyperv/hyperv_wmi.c   |   2 +-
 src/interface/interface_backend_netcf.c   |  16 +-
 src/interface/interface_backend_udev.c|  26 +-
 src/internal.h|  31 --
 src/libvirt.c |   8 +-
 src/libxl/libxl_conf.h|   2 +-
 src/libxl/libxl_domain.c  |  26 +-
 src/libxl/libxl_domain.h  |   4 +-
 src/libxl/libxl_driver.c  |  70 ++--
 src/libxl/libxl_logger.c  |  14 +-
 src/libxl/libxl_migration.c   |  12 +-
 src/locking/lock_daemon.c |  20 +-
 src/locking/lock_daemon_config.c  |   2 +-
 src/locking/lock_daemon_dispatch.c|  32 +-
 src/locking/lock_driver_lockd.c   |   8 +-
 src/locking/lock_driver_nop.c |  48 +--
 src/locking/lock_driver_sanlock.c |  10 +-
 src/locking/lock_manager.c|  10 +-
 src/locking/sanlock_helper.c

[libvirt] [PATCH 03/35] use G_GNUC_NORETURN instead of ATTRIBUTE_NORETURN

2019-10-14 Thread Ján Tomko
Remove all usage of ATTRIBUTE_NORETURN in favor of GLib's
G_GNUC_NORETURN.

Signed-off-by: Ján Tomko 
---
 src/lxc/lxc_container.c| 2 +-
 src/network/leaseshelper.c | 2 +-
 src/util/iohelper.c| 2 +-
 src/util/virprocess.c  | 2 +-
 src/util/virprocess.h  | 2 +-
 tests/eventtest.c  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 905645a41c..97f9055506 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -116,7 +116,7 @@ static int lxcContainerMountFSBlock(virDomainFSDefPtr fs,
  * in a child pid namespace if container reboot support exists.
  * Otherwise, it will either succeed or return -EPERM.
  */
-ATTRIBUTE_NORETURN static int
+G_GNUC_NORETURN static int
 lxcContainerRebootChild(void *argv)
 {
 int *cmd = argv;
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index 46482ad3ce..dc737879ca 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -47,7 +47,7 @@ helperVersion(const char *argv0)
 printf("%s (%s) %s\n", argv0, PACKAGE_NAME, PACKAGE_VERSION);
 }
 
-ATTRIBUTE_NORETURN static void
+G_GNUC_NORETURN static void
 usage(int status)
 {
 if (status) {
diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index f3d45b9c03..3dc0488b26 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -175,7 +175,7 @@ runIO(const char *path, int fd, int oflags)
 
 static const char *program_name;
 
-ATTRIBUTE_NORETURN static void
+G_GNUC_NORETURN static void
 usage(int status)
 {
 if (status) {
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index b1544af730..0fa648ce74 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1214,7 +1214,7 @@ virProcessSetupPrivateMountNS(void)
 #endif /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */
 
 #if defined(__linux__)
-ATTRIBUTE_NORETURN static int
+G_GNUC_NORETURN static int
 virProcessDummyChild(void *argv ATTRIBUTE_UNUSED)
 {
 _exit(0);
diff --git a/src/util/virprocess.h b/src/util/virprocess.h
index 4806c592da..8e2af33c7d 100644
--- a/src/util/virprocess.h
+++ b/src/util/virprocess.h
@@ -46,7 +46,7 @@ virProcessTranslateStatus(int status);
 void
 virProcessAbort(pid_t pid);
 
-void virProcessExitWithStatus(int status) ATTRIBUTE_NORETURN;
+void virProcessExitWithStatus(int status) G_GNUC_NORETURN;
 
 int
 virProcessWait(pid_t pid, int *exitstatus, bool raw)
diff --git a/tests/eventtest.c b/tests/eventtest.c
index f04b416ad2..2a6edc7461 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -158,7 +158,7 @@ static pthread_cond_t eventThreadJobCond = 
PTHREAD_COND_INITIALIZER;
 static int eventThreadJobDone;
 
 
-ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
+G_GNUC_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
 while (1) {
 pthread_mutex_lock(&eventThreadMutex);
 while (!eventThreadRunOnce)
-- 
2.19.2

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

[libvirt] [PATCH 33/35] syntax-check: check for G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED

2019-10-14 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 build-aux/syntax-check.mk | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index f4712c24c3..c220dadd6c 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -370,7 +370,7 @@ sc_flags_usage:
  | $(GREP) -c '\(long\|unsigned\) flags')" != 4 && \
  { echo '$(ME): new API should use "unsigned int flags"' 1>&2; \
exit 1; } || :
-   @prohibit=' flags ATTRIBUTE_UNUSED' \
+   @prohibit=' flags G_GNUC_UNUSED' \
exclude='virSecurityDomainImageLabelFlags' \
halt='flags should be checked with virCheckFlags' \
  $(_sc_search_regexp)
@@ -620,12 +620,12 @@ sc_prohibit_return_as_function:
halt='avoid extra () with return statements' \
  $(_sc_search_regexp)
 
-# ATTRIBUTE_UNUSED should only be applied in implementations, not
+# G_GNUC_UNUSED should only be applied in implementations, not
 # header declarations
-sc_avoid_attribute_unused_in_header:
-   @prohibit='^[^#]*ATTRIBUTE_UNUSED([^:]|$$)' \
+sc_avoid_g_gnuc_unused_in_header:
+   @prohibit='^[^#]*G_GNUC_UNUSED([^:]|$$)' \
in_vc_files='\.h$$' \
-   halt='use ATTRIBUTE_UNUSED in .c rather than .h files' \
+   halt='use G_GNUC_UNUSED in .c rather than .h files' \
  $(_sc_search_regexp)
 
 sc_prohibit_int_index:
@@ -2295,7 +2295,7 @@ exclude_file_name_regexp--sc_prohibit_int_ijk = \
 exclude_file_name_regexp--sc_prohibit_unsigned_pid = \
   
^(include/libvirt/.*\.h|src/(qemu/qemu_driver\.c|driver-hypervisor\.h|libvirt(-[a-z]*)?\.c|.*\.x|util/vir(polkit|systemd)\.c)|tests/virpolkittest\.c|tools/virsh-domain\.c)$$
 
-exclude_file_name_regexp--sc_avoid_attribute_unused_in_header = \
+exclude_file_name_regexp--sc_avoid_g_gnuc_unused_in_header = \
   ^(src/util/virlog\.h|src/network/bridge_driver\.h)$$
 
 exclude_file_name_regexp--sc_prohibit_mixed_case_abbreviations = \
-- 
2.19.2

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

[libvirt] [PATCH 32/35] Use G_GNUC_UNUSED everywhere

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/hyperv/hyperv_driver.c  | 12 -
 src/hyperv/hyperv_wmi.c |  2 +-
 src/interface/interface_backend_netcf.c | 16 ++--
 src/interface/interface_backend_udev.c  | 20 +++
 src/libvirt.c   |  8 +++---
 src/phyp/phyp_driver.c  | 34 -
 src/secret/secret_driver.c  | 16 ++--
 src/vmware/vmware_conf.c|  2 +-
 src/vmware/vmware_driver.c  | 32 +++
 src/vmx/vmx.c   | 24 -
 10 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index ceaf528dd3..4e99721d37 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -118,7 +118,7 @@ hypervInitConnection(virConnectPtr conn, hypervPrivate 
*priv,
 
 static virDrvOpenStatus
 hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
-  virConfPtr conf ATTRIBUTE_UNUSED,
+  virConfPtr conf G_GNUC_UNUSED,
   unsigned int flags)
 {
 virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
@@ -194,7 +194,7 @@ hypervConnectClose(virConnectPtr conn)
 
 
 static const char *
-hypervConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED)
+hypervConnectGetType(virConnectPtr conn G_GNUC_UNUSED)
 {
 return "Hyper-V";
 }
@@ -598,7 +598,7 @@ hypervDomainDestroy(virDomainPtr domain)
 
 
 static char *
-hypervDomainGetOSType(virDomainPtr domain ATTRIBUTE_UNUSED)
+hypervDomainGetOSType(virDomainPtr domain G_GNUC_UNUSED)
 {
 char *osType;
 
@@ -1100,7 +1100,7 @@ hypervDomainIsActive(virDomainPtr domain)
 
 
 static int
-hypervDomainIsPersistent(virDomainPtr domain ATTRIBUTE_UNUSED)
+hypervDomainIsPersistent(virDomainPtr domain G_GNUC_UNUSED)
 {
 /* Hyper-V has no concept of transient domains, so all of them are 
persistent */
 return 1;
@@ -1109,7 +1109,7 @@ hypervDomainIsPersistent(virDomainPtr domain 
ATTRIBUTE_UNUSED)
 
 
 static int
-hypervDomainIsUpdated(virDomainPtr domain ATTRIBUTE_UNUSED)
+hypervDomainIsUpdated(virDomainPtr domain G_GNUC_UNUSED)
 {
 return 0;
 }
@@ -1607,7 +1607,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
 
 static void
 hypervDebugHandler(const char *message, debug_level_e level,
-   void *user_data ATTRIBUTE_UNUSED)
+   void *user_data G_GNUC_UNUSED)
 {
 switch (level) {
   case DEBUG_LEVEL_ERROR:
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index c2c1f082e1..04f82389c1 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -1127,7 +1127,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr 
wqlQuery,
 }
 
 void
-hypervFreeObject(hypervPrivate *priv ATTRIBUTE_UNUSED, hypervObject *object)
+hypervFreeObject(hypervPrivate *priv G_GNUC_UNUSED, hypervObject *object)
 {
 hypervObject *next;
 #if WS_SERIALIZER_FREE_MEM_WORKS
diff --git a/src/interface/interface_backend_netcf.c 
b/src/interface/interface_backend_netcf.c
index 5ef8ac33db..a45d429973 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -89,8 +89,8 @@ virNetcfDriverStateDispose(void *obj)
 
 static int
 netcfStateInitialize(bool privileged,
- virStateInhibitCallback callback ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED)
+ virStateInhibitCallback callback G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED)
 {
 if (virNetcfDriverStateInitialize() < 0)
 return VIR_DRV_STATE_INIT_ERROR;
@@ -188,8 +188,8 @@ netcfStateReload(void)
 
 static virDrvOpenStatus
 netcfConnectOpen(virConnectPtr conn,
- virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- virConfPtr conf ATTRIBUTE_UNUSED,
+ virConnectAuthPtr auth G_GNUC_UNUSED,
+ virConfPtr conf G_GNUC_UNUSED,
  unsigned int flags)
 {
 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
@@ -211,27 +211,27 @@ netcfConnectOpen(virConnectPtr conn,
 return VIR_DRV_OPEN_SUCCESS;
 }
 
-static int netcfConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int netcfConnectClose(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 0;
 }
 
 
-static int netcfConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int netcfConnectIsSecure(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Trivially secure, since always inside the daemon */
 return 1;
 }
 
 
-static int netcfConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int netcfConnectIsEncrypted(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Not encrypted, but remote driver takes care of that */
 return 0;
 }
 
 
-static int netcfConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int netcfConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)

[libvirt] [PATCH 25/35] storage: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/storage/storage_backend.c |  2 +-
 src/storage/storage_backend_disk.c|  6 ++---
 src/storage/storage_backend_fs.c  |  4 +--
 src/storage/storage_backend_logical.c |  4 +--
 src/storage/storage_backend_mpath.c   |  2 +-
 src/storage/storage_backend_rbd.c | 22 
 src/storage/storage_backend_zfs.c |  4 +--
 src/storage/storage_driver.c  | 22 
 src/storage/storage_util.c| 36 +--
 9 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index ed5bdd5bad..6ab5844235 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -106,7 +106,7 @@ virStorageDriverLoadBackendModule(const char *name,
 return -1
 
 int
-virStorageBackendDriversRegister(bool allbackends ATTRIBUTE_UNUSED)
+virStorageBackendDriversRegister(bool allbackends G_GNUC_UNUSED)
 {
 #if WITH_STORAGE_DIR || WITH_STORAGE_FS
 VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister, "fs");
diff --git a/src/storage/storage_backend_disk.c 
b/src/storage/storage_backend_disk.c
index f58b7b294c..5bf704bcc8 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -41,7 +41,7 @@ VIR_LOG_INIT("storage.storage_backend_disk");
 
 static bool
 virStorageVolPartFindExtended(virStorageVolDefPtr def,
-  const void *opaque ATTRIBUTE_UNUSED)
+  const void *opaque G_GNUC_UNUSED)
 {
 if (def->source.partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
 return true;
@@ -286,7 +286,7 @@ struct virStorageBackendDiskPoolVolData {
 };
 
 static int
-virStorageBackendDiskMakeVol(size_t ntok ATTRIBUTE_UNUSED,
+virStorageBackendDiskMakeVol(size_t ntok G_GNUC_UNUSED,
  char **const groups,
  void *opaque)
 {
@@ -391,7 +391,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr 
pool,
 }
 
 static int
-virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRIBUTE_UNUSED,
+virStorageBackendDiskMakePoolGeometry(size_t ntok G_GNUC_UNUSED,
   char **const groups,
   void *data)
 {
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index c903677950..ed677058ed 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -438,8 +438,8 @@ virStorageBackendExecuteMKFS(const char *device,
 }
 #else /* #ifdef MKFS */
 static int
-virStorageBackendExecuteMKFS(const char *device ATTRIBUTE_UNUSED,
- const char *format ATTRIBUTE_UNUSED)
+virStorageBackendExecuteMKFS(const char *device G_GNUC_UNUSED,
+ const char *format G_GNUC_UNUSED)
 {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("mkfs is not supported on this platform: "
diff --git a/src/storage/storage_backend_logical.c 
b/src/storage/storage_backend_logical.c
index 603a3f9a42..6e468b3579 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -543,7 +543,7 @@ 
virStorageBackendLogicalGetPoolSources(virStoragePoolSourceListPtr sourceList)
 
 
 static char *
-virStorageBackendLogicalFindPoolSources(const char *srcSpec ATTRIBUTE_UNUSED,
+virStorageBackendLogicalFindPoolSources(const char *srcSpec G_GNUC_UNUSED,
 unsigned int flags)
 {
 virStoragePoolSourceList sourceList;
@@ -837,7 +837,7 @@ virStorageBackendLogicalDeletePool(virStoragePoolObjPtr 
pool,
 
 
 static int
-virStorageBackendLogicalDeleteVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendLogicalDeleteVol(virStoragePoolObjPtr pool G_GNUC_UNUSED,
   virStorageVolDefPtr vol,
   unsigned int flags)
 {
diff --git a/src/storage/storage_backend_mpath.c 
b/src/storage/storage_backend_mpath.c
index cb1b23288a..4d41ea1107 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -233,7 +233,7 @@ virStorageBackendGetMaps(virStoragePoolObjPtr pool)
 }
 
 static int
-virStorageBackendMpathCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendMpathCheckPool(virStoragePoolObjPtr pool G_GNUC_UNUSED,
 bool *isActive)
 {
 *isActive = virFileExists("/dev/mapper") ||
diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index b10ca1503d..4f4ade9d15 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -450,7 +450,7 @@ volStorageBackendRBDUseFastDiff(uint64_t features, uint64_t 
flags)
 }
 
 static int
-virStorageBackendRBDRefreshVolInfoCb(uint64_t offset ATTRIBUTE_UNUSED,
+virStorageBackendRBDRefreshVolInfoCb(uint64_t offset G_GNUC_UN

[libvirt] [PATCH 28/35] tools: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 tools/virsh-completer-domain.c   |  6 +--
 tools/virsh-completer-host.c |  4 +-
 tools/virsh-completer-interface.c|  2 +-
 tools/virsh-completer-network.c  |  8 ++--
 tools/virsh-completer-nodedev.c  |  6 +--
 tools/virsh-completer-nwfilter.c |  4 +-
 tools/virsh-completer-pool.c |  6 +--
 tools/virsh-completer-secret.c   |  6 +--
 tools/virsh-console.c|  8 ++--
 tools/virsh-domain-monitor.c |  4 +-
 tools/virsh-domain.c | 62 ++--
 tools/virsh-host.c   | 14 +++
 tools/virsh-interface.c  |  8 ++--
 tools/virsh-network.c|  6 +--
 tools/virsh-nodedev.c|  8 ++--
 tools/virsh-nwfilter.c   |  4 +-
 tools/virsh-pool.c   | 14 +++
 tools/virsh-secret.c |  8 ++--
 tools/virsh-util.c   | 10 ++---
 tools/virsh-volume.c |  2 +-
 tools/virsh.c|  4 +-
 tools/virt-admin-completer.c |  2 +-
 tools/virt-admin.c   | 12 +++---
 tools/virt-host-validate-common.c|  4 +-
 tools/virt-login-shell-helper.c  |  4 +-
 tools/vsh.c  | 56 -
 tools/wireshark/src/packet-libvirt.c |  6 +--
 27 files changed, 139 insertions(+), 139 deletions(-)

diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index 9c10e38aba..8f5c711097 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -31,7 +31,7 @@
 
 char **
 virshDomainNameCompleter(vshControl *ctl,
- const vshCmd *cmd ATTRIBUTE_UNUSED,
+ const vshCmd *cmd G_GNUC_UNUSED,
  unsigned int flags)
 {
 virshControlPtr priv = ctl->privData;
@@ -168,8 +168,8 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
 
 
 char **
-virshDomainEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
-  const vshCmd *cmd ATTRIBUTE_UNUSED,
+virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
+  const vshCmd *cmd G_GNUC_UNUSED,
   unsigned int flags)
 {
 size_t i = 0;
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index 7e31ca2bf3..839c8cc420 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -51,7 +51,7 @@ virshPagesizeNodeToString(xmlNodePtr node)
 
 char **
 virshAllocpagesPagesizeCompleter(vshControl *ctl,
- const vshCmd *cmd ATTRIBUTE_UNUSED,
+ const vshCmd *cmd G_GNUC_UNUSED,
  unsigned int flags)
 {
 VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
@@ -107,7 +107,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
 
 char **
 virshCellnoCompleter(vshControl *ctl,
- const vshCmd *cmd ATTRIBUTE_UNUSED,
+ const vshCmd *cmd G_GNUC_UNUSED,
  unsigned int flags)
 {
 VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
diff --git a/tools/virsh-completer-interface.c 
b/tools/virsh-completer-interface.c
index 5dcdab8e92..24a69d30b9 100644
--- a/tools/virsh-completer-interface.c
+++ b/tools/virsh-completer-interface.c
@@ -27,7 +27,7 @@
 
 char **
 virshInterfaceNameCompleter(vshControl *ctl,
-const vshCmd *cmd ATTRIBUTE_UNUSED,
+const vshCmd *cmd G_GNUC_UNUSED,
 unsigned int flags)
 {
 virshControlPtr priv = ctl->privData;
diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c
index 6f92780feb..404260b20c 100644
--- a/tools/virsh-completer-network.c
+++ b/tools/virsh-completer-network.c
@@ -28,7 +28,7 @@
 
 char **
 virshNetworkNameCompleter(vshControl *ctl,
-  const vshCmd *cmd ATTRIBUTE_UNUSED,
+  const vshCmd *cmd G_GNUC_UNUSED,
   unsigned int flags)
 {
 virshControlPtr priv = ctl->privData;
@@ -70,8 +70,8 @@ virshNetworkNameCompleter(vshControl *ctl,
 
 
 char **
-virshNetworkEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
-   const vshCmd *cmd ATTRIBUTE_UNUSED,
+virshNetworkEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
+   const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
 {
 size_t i = 0;
@@ -97,7 +97,7 @@ virshNetworkEventNameCompleter(vshControl *ctl 
ATTRIBUTE_UNUSED,
 
 char **
 virshNetworkPortUUIDCompleter(vshControl *ctl,
-  const vshCmd *cmd ATTRIBUTE_UNUSED,
+  const vshCmd *cmd G_GNUC_UNUSED,
   unsigned int flags)
 {
 virshControlPtr priv = ctl->privData;
diff --git a/tools/vi

[libvirt] [PATCH 01/35] util: remove MIN and MAX macros

2019-10-14 Thread Ján Tomko
They are already defined in glib.h.

(libxml2 also has them defined)

Signed-off-by: Ján Tomko 
---
 src/util/virutil.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/src/util/virutil.h b/src/util/virutil.h
index b64a85f49e..15ae67dea2 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -26,13 +26,6 @@
 #include 
 #include 
 
-#ifndef MIN
-# define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef MAX
-# define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
 
 int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK;
 int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK;
-- 
2.19.2

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

[libvirt] [PATCH 10/35] conf: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/conf/capabilities.c   |  6 +-
 src/conf/domain_addr.c| 22 
 src/conf/domain_audit.c   |  2 +-
 src/conf/domain_capabilities.c|  2 +-
 src/conf/domain_conf.c| 28 +-
 src/conf/domain_event.c   |  2 +-
 src/conf/network_conf.c   | 80 +--
 src/conf/node_device_conf.c   | 10 ++--
 src/conf/nwfilter_conf.c  | 50 -
 src/conf/nwfilter_params.c|  2 +-
 src/conf/object_event.c   |  2 +-
 src/conf/virchrdev.c  | 10 ++--
 src/conf/virdomaincheckpointobjlist.c |  2 +-
 src/conf/virdomainmomentobjlist.c |  6 +-
 src/conf/virdomainobjlist.c   | 12 ++--
 src/conf/virinterfaceobj.c| 10 ++--
 src/conf/virnetworkobj.c  | 18 +++---
 src/conf/virnodedeviceobj.c   | 16 +++---
 src/conf/virnwfilterbindingobjlist.c  |  4 +-
 src/conf/virsecretobj.c   |  8 +--
 src/conf/virstorageobj.c  | 22 
 21 files changed, 157 insertions(+), 157 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 7419d9cfc8..1781c1df0a 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -1485,8 +1485,8 @@ virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo)
 
 /* returns 1 on success, 0 if the detection failed and -1 on hard error */
 static int
-virCapabilitiesFillCPUInfo(int cpu_id ATTRIBUTE_UNUSED,
-   virCapsHostNUMACellCPUPtr cpu ATTRIBUTE_UNUSED)
+virCapabilitiesFillCPUInfo(int cpu_id G_GNUC_UNUSED,
+   virCapsHostNUMACellCPUPtr cpu G_GNUC_UNUSED)
 {
 #ifdef __linux__
 cpu->id = cpu_id;
@@ -1592,7 +1592,7 @@ virCapabilitiesInitNUMAFake(virCapsPtr caps)
 int ncpus;
 int s, c, t;
 int id, cid;
-int onlinecpus ATTRIBUTE_UNUSED;
+int onlinecpus G_GNUC_UNUSED;
 bool tmp;
 
 if (virCapabilitiesGetNodeInfo(&nodeinfo) < 0)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 4e02c43375..fc612ee6a2 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1301,8 +1301,8 @@ 
virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
 
 
 static int
-virDomainPCIAddressSetMultiIter(virDomainDefPtr def ATTRIBUTE_UNUSED,
-virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
+virDomainPCIAddressSetMultiIter(virDomainDefPtr def G_GNUC_UNUSED,
+virDomainDeviceDefPtr dev G_GNUC_UNUSED,
 virDomainDeviceInfoPtr info,
 void *data)
 {
@@ -1335,9 +1335,9 @@ virDomainPCIAddressSetMultiIter(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 
 static int
 virDomainPCIAddressSetAllMultiIter(virDomainDefPtr def,
-   virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
+   virDomainDeviceDefPtr dev G_GNUC_UNUSED,
virDomainDeviceInfoPtr info,
-   void *data ATTRIBUTE_UNUSED)
+   void *data G_GNUC_UNUSED)
 {
 virPCIDeviceAddressPtr testAddr;
 
@@ -1463,8 +1463,8 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
 }
 
 static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
-virDomainCCWAddressAllocate(virDomainDefPtr def ATTRIBUTE_UNUSED,
-virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
+virDomainCCWAddressAllocate(virDomainDefPtr def G_GNUC_UNUSED,
+virDomainDeviceDefPtr dev G_GNUC_UNUSED,
 virDomainDeviceInfoPtr info,
 void *data)
 {
@@ -1472,8 +1472,8 @@ virDomainCCWAddressAllocate(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 }
 
 static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
-virDomainCCWAddressValidate(virDomainDefPtr def ATTRIBUTE_UNUSED,
-virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
+virDomainCCWAddressValidate(virDomainDefPtr def G_GNUC_UNUSED,
+virDomainDeviceDefPtr dev G_GNUC_UNUSED,
 virDomainDeviceInfoPtr info,
 void *data)
 {
@@ -1682,8 +1682,8 @@ 
virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs)
  * opaque should be the address set
  */
 static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
-virDomainVirtioSerialAddrReserve(virDomainDefPtr def ATTRIBUTE_UNUSED,
- virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
+virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED,
+ virDomainDeviceDefPtr dev G_GNUC_UNUSED,
  virDomainDeviceInfoPtr info,
  void *data)
 {
@@ -2422,7 +2422,7 @@ virDomainUSBAddressAssign(virDo

[libvirt] [PATCH 17/35] network: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/network/bridge_driver.c   | 26 +-
 src/network/bridge_driver_linux.c |  2 +-
 src/network/bridge_driver_nop.c   | 12 ++--
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d10665efa3..4beb28a5d9 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -662,7 +662,7 @@ networkAutostartConfig(virNetworkObjPtr obj,
 
 #ifdef WITH_FIREWALLD
 static DBusHandlerResult
-firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED,
+firewalld_dbus_filter_bridge(DBusConnection *connection G_GNUC_UNUSED,
  DBusMessage *message,
  void *user_data)
 {
@@ -709,8 +709,8 @@ firewalld_dbus_filter_bridge(DBusConnection *connection 
ATTRIBUTE_UNUSED,
  */
 static int
 networkStateInitialize(bool privileged,
-   virStateInhibitCallback callback ATTRIBUTE_UNUSED,
-   void *opaque ATTRIBUTE_UNUSED)
+   virStateInhibitCallback callback G_GNUC_UNUSED,
+   void *opaque G_GNUC_UNUSED)
 {
 int ret = VIR_DRV_STATE_INIT_ERROR;
 char *configdir = NULL;
@@ -932,8 +932,8 @@ networkStateCleanup(void)
 
 static virDrvOpenStatus
 networkConnectOpen(virConnectPtr conn,
-   virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-   virConfPtr conf ATTRIBUTE_UNUSED,
+   virConnectAuthPtr auth G_GNUC_UNUSED,
+   virConfPtr conf G_GNUC_UNUSED,
unsigned int flags)
 {
 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
@@ -955,27 +955,27 @@ networkConnectOpen(virConnectPtr conn,
 return VIR_DRV_OPEN_SUCCESS;
 }
 
-static int networkConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int networkConnectClose(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 0;
 }
 
 
-static int networkConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int networkConnectIsSecure(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Trivially secure, since always inside the daemon */
 return 1;
 }
 
 
-static int networkConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int networkConnectIsEncrypted(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* Not encrypted, but remote driver takes care of that */
 return 0;
 }
 
 
-static int networkConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int networkConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 1;
 }
@@ -1131,7 +1131,7 @@ networkDnsmasqConfContents(virNetworkObjPtr obj,
const char *pidfile,
char **configstr,
dnsmasqContext *dctx,
-   dnsmasqCapsPtr caps ATTRIBUTE_UNUSED)
+   dnsmasqCapsPtr caps G_GNUC_UNUSED)
 {
 virNetworkDefPtr def = virNetworkObjGetDef(obj);
 virBuffer configbuf = VIR_BUFFER_INITIALIZER;
@@ -2213,7 +2213,7 @@ networkRefreshDaemons(virNetworkDriverStatePtr driver)
 
 static int
 networkReloadFirewallRulesHelper(virNetworkObjPtr obj,
- void *opaque ATTRIBUTE_UNUSED)
+ void *opaque G_GNUC_UNUSED)
 {
 virNetworkDefPtr def;
 
@@ -2760,7 +2760,7 @@ networkStartNetworkBridge(virNetworkObjPtr obj)
 
 
 static int
-networkShutdownNetworkBridge(virNetworkObjPtr obj ATTRIBUTE_UNUSED)
+networkShutdownNetworkBridge(virNetworkObjPtr obj G_GNUC_UNUSED)
 {
 virNetworkDefPtr def = virNetworkObjGetDef(obj);
 
@@ -2900,7 +2900,7 @@ networkStartNetworkExternal(virNetworkObjPtr obj)
 
 
 static int
-networkShutdownNetworkExternal(virNetworkObjPtr obj ATTRIBUTE_UNUSED)
+networkShutdownNetworkExternal(virNetworkObjPtr obj G_GNUC_UNUSED)
 {
 /* put anything here that needs to be done each time a network of
  * type BRIDGE, PRIVATE, VEPA, HOSTDEV or PASSTHROUGH is shutdown. On
diff --git a/src/network/bridge_driver_linux.c 
b/src/network/bridge_driver_linux.c
index 35459c10d1..d62fb899b9 100644
--- a/src/network/bridge_driver_linux.c
+++ b/src/network/bridge_driver_linux.c
@@ -157,7 +157,7 @@ void networkPreReloadFirewallRules(virNetworkDriverStatePtr 
driver, bool startup
 }
 
 
-void networkPostReloadFirewallRules(bool startup ATTRIBUTE_UNUSED)
+void networkPostReloadFirewallRules(bool startup G_GNUC_UNUSED)
 {
 iptablesSetDeletePrivate(true);
 }
diff --git a/src/network/bridge_driver_nop.c b/src/network/bridge_driver_nop.c
index ec7b1ed8b7..08d737511f 100644
--- a/src/network/bridge_driver_nop.c
+++ b/src/network/bridge_driver_nop.c
@@ -19,27 +19,27 @@
 
 #include 
 
-void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver 
ATTRIBUTE_UNUSED,
-   bool startup ATTRIBUTE_UNUSED)
+void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver 
G_GNUC_UN

[libvirt] [PATCH 08/35] admin: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/admin/admin_remote.c  |  4 +--
 src/admin/admin_server_dispatch.c | 60 +++
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/admin/admin_remote.c b/src/admin/admin_remote.c
index 0846e72f6d..8e0752746c 100644
--- a/src/admin/admin_remote.c
+++ b/src/admin/admin_remote.c
@@ -76,7 +76,7 @@ make_nonnull_client(admin_nonnull_client *client_dst,
 }
 
 static int
-callFull(virAdmConnectPtr conn ATTRIBUTE_UNUSED,
+callFull(virAdmConnectPtr conn G_GNUC_UNUSED,
  remoteAdminPrivPtr priv,
  int *fdin,
  size_t fdinlen,
@@ -130,7 +130,7 @@ call(virAdmConnectPtr conn,
 #include "admin_client.h"
 
 static void
-remoteAdminClientCloseFunc(virNetClientPtr client ATTRIBUTE_UNUSED,
+remoteAdminClientCloseFunc(virNetClientPtr client G_GNUC_UNUSED,
int reason,
void *opaque)
 {
diff --git a/src/admin/admin_server_dispatch.c 
b/src/admin/admin_server_dispatch.c
index f07ae6df1d..4cc41428ed 100644
--- a/src/admin/admin_server_dispatch.c
+++ b/src/admin/admin_server_dispatch.c
@@ -60,7 +60,7 @@ remoteAdmClientFree(void *data)
 }
 
 void *
-remoteAdmClientNew(virNetServerClientPtr client ATTRIBUTE_UNUSED,
+remoteAdmClientNew(virNetServerClientPtr client G_GNUC_UNUSED,
void *opaque)
 {
 struct daemonAdmClientPrivate *priv;
@@ -107,14 +107,14 @@ remoteAdmClientNew(virNetServerClientPtr client 
ATTRIBUTE_UNUSED,
 }
 
 void *remoteAdmClientNewPostExecRestart(virNetServerClientPtr client,
-virJSONValuePtr object 
ATTRIBUTE_UNUSED,
+virJSONValuePtr object G_GNUC_UNUSED,
 void *opaque)
 {
 return remoteAdmClientNew(client, opaque);
 }
 
-virJSONValuePtr remoteAdmClientPreExecRestart(virNetServerClientPtr client 
ATTRIBUTE_UNUSED,
-  void *data ATTRIBUTE_UNUSED)
+virJSONValuePtr remoteAdmClientPreExecRestart(virNetServerClientPtr client 
G_GNUC_UNUSED,
+  void *data G_GNUC_UNUSED)
 {
 virJSONValuePtr object = virJSONValueNewObject();
 
@@ -162,9 +162,9 @@ make_nonnull_client(admin_nonnull_client *clt_dst,
 
 /* Functions */
 static int
-adminDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
+adminDispatchConnectOpen(virNetServerPtr server G_GNUC_UNUSED,
  virNetServerClientPtr client,
- virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessagePtr msg G_GNUC_UNUSED,
  virNetMessageErrorPtr rerr,
  struct admin_connect_open_args *args)
 {
@@ -188,17 +188,17 @@ adminDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 }
 
 static int
-adminDispatchConnectClose(virNetServerPtr server ATTRIBUTE_UNUSED,
+adminDispatchConnectClose(virNetServerPtr server G_GNUC_UNUSED,
   virNetServerClientPtr client,
-  virNetMessagePtr msg ATTRIBUTE_UNUSED,
-  virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED)
+  virNetMessagePtr msg G_GNUC_UNUSED,
+  virNetMessageErrorPtr rerr G_GNUC_UNUSED)
 {
 virNetServerClientDelayedClose(client);
 return 0;
 }
 
 static int
-adminConnectGetLibVersion(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
+adminConnectGetLibVersion(virNetDaemonPtr dmn G_GNUC_UNUSED,
   unsigned long long *libVer)
 {
 if (libVer)
@@ -216,9 +216,9 @@ adminGetConn(virNetServerClientPtr client)
 }
 
 static int
-adminDispatchServerGetThreadpoolParameters(virNetServerPtr server 
ATTRIBUTE_UNUSED,
+adminDispatchServerGetThreadpoolParameters(virNetServerPtr server 
G_GNUC_UNUSED,
virNetServerClientPtr client,
-   virNetMessagePtr msg 
ATTRIBUTE_UNUSED,
+   virNetMessagePtr msg G_GNUC_UNUSED,
virNetMessageErrorPtr rerr,
struct 
admin_server_get_threadpool_parameters_args *args,
struct 
admin_server_get_threadpool_parameters_ret *ret)
@@ -254,9 +254,9 @@ adminDispatchServerGetThreadpoolParameters(virNetServerPtr 
server ATTRIBUTE_UNUS
 }
 
 static int
-adminDispatchServerSetThreadpoolParameters(virNetServerPtr server 
ATTRIBUTE_UNUSED,
+adminDispatchServerSetThreadpoolParameters(virNetServerPtr server 
G_GNUC_UNUSED,
virNetServerClientPtr client,
-   virNetMessagePtr msg 
ATTRIBUTE_UNUSED,
+   virNetMessagePtr msg G_GNUC_UNUSED,

[libvirt] [PATCH 06/35] examples: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Name the macro G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED
to match the rest of libvirt code.

Signed-off-by: Ján Tomko 
---
 examples/c/misc/event-test.c | 140 +--
 1 file changed, 70 insertions(+), 70 deletions(-)

diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c
index fcf4492470..533b8da9bf 100644
--- a/examples/c/misc/event-test.c
+++ b/examples/c/misc/event-test.c
@@ -21,17 +21,17 @@
 # define verify(cond)
 #endif
 
-#ifndef ATTRIBUTE_UNUSED
-# define ATTRIBUTE_UNUSED __attribute__((__unused__))
+#ifndef G_GNUC_UNUSED
+# define G_GNUC_UNUSED __attribute__((__unused__))
 #endif
 
 int run = 1;
 
 /* Callback functions */
 static void
-connectClose(virConnectPtr conn ATTRIBUTE_UNUSED,
+connectClose(virConnectPtr conn G_GNUC_UNUSED,
  int reason,
- void *opaque ATTRIBUTE_UNUSED)
+ void *opaque G_GNUC_UNUSED)
 {
 run = 0;
 
@@ -404,11 +404,11 @@ secretEventToString(int event)
 
 
 static int
-myDomainEventCallback1(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventCallback1(virConnectPtr conn G_GNUC_UNUSED,
virDomainPtr dom,
int event,
int detail,
-   void *opaque ATTRIBUTE_UNUSED)
+   void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), eventToString(event),
@@ -418,11 +418,11 @@ myDomainEventCallback1(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 
 static int
-myDomainEventCallback2(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventCallback2(virConnectPtr conn G_GNUC_UNUSED,
virDomainPtr dom,
int event,
int detail,
-   void *opaque ATTRIBUTE_UNUSED)
+   void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), eventToString(event),
@@ -432,9 +432,9 @@ myDomainEventCallback2(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 
 static int
-myDomainEventRebootCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventRebootCallback(virConnectPtr conn G_GNUC_UNUSED,
 virDomainPtr dom,
-void *opaque ATTRIBUTE_UNUSED)
+void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%d) rebooted\n", __func__, 
virDomainGetName(dom),
virDomainGetID(dom));
@@ -444,10 +444,10 @@ myDomainEventRebootCallback(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 
 static int
-myDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventRTCChangeCallback(virConnectPtr conn G_GNUC_UNUSED,
virDomainPtr dom,
long long offset,
-   void *opaque ATTRIBUTE_UNUSED)
+   void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%d) rtc change %" PRIdMAX "\n",
__func__, virDomainGetName(dom), virDomainGetID(dom),
@@ -458,10 +458,10 @@ myDomainEventRTCChangeCallback(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 
 static int
-myDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventBalloonChangeCallback(virConnectPtr conn G_GNUC_UNUSED,
virDomainPtr dom,
unsigned long long actual,
-   void *opaque ATTRIBUTE_UNUSED)
+   void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%d) balloon change %" PRIuMAX "KB\n",
__func__, virDomainGetName(dom), virDomainGetID(dom), 
(uintmax_t)actual);
@@ -471,10 +471,10 @@ myDomainEventBalloonChangeCallback(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 
 static int
-myDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventWatchdogCallback(virConnectPtr conn G_GNUC_UNUSED,
   virDomainPtr dom,
   int action,
-  void *opaque ATTRIBUTE_UNUSED)
+  void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%d) watchdog action=%d\n", __func__,
virDomainGetName(dom), virDomainGetID(dom), action);
@@ -484,12 +484,12 @@ myDomainEventWatchdogCallback(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 
 static int
-myDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+myDomainEventIOErrorCallback(virConnectPtr conn G_GNUC_UNUSED,
  virDomainPtr dom,
  const char *srcPath,
  const char *devAlias,
  int action,
- void *opaque ATTRIBUTE_UNUSED)
+ void *opaque G_GNUC_UNUSED)
 {
 printf("%s EVENT: Domain %s(%

[libvirt] [PATCH 21/35] qemu: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_block.c|  6 +-
 src/qemu/qemu_blockjob.c |  4 +-
 src/qemu/qemu_capabilities.c |  4 +-
 src/qemu/qemu_cgroup.c   |  2 +-
 src/qemu/qemu_checkpoint.c   |  2 +-
 src/qemu/qemu_command.c  |  8 +--
 src/qemu/qemu_conf.c |  4 +-
 src/qemu/qemu_domain.c   | 94 
 src/qemu/qemu_domain_address.c   | 30 +-
 src/qemu/qemu_driver.c   | 64 +++---
 src/qemu/qemu_hotplug.c  |  4 +-
 src/qemu/qemu_migration.c|  4 +-
 src/qemu/qemu_migration_cookie.c |  2 +-
 src/qemu/qemu_monitor.c  |  4 +-
 src/qemu/qemu_monitor_json.c | 18 +++---
 src/qemu/qemu_process.c  | 84 ++--
 src/qemu/qemu_qapi.c |  2 +-
 17 files changed, 168 insertions(+), 168 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index eacb48aa78..599ca629e0 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -51,7 +51,7 @@ qemuBlockNodeNameValidate(const char *nn)
 
 
 static int
-qemuBlockNamedNodesArrayToHash(size_t pos ATTRIBUTE_UNUSED,
+qemuBlockNamedNodesArrayToHash(size_t pos G_GNUC_UNUSED,
virJSONValuePtr item,
void *opaque)
 {
@@ -93,7 +93,7 @@ VIR_DEFINE_AUTOPTR_FUNC(qemuBlockNodeNameBackingChainData,
 
 static void
 qemuBlockNodeNameBackingChainDataHashEntryFree(void *opaque,
-   const void *name 
ATTRIBUTE_UNUSED)
+   const void *name G_GNUC_UNUSED)
 {
 qemuBlockNodeNameBackingChainDataFree(opaque);
 }
@@ -192,7 +192,7 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr 
next,
 
 
 static int
-qemuBlockNodeNameGetBackingChainDisk(size_t pos ATTRIBUTE_UNUSED,
+qemuBlockNodeNameGetBackingChainDisk(size_t pos G_GNUC_UNUSED,
  virJSONValuePtr item,
  void *opaque)
 {
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index c118f2c298..89c28986b0 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -419,8 +419,8 @@ qemuBlockJobIsRunning(qemuBlockJobDataPtr job)
 /* returns 1 for a job we didn't reconnect to */
 static int
 qemuBlockJobRefreshJobsFindInactive(const void *payload,
-const void *name ATTRIBUTE_UNUSED,
-const void *data ATTRIBUTE_UNUSED)
+const void *name G_GNUC_UNUSED,
+const void *data G_GNUC_UNUSED)
 {
 const qemuBlockJobData *job = payload;
 
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 091e48c7e1..cbd4ebc8ea 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4112,7 +4112,7 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
 static int
 virQEMUCapsSaveFile(void *data,
 const char *filename,
-void *privData ATTRIBUTE_UNUSED)
+void *privData G_GNUC_UNUSED)
 {
 virQEMUCapsPtr qemuCaps = data;
 char *xml = NULL;
@@ -4940,7 +4940,7 @@ virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
 
 static int
 virQEMUCapsCompareArch(const void *payload,
-   const void *name ATTRIBUTE_UNUSED,
+   const void *name G_GNUC_UNUSED,
const void *opaque)
 {
 struct virQEMUCapsSearchData *data = (struct virQEMUCapsSearchData 
*)opaque;
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 740a1b33dc..f1776a7c0b 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -285,7 +285,7 @@ qemuTeardownChrSourceCgroup(virDomainObjPtr vm,
 
 
 static int
-qemuSetupChardevCgroupCB(virDomainDefPtr def ATTRIBUTE_UNUSED,
+qemuSetupChardevCgroupCB(virDomainDefPtr def G_GNUC_UNUSED,
  virDomainChrDefPtr dev,
  void *opaque)
 {
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 8856a90ce8..0c4385083b 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -502,7 +502,7 @@ struct virQEMUCheckpointReparent {
 
 static int
 qemuCheckpointReparentChildren(void *payload,
-   const void *name ATTRIBUTE_UNUSED,
+   const void *name G_GNUC_UNUSED,
void *data)
 {
 virDomainMomentObjPtr moment = payload;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0f1625d401..a41156476f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7815,9 +7815,9 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
 
 
 static int
-qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
+qemuBuildGraphicsSDLComma

[libvirt] [PATCH 16/35] lxc: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/lxc/lxc_cgroup.c |  4 ++--
 src/lxc/lxc_container.c  | 10 +-
 src/lxc/lxc_controller.c |  4 ++--
 src/lxc/lxc_domain.c | 26 +-
 src/lxc/lxc_driver.c | 18 +-
 src/lxc/lxc_fuse.c   | 26 +-
 src/lxc/lxc_monitor.c| 12 ++--
 src/lxc/lxc_process.c|  4 ++--
 8 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 76014f3bfd..5efb495b56 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -272,7 +272,7 @@ struct _virLXCCgroupDevicePolicy {
 
 
 int
-virLXCSetupHostUSBDeviceCgroup(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
+virLXCSetupHostUSBDeviceCgroup(virUSBDevicePtr dev G_GNUC_UNUSED,
const char *path,
void *opaque)
 {
@@ -288,7 +288,7 @@ virLXCSetupHostUSBDeviceCgroup(virUSBDevicePtr dev 
ATTRIBUTE_UNUSED,
 
 
 int
-virLXCTeardownHostUSBDeviceCgroup(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
+virLXCTeardownHostUSBDeviceCgroup(virUSBDevicePtr dev G_GNUC_UNUSED,
   const char *path,
   void *opaque)
 {
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 97f9055506..2a0b04117e 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1035,8 +1035,8 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def,
 return ret;
 }
 #else
-static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
- const char *stateDir ATTRIBUTE_UNUSED)
+static int lxcContainerMountProcFuse(virDomainDefPtr def G_GNUC_UNUSED,
+ const char *stateDir G_GNUC_UNUSED)
 {
 return 0;
 }
@@ -1305,7 +1305,7 @@ lxcContainerMountDetectFilesystem(const char *src, char 
**type)
 }
 #else /* ! WITH_BLKID */
 static int
-lxcContainerMountDetectFilesystem(const char *src ATTRIBUTE_UNUSED,
+lxcContainerMountDetectFilesystem(const char *src G_GNUC_UNUSED,
   char **type)
 {
 /* No libblkid, so just return success with no detected type */
@@ -2083,8 +2083,8 @@ static int lxcContainerDropCapabilities(virDomainDefPtr 
def,
 return 0;
 }
 #else
-static int lxcContainerDropCapabilities(virDomainDefPtr def ATTRIBUTE_UNUSED,
-bool keepReboot ATTRIBUTE_UNUSED)
+static int lxcContainerDropCapabilities(virDomainDefPtr def G_GNUC_UNUSED,
+bool keepReboot G_GNUC_UNUSED)
 {
 VIR_WARN("libcap-ng support not compiled in, unable to clear 
capabilities");
 return 0;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 9097655b4d..a1f4ae8812 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -150,7 +150,7 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl);
 static int virLXCControllerEventSendInit(virLXCControllerPtr ctrl,
  pid_t initpid);
 
-static void virLXCControllerQuitTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
+static void virLXCControllerQuitTimer(int timer G_GNUC_UNUSED, void *opaque)
 {
 virLXCControllerPtr ctrl = opaque;
 
@@ -1027,7 +1027,7 @@ static virMutex lock = VIR_MUTEX_INITIALIZER;
 
 
 static void virLXCControllerSignalChildIO(virNetDaemonPtr dmn,
-  siginfo_t *info ATTRIBUTE_UNUSED,
+  siginfo_t *info G_GNUC_UNUSED,
   void *opaque)
 {
 virLXCControllerPtr ctrl = opaque;
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index c4360f25f6..4339d305a9 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -84,7 +84,7 @@ virLXCDomainObjFreeJob(virLXCDomainObjPrivatePtr priv)
  * Successful calls must be followed by EndJob eventually.
  */
 int
-virLXCDomainObjBeginJob(virLXCDriverPtr driver ATTRIBUTE_UNUSED,
+virLXCDomainObjBeginJob(virLXCDriverPtr driver G_GNUC_UNUSED,
virDomainObjPtr obj,
enum virLXCDomainJob job)
 {
@@ -136,7 +136,7 @@ virLXCDomainObjBeginJob(virLXCDriverPtr driver 
ATTRIBUTE_UNUSED,
  * earlier virLXCDomainBeginJob() call
  */
 void
-virLXCDomainObjEndJob(virLXCDriverPtr driver ATTRIBUTE_UNUSED,
+virLXCDomainObjEndJob(virLXCDriverPtr driver G_GNUC_UNUSED,
  virDomainObjPtr obj)
 {
 virLXCDomainObjPrivatePtr priv = obj->privateData;
@@ -151,7 +151,7 @@ virLXCDomainObjEndJob(virLXCDriverPtr driver 
ATTRIBUTE_UNUSED,
 
 
 static void *
-virLXCDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
+virLXCDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
 {
 virLXCDomainObjPrivatePtr priv;
 
@@ -326,7 +326,7 @@ virLXCDomainObjPrivateXMLFormat(virBufferPtr buf,
 static int
 virLXCDomainObjPrivateXMLParse(xml

[libvirt] [PATCH 23/35] rpc: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/rpc/virkeepalive.c|  2 +-
 src/rpc/virnetclientprogram.c |  4 +-
 src/rpc/virnetclientstream.c  |  4 +-
 src/rpc/virnetdaemon.c| 22 -
 src/rpc/virnetlibsshsession.c |  2 +-
 src/rpc/virnetsaslcontext.c   |  6 +--
 src/rpc/virnetserverprogram.c |  2 +-
 src/rpc/virnetserverservice.c |  2 +-
 src/rpc/virnetsocket.c| 90 +--
 src/rpc/virnetsshsession.c|  8 ++--
 src/rpc/virnettlscontext.c|  4 +-
 11 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index 5906cdfa19..860b91b6b1 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -148,7 +148,7 @@ virKeepAliveTimerInternal(virKeepAlivePtr ka,
 
 
 static void
-virKeepAliveTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
+virKeepAliveTimer(int timer G_GNUC_UNUSED, void *opaque)
 {
 virKeepAlivePtr ka = opaque;
 virNetMessagePtr msg = NULL;
diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c
index 58f24145ec..4d1a2bc28b 100644
--- a/src/rpc/virnetclientprogram.c
+++ b/src/rpc/virnetclientprogram.c
@@ -85,7 +85,7 @@ virNetClientProgramPtr virNetClientProgramNew(unsigned 
program,
 }
 
 
-void virNetClientProgramDispose(void *obj ATTRIBUTE_UNUSED)
+void virNetClientProgramDispose(void *obj G_GNUC_UNUSED)
 {
 }
 
@@ -113,7 +113,7 @@ int virNetClientProgramMatches(virNetClientProgramPtr prog,
 
 
 static int
-virNetClientProgramDispatchError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
+virNetClientProgramDispatchError(virNetClientProgramPtr prog G_GNUC_UNUSED,
  virNetMessagePtr msg)
 {
 virNetMessageError err;
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 834c44843b..f904eaba31 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -98,7 +98,7 @@ virNetClientStreamEventTimerUpdate(virNetClientStreamPtr st)
 
 
 static void
-virNetClientStreamEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
+virNetClientStreamEventTimer(int timer G_GNUC_UNUSED, void *opaque)
 {
 virNetClientStreamPtr st = opaque;
 int events = 0;
@@ -688,7 +688,7 @@ virNetClientStreamSendHole(virNetClientStreamPtr st,
 
 
 int
-virNetClientStreamRecvHole(virNetClientPtr client ATTRIBUTE_UNUSED,
+virNetClientStreamRecvHole(virNetClientPtr client G_GNUC_UNUSED,
virNetClientStreamPtr st,
long long *length)
 {
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 7b68ddbdf2..570930436a 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -210,7 +210,7 @@ struct collectData {
 
 static int
 collectServers(void *payload,
-   const void *name ATTRIBUTE_UNUSED,
+   const void *name G_GNUC_UNUSED,
void *opaque)
 {
 virNetServerPtr srv = virObjectRef(payload);
@@ -594,7 +594,7 @@ static int sigWrite = -1;
 
 static void
 virNetDaemonSignalHandler(int sig, siginfo_t * siginfo,
-  void* context ATTRIBUTE_UNUSED)
+  void* context G_GNUC_UNUSED)
 {
 int origerrno;
 int r;
@@ -619,8 +619,8 @@ virNetDaemonSignalHandler(int sig, siginfo_t * siginfo,
 
 static void
 virNetDaemonSignalEvent(int watch,
-int fd ATTRIBUTE_UNUSED,
-int events ATTRIBUTE_UNUSED,
+int fd G_GNUC_UNUSED,
+int events G_GNUC_UNUSED,
 void *opaque)
 {
 virNetDaemonPtr dmn = opaque;
@@ -733,7 +733,7 @@ virNetDaemonAddSignalHandler(virNetDaemonPtr dmn,
 
 
 static void
-virNetDaemonAutoShutdownTimer(int timerid ATTRIBUTE_UNUSED,
+virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED,
   void *opaque)
 {
 virNetDaemonPtr dmn = opaque;
@@ -750,7 +750,7 @@ virNetDaemonAutoShutdownTimer(int timerid ATTRIBUTE_UNUSED,
 
 static int
 daemonServerUpdateServices(void *payload,
-   const void *key ATTRIBUTE_UNUSED,
+   const void *key G_GNUC_UNUSED,
void *opaque)
 {
 bool *enable = opaque;
@@ -771,8 +771,8 @@ virNetDaemonUpdateServices(virNetDaemonPtr dmn,
 
 static int
 daemonServerProcessClients(void *payload,
-   const void *key ATTRIBUTE_UNUSED,
-   void *opaque ATTRIBUTE_UNUSED)
+   const void *key G_GNUC_UNUSED,
+   void *opaque G_GNUC_UNUSED)
 {
 virNetServerPtr srv = payload;
 
@@ -861,8 +861,8 @@ virNetDaemonQuit(virNetDaemonPtr dmn)
 
 static int
 daemonServerClose(void *payload,
-  const void *key ATTRIBUTE_UNUSED,
-  void *opaque ATTRIBUTE_UNUSED)
+  const void *key G_GNUC_UNUSED,
+  void *opaque G_GNU

[libvirt] [PATCH 19/35] nwfilter: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/nwfilter/nwfilter_dhcpsnoop.c | 20 ++--
 src/nwfilter/nwfilter_driver.c| 22 +++---
 src/nwfilter/nwfilter_ebiptables_driver.c | 12 ++--
 src/nwfilter/nwfilter_gentech_driver.c|  2 +-
 src/nwfilter/nwfilter_learnipaddr.c   | 12 ++--
 5 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c 
b/src/nwfilter/nwfilter_dhcpsnoop.c
index c82457989e..dae2ad611d 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -661,7 +661,7 @@ virNWFilterSnoopReqUnlock(virNWFilterSnoopReqPtr req)
  * virNWFilterSnoopReqRelease - hash table free function to kill a request
  */
 static void
-virNWFilterSnoopReqRelease(void *req0, const void *name ATTRIBUTE_UNUSED)
+virNWFilterSnoopReqRelease(void *req0, const void *name G_GNUC_UNUSED)
 {
 virNWFilterSnoopReqPtr req = req0;
 
@@ -1826,8 +1826,8 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLeasePtr 
ipl)
  */
 static int
 virNWFilterSnoopPruneIter(const void *payload,
-  const void *name ATTRIBUTE_UNUSED,
-  const void *data ATTRIBUTE_UNUSED)
+  const void *name G_GNUC_UNUSED,
+  const void *data G_GNUC_UNUSED)
 {
 virNWFilterSnoopReqPtr req = (virNWFilterSnoopReqPtr)payload;
 bool del_req;
@@ -1856,7 +1856,7 @@ virNWFilterSnoopPruneIter(const void *payload,
  */
 static int
 virNWFilterSnoopSaveIter(void *payload,
- const void *name ATTRIBUTE_UNUSED,
+ const void *name G_GNUC_UNUSED,
  void *data)
 {
 virNWFilterSnoopReqPtr req = payload;
@@ -2023,8 +2023,8 @@ virNWFilterSnoopJoinThreads(void)
  */
 static int
 virNWFilterSnoopRemAllReqIter(const void *payload,
-  const void *name ATTRIBUTE_UNUSED,
-  const void *data ATTRIBUTE_UNUSED)
+  const void *name G_GNUC_UNUSED,
+  const void *data G_GNUC_UNUSED)
 {
 virNWFilterSnoopReqPtr req = (virNWFilterSnoopReqPtr)payload;
 
@@ -2200,7 +2200,7 @@ virNWFilterDHCPSnoopInit(void)
 }
 
 void
-virNWFilterDHCPSnoopEnd(const char *ifname ATTRIBUTE_UNUSED)
+virNWFilterDHCPSnoopEnd(const char *ifname G_GNUC_UNUSED)
 {
 return;
 }
@@ -2212,9 +2212,9 @@ virNWFilterDHCPSnoopShutdown(void)
 }
 
 int
-virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
-virNWFilterBindingDefPtr binding ATTRIBUTE_UNUSED,
-virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED)
+virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver G_GNUC_UNUSED,
+virNWFilterBindingDefPtr binding G_GNUC_UNUSED,
+virNWFilterDriverStatePtr driver G_GNUC_UNUSED)
 {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("libvirt was not compiled with libpcap and \""
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index aef5bd4c7f..fbdf250934 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -80,9 +80,9 @@ static void nwfilterDriverUnlock(void)
 #ifdef WITH_FIREWALLD
 
 static DBusHandlerResult
-nwfilterFirewalldDBusFilter(DBusConnection *connection ATTRIBUTE_UNUSED,
+nwfilterFirewalldDBusFilter(DBusConnection *connection G_GNUC_UNUSED,
 DBusMessage *message,
-void *user_data ATTRIBUTE_UNUSED)
+void *user_data G_GNUC_UNUSED)
 {
 if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
"NameOwnerChanged") ||
@@ -154,7 +154,7 @@ nwfilterDriverRemoveDBusMatches(void)
 }
 
 static int
-nwfilterDriverInstallDBusMatches(DBusConnection *sysbus ATTRIBUTE_UNUSED)
+nwfilterDriverInstallDBusMatches(DBusConnection *sysbus G_GNUC_UNUSED)
 {
 return 0;
 }
@@ -177,8 +177,8 @@ virNWFilterTriggerRebuildImpl(void *opaque)
  */
 static int
 nwfilterStateInitialize(bool privileged,
-virStateInhibitCallback callback ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED)
+virStateInhibitCallback callback G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED)
 {
 DBusConnection *sysbus = NULL;
 
@@ -384,8 +384,8 @@ nwfilterStateCleanup(void)
 
 static virDrvOpenStatus
 nwfilterConnectOpen(virConnectPtr conn,
-virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-virConfPtr conf ATTRIBUTE_UNUSED,
+virConnectAuthPtr auth G_GNUC_UNUSED,
+virConfPtr conf G_GNUC_UNUSED,
 unsigned int flags)
 {
 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
@@ -409,27 +409,27 @@ nwfilterConnect

[libvirt] [PATCH 13/35] libxl: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/libxl/libxl_conf.h  |  2 +-
 src/libxl/libxl_domain.c| 26 +++---
 src/libxl/libxl_driver.c| 70 ++---
 src/libxl/libxl_logger.c| 14 
 src/libxl/libxl_migration.c | 12 +++
 5 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 80be791b7c..305c8c41ef 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -212,7 +212,7 @@ libxlCreateXMLConf(void);
 #ifdef LIBXL_HAVE_DEVICE_CHANNEL
 # define LIBXL_ATTR_UNUSED
 #else
-# define LIBXL_ATTR_UNUSED ATTRIBUTE_UNUSED
+# define LIBXL_ATTR_UNUSED G_GNUC_UNUSED
 #endif
 int
 libxlBuildDomainConfig(virPortAllocatorRangePtr graphicsports,
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 4073bf8d46..1e4d900ac5 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -108,7 +108,7 @@ libxlDomainObjFreeJob(libxlDomainObjPrivatePtr priv)
  * successful calls must be followed by EndJob eventually
  */
 int
-libxlDomainObjBeginJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,
+libxlDomainObjBeginJob(libxlDriverPrivatePtr driver G_GNUC_UNUSED,
virDomainObjPtr obj,
enum libxlDomainJob job)
 {
@@ -166,7 +166,7 @@ libxlDomainObjBeginJob(libxlDriverPrivatePtr driver 
ATTRIBUTE_UNUSED,
  * and obj is disposed.
  */
 void
-libxlDomainObjEndJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,
+libxlDomainObjEndJob(libxlDriverPrivatePtr driver G_GNUC_UNUSED,
  virDomainObjPtr obj)
 {
 libxlDomainObjPrivatePtr priv = obj->privateData;
@@ -201,7 +201,7 @@ libxlDomainJobUpdateTime(struct libxlDomainJobObj *job)
 }
 
 static void *
-libxlDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
+libxlDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
 {
 libxlDomainObjPrivatePtr priv;
 
@@ -246,7 +246,7 @@ libxlDomainObjPrivateFree(void *data)
 static int
 libxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
   virDomainObjPtr vm,
-  virDomainDefParserConfigPtr config 
ATTRIBUTE_UNUSED)
+  virDomainDefParserConfigPtr config G_GNUC_UNUSED)
 {
 libxlDomainObjPrivatePtr priv = vm->privateData;
 
@@ -278,10 +278,10 @@ virDomainXMLPrivateDataCallbacks 
libxlDomainXMLPrivateDataCallbacks = {
 static int
 libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
   const virDomainDef *def,
-  virCapsPtr caps ATTRIBUTE_UNUSED,
-  unsigned int parseFlags ATTRIBUTE_UNUSED,
-  void *opaque ATTRIBUTE_UNUSED,
-  void *parseOpaque ATTRIBUTE_UNUSED)
+  virCapsPtr caps G_GNUC_UNUSED,
+  unsigned int parseFlags G_GNUC_UNUSED,
+  void *opaque G_GNUC_UNUSED,
+  void *parseOpaque G_GNUC_UNUSED)
 {
 if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
 dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
@@ -367,10 +367,10 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
 
 static int
 libxlDomainDefPostParse(virDomainDefPtr def,
-virCapsPtr caps ATTRIBUTE_UNUSED,
-unsigned int parseFlags ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED,
-void *parseOpaque ATTRIBUTE_UNUSED)
+virCapsPtr caps G_GNUC_UNUSED,
+unsigned int parseFlags G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED,
+void *parseOpaque G_GNUC_UNUSED)
 {
 /* Xen PV domains always have a PV console, so add one to the domain config
  * via post-parse callback if not explicitly specified in the XML. */
@@ -1255,7 +1255,7 @@ libxlDomainCreateChannelPTY(virDomainDefPtr def, 
libxl_ctx *ctx)
 #ifdef LIBXL_HAVE_SRM_V2
 # define LIBXL_DOMSTART_RESTORE_VER_ATTR /* empty */
 #else
-# define LIBXL_DOMSTART_RESTORE_VER_ATTR ATTRIBUTE_UNUSED
+# define LIBXL_DOMSTART_RESTORE_VER_ATTR G_GNUC_UNUSED
 #endif
 
 /*
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ea643b8a3f..7153a82e20 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -131,7 +131,7 @@ libxlOSEventHookInfoFree(void *obj)
 }
 
 static void
-libxlFDEventCallback(int watch ATTRIBUTE_UNUSED,
+libxlFDEventCallback(int watch G_GNUC_UNUSED,
  int fd,
  int vir_events,
  void *fd_info)
@@ -185,8 +185,8 @@ libxlFDRegisterEventHook(void *priv,
 }
 
 static int
-libxlFDModifyEventHook(void *priv ATTRIBUTE_UNUSED,
-   int fd ATTRIBUTE_UNUSED,
+libxlFDModifyEventHook(void *priv G_GNUC_UNUSED,
+

[libvirt] [PATCH 26/35] test: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/test/test_driver.c | 80 +-
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 19b8158ed6..d2a4e100bb 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1441,7 +1441,7 @@ testDriverCloseInternal(testDriverPtr driver)
 static virDrvOpenStatus
 testConnectOpen(virConnectPtr conn,
 virConnectAuthPtr auth,
-virConfPtr conf ATTRIBUTE_UNUSED,
+virConfPtr conf G_GNUC_UNUSED,
 unsigned int flags)
 {
 int ret;
@@ -1484,42 +1484,42 @@ testConnectClose(virConnectPtr conn)
 }
 
 
-static int testConnectGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
+static int testConnectGetVersion(virConnectPtr conn G_GNUC_UNUSED,
  unsigned long *hvVer)
 {
 *hvVer = 2;
 return 0;
 }
 
-static char *testConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
+static char *testConnectGetHostname(virConnectPtr conn G_GNUC_UNUSED)
 {
 return virGetHostname();
 }
 
 
-static int testConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int testConnectIsSecure(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 1;
 }
 
-static int testConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int testConnectIsEncrypted(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 0;
 }
 
-static int testConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int testConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 {
 return 1;
 }
 
-static int testConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
-  const char *type ATTRIBUTE_UNUSED)
+static int testConnectGetMaxVcpus(virConnectPtr conn G_GNUC_UNUSED,
+  const char *type G_GNUC_UNUSED)
 {
 return 32;
 }
 
 static char *
-testConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
+testConnectBaselineCPU(virConnectPtr conn G_GNUC_UNUSED,
const char **xmlCPUs,
unsigned int ncpus,
unsigned int flags)
@@ -1570,7 +1570,7 @@ static char *testConnectGetCapabilities(virConnectPtr 
conn)
 }
 
 static char *
-testConnectGetSysinfo(virConnectPtr conn ATTRIBUTE_UNUSED,
+testConnectGetSysinfo(virConnectPtr conn G_GNUC_UNUSED,
   unsigned int flags)
 {
 char *ret;
@@ -1590,14 +1590,14 @@ testConnectGetSysinfo(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 }
 
 static const char *
-testConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED)
+testConnectGetType(virConnectPtr conn G_GNUC_UNUSED)
 {
 return "TEST";
 }
 
 
 static int
-testConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED,
+testConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED,
int feature)
 {
 switch ((virDrvFeature) feature) {
@@ -1662,7 +1662,7 @@ static int testDomainIsPersistent(virDomainPtr dom)
 return ret;
 }
 
-static int testDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED)
+static int testDomainIsUpdated(virDomainPtr dom G_GNUC_UNUSED)
 {
 return 0;
 }
@@ -1723,8 +1723,8 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
 static virDomainPtr
 testDomainCreateXMLWithFiles(virConnectPtr conn,
  const char *xml,
- unsigned int nfiles ATTRIBUTE_UNUSED,
- int *files ATTRIBUTE_UNUSED,
+ unsigned int nfiles G_GNUC_UNUSED,
+ int *files G_GNUC_UNUSED,
  unsigned int flags)
 {
 return testDomainCreateXML(conn, xml, flags);
@@ -2557,7 +2557,7 @@ testDomainCoreDump(virDomainPtr domain,
 
 
 static char *
-testDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED)
+testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED)
 {
 char *ret;
 
@@ -2567,8 +2567,8 @@ testDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED)
 
 
 static int
-testDomainGetLaunchSecurityInfo(virDomainPtr domain ATTRIBUTE_UNUSED,
-virTypedParameterPtr *params ATTRIBUTE_UNUSED,
+testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED,
+virTypedParameterPtr *params G_GNUC_UNUSED,
 int *nparams,
 unsigned int flags)
 {
@@ -2898,8 +2898,8 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int 
nrCpus,
 
 static int
 testDomainSetUserPassword(virDomainPtr dom,
-  const char *user ATTRIBUTE_UNUSED,
-  const char *password ATTRIBUTE_UNUSED,
+  const char *user G_GNUC_UNUSED,
+  const char *password G_GNUC_UNUSED,
   unsigned int flags)
 {
 int ret = -1;
@@ -4282,8 +4282,8 @@ static int testNodeGetCells

[libvirt] [PATCH 14/35] locking: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/locking/lock_daemon.c  | 20 ++---
 src/locking/lock_daemon_config.c   |  2 +-
 src/locking/lock_daemon_dispatch.c | 32 ++--
 src/locking/lock_driver_lockd.c|  8 ++---
 src/locking/lock_driver_nop.c  | 48 +++---
 src/locking/lock_driver_sanlock.c  | 10 +++
 src/locking/lock_manager.c | 10 +++
 src/locking/sanlock_helper.c   |  6 ++--
 8 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index c12cb4ea0f..59167d7d31 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -140,7 +140,7 @@ virLockDaemonUnlock(virLockDaemonPtr lockd)
 }
 
 static void virLockDaemonLockSpaceDataFree(void *data,
-   const void *key ATTRIBUTE_UNUSED)
+   const void *key G_GNUC_UNUSED)
 {
 virLockSpaceFree(data);
 }
@@ -209,7 +209,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool 
privileged)
 
 
 static virNetServerPtr
-virLockDaemonNewServerPostExecRestart(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
+virLockDaemonNewServerPostExecRestart(virNetDaemonPtr dmn G_GNUC_UNUSED,
   const char *name,
   virJSONValuePtr object,
   void *opaque)
@@ -481,8 +481,8 @@ virLockDaemonUnixSocketPaths(bool privileged,
 
 
 static void
-virLockDaemonErrorHandler(void *opaque ATTRIBUTE_UNUSED,
-  virErrorPtr err ATTRIBUTE_UNUSED)
+virLockDaemonErrorHandler(void *opaque G_GNUC_UNUSED,
+  virErrorPtr err G_GNUC_UNUSED)
 {
 /* Don't do anything, since logging infrastructure already
  * took care of reporting the error */
@@ -552,16 +552,16 @@ virLockDaemonVersion(const char *argv0)
 
 static void
 virLockDaemonShutdownHandler(virNetDaemonPtr dmn,
- siginfo_t *sig ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED)
+ siginfo_t *sig G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED)
 {
 virNetDaemonQuit(dmn);
 }
 
 static void
 virLockDaemonExecRestartHandler(virNetDaemonPtr dmn,
-siginfo_t *sig ATTRIBUTE_UNUSED,
-void *opaque ATTRIBUTE_UNUSED)
+siginfo_t *sig G_GNUC_UNUSED,
+void *opaque G_GNUC_UNUSED)
 {
 execRestart = true;
 virNetDaemonQuit(dmn);
@@ -590,7 +590,7 @@ struct virLockDaemonClientReleaseData {
 
 static int
 virLockDaemonClientReleaseLockspace(void *payload,
-const void *name ATTRIBUTE_UNUSED,
+const void *name G_GNUC_UNUSED,
 void *opaque)
 {
 virLockSpacePtr lockspace = payload;
@@ -781,7 +781,7 @@ virLockDaemonClientNewPostExecRestart(virNetServerClientPtr 
client,
 
 
 static virJSONValuePtr
-virLockDaemonClientPreExecRestart(virNetServerClientPtr client 
ATTRIBUTE_UNUSED,
+virLockDaemonClientPreExecRestart(virNetServerClientPtr client G_GNUC_UNUSED,
   void *opaque)
 {
 virLockDaemonClientPtr priv = opaque;
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index 8df7cf89cd..f77d6c9017 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -62,7 +62,7 @@ virLockDaemonConfigFilePath(bool privileged, char 
**configfile)
 
 
 virLockDaemonConfigPtr
-virLockDaemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
+virLockDaemonConfigNew(bool privileged G_GNUC_UNUSED)
 {
 virLockDaemonConfigPtr data;
 
diff --git a/src/locking/lock_daemon_dispatch.c 
b/src/locking/lock_daemon_dispatch.c
index 7f3c806220..d68fd9cf01 100644
--- a/src/locking/lock_daemon_dispatch.c
+++ b/src/locking/lock_daemon_dispatch.c
@@ -36,9 +36,9 @@ VIR_LOG_INIT("locking.lock_daemon_dispatch");
 #include "lock_daemon_dispatch_stubs.h"
 
 static int
-virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server 
ATTRIBUTE_UNUSED,
+virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server 
G_GNUC_UNUSED,
 virNetServerClientPtr client,
-virNetMessagePtr msg 
ATTRIBUTE_UNUSED,
+virNetMessagePtr msg G_GNUC_UNUSED,
 virNetMessageErrorPtr rerr,
 
virLockSpaceProtocolAcquireResourceArgs *args)
 {
@@ -96,9 +96,9 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr 
server ATTRIBUTE_UNU
 
 
 static int
-virLockSpaceProtocolDispatchCreateResource(virNetServerPtr server 
ATTRIBUTE_UNUSED,
+virLo

[libvirt] [PATCH 12/35] esx: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/esx/esx_driver.c| 32 ++---
 src/esx/esx_interface_driver.c  | 10 -
 src/esx/esx_network_driver.c| 16 +++
 src/esx/esx_storage_backend_iscsi.c | 16 +++
 src/esx/esx_storage_driver.c| 16 +++
 src/esx/esx_vi.c| 20 +-
 src/esx/esx_vi_types.c  |  4 ++--
 7 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index d6d219c101..b7c80d5c43 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -825,7 +825,7 @@ esxConnectToVCenter(esxPrivate *priv,
  */
 static virDrvOpenStatus
 esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
-   virConfPtr conf ATTRIBUTE_UNUSED,
+   virConfPtr conf G_GNUC_UNUSED,
unsigned int flags)
 {
 virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
@@ -1097,7 +1097,7 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
 
 
 static const char *
-esxConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED)
+esxConnectGetType(virConnectPtr conn G_GNUC_UNUSED)
 {
 return "ESX";
 }
@@ -1852,7 +1852,7 @@ esxDomainDestroy(virDomainPtr dom)
 
 
 static char *
-esxDomainGetOSType(virDomainPtr domain ATTRIBUTE_UNUSED)
+esxDomainGetOSType(virDomainPtr domain G_GNUC_UNUSED)
 {
 char *osType;
 
@@ -3450,7 +3450,7 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
  *   SharesLevel 'low', 'normal' and 'high'.
  */
 static char *
-esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams)
+esxDomainGetSchedulerType(virDomainPtr domain G_GNUC_UNUSED, int *nparams)
 {
 char *type;
 
@@ -3736,13 +3736,13 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
 
 static int
 esxDomainMigratePrepare(virConnectPtr dconn,
-char **cookie ATTRIBUTE_UNUSED,
-int *cookielen ATTRIBUTE_UNUSED,
-const char *uri_in ATTRIBUTE_UNUSED,
+char **cookie G_GNUC_UNUSED,
+int *cookielen G_GNUC_UNUSED,
+const char *uri_in G_GNUC_UNUSED,
 char **uri_out,
 unsigned long flags,
-const char *dname ATTRIBUTE_UNUSED,
-unsigned long resource ATTRIBUTE_UNUSED)
+const char *dname G_GNUC_UNUSED,
+unsigned long resource G_GNUC_UNUSED)
 {
 esxPrivate *priv = dconn->privateData;
 
@@ -3763,12 +3763,12 @@ esxDomainMigratePrepare(virConnectPtr dconn,
 
 static int
 esxDomainMigratePerform(virDomainPtr domain,
-const char *cookie ATTRIBUTE_UNUSED,
-int cookielen ATTRIBUTE_UNUSED,
+const char *cookie G_GNUC_UNUSED,
+int cookielen G_GNUC_UNUSED,
 const char *uri,
 unsigned long flags,
 const char *dname,
-unsigned long bandwidth ATTRIBUTE_UNUSED)
+unsigned long bandwidth G_GNUC_UNUSED)
 {
 int result = -1;
 esxPrivate *priv = domain->conn->privateData;
@@ -3906,9 +3906,9 @@ esxDomainMigratePerform(virDomainPtr domain,
 
 static virDomainPtr
 esxDomainMigrateFinish(virConnectPtr dconn, const char *dname,
-   const char *cookie ATTRIBUTE_UNUSED,
-   int cookielen ATTRIBUTE_UNUSED,
-   const char *uri ATTRIBUTE_UNUSED,
+   const char *cookie G_GNUC_UNUSED,
+   int cookielen G_GNUC_UNUSED,
+   const char *uri G_GNUC_UNUSED,
unsigned long flags)
 {
 virCheckFlags(ESX_MIGRATION_FLAGS, NULL);
@@ -4060,7 +4060,7 @@ esxDomainIsPersistent(virDomainPtr domain)
 
 
 static int
-esxDomainIsUpdated(virDomainPtr domain ATTRIBUTE_UNUSED)
+esxDomainIsUpdated(virDomainPtr domain G_GNUC_UNUSED)
 {
 /* ESX domains never have a persistent state that differs from
  * current state.  However, we do want to check for existence.  */
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index e3b41164e7..76dcb3d53c 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -107,7 +107,7 @@ esxConnectListInterfaces(virConnectPtr conn, char **const 
names, int maxnames)
 
 
 static int
-esxConnectNumOfDefinedInterfaces(virConnectPtr conn ATTRIBUTE_UNUSED)
+esxConnectNumOfDefinedInterfaces(virConnectPtr conn G_GNUC_UNUSED)
 {
 /* ESX interfaces are always active */
 return 0;
@@ -116,9 +116,9 @@ esxConnectNumOfDefinedInterfaces(virConnectPtr conn 
ATTRIBUTE_UNUSED)
 
 
 static int
-esxConnectListDefinedInterfaces(virConnectPtr conn ATTRIBUTE_UNUSED,
-   

[libvirt] [PATCH 02/35] apibuild: ignore GLib macros too

2019-10-14 Thread Ján Tomko
Add an exception for the GLib versions of the macros we already ignore.

Signed-off-by: Ján Tomko 
---
 docs/apibuild.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 92886e1276..b11d3fd5a9 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -73,6 +73,8 @@ admin_included_files = {
 ignored_words = {
   "ATTRIBUTE_UNUSED": (0, "macro keyword"),
   "ATTRIBUTE_SENTINEL": (0, "macro keyword"),
+  "G_GNUC_UNUSED": (0, "macro keyword"),
+  "G_GNUC_NULL_TERMINATED": (0, "macro keyword"),
   "VIR_DEPRECATED": (0, "macro keyword"),
   "VIR_EXPORT_VAR": (0, "macro keyword"),
   "WINAPI": (0, "Windows keyword"),
-- 
2.19.2

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

[libvirt] [PATCH 11/35] cpu: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/cpu/cpu_arm.c   | 14 +++---
 src/cpu/cpu_ppc64.c | 10 +-
 src/cpu/cpu_s390.c  |  6 +++---
 src/cpu/cpu_x86.c   |  4 ++--
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index 65d69c00af..d464d7add2 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -71,10 +71,10 @@ virCPUarmUpdate(virCPUDefPtr guest,
 
 static virCPUDefPtr
 virCPUarmBaseline(virCPUDefPtr *cpus,
-  unsigned int ncpus ATTRIBUTE_UNUSED,
-  virDomainCapsCPUModelsPtr models ATTRIBUTE_UNUSED,
-  const char **features ATTRIBUTE_UNUSED,
-  bool migratable ATTRIBUTE_UNUSED)
+  unsigned int ncpus G_GNUC_UNUSED,
+  virDomainCapsCPUModelsPtr models G_GNUC_UNUSED,
+  const char **features G_GNUC_UNUSED,
+  bool migratable G_GNUC_UNUSED)
 {
 virCPUDefPtr cpu = NULL;
 
@@ -91,9 +91,9 @@ virCPUarmBaseline(virCPUDefPtr *cpus,
 }
 
 static virCPUCompareResult
-virCPUarmCompare(virCPUDefPtr host ATTRIBUTE_UNUSED,
- virCPUDefPtr cpu ATTRIBUTE_UNUSED,
- bool failMessages ATTRIBUTE_UNUSED)
+virCPUarmCompare(virCPUDefPtr host G_GNUC_UNUSED,
+ virCPUDefPtr cpu G_GNUC_UNUSED,
+ bool failMessages G_GNUC_UNUSED)
 {
 return VIR_CPU_COMPARE_IDENTICAL;
 }
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 9c75c4a2f2..5194c2adc1 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -276,7 +276,7 @@ ppc64MapFree(struct ppc64_map *map)
 }
 
 static int
-ppc64VendorParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
+ppc64VendorParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED,
  const char *name,
  void *data)
 {
@@ -678,7 +678,7 @@ virCPUppc64GetHost(virCPUDefPtr cpu,
 
 static int
 virCPUppc64Update(virCPUDefPtr guest,
-  const virCPUDef *host ATTRIBUTE_UNUSED)
+  const virCPUDef *host G_GNUC_UNUSED)
 {
 /*
  * - host-passthrough doesn't even get here
@@ -697,9 +697,9 @@ virCPUppc64Update(virCPUDefPtr guest,
 static virCPUDefPtr
 virCPUppc64Baseline(virCPUDefPtr *cpus,
 unsigned int ncpus,
-virDomainCapsCPUModelsPtr models ATTRIBUTE_UNUSED,
-const char **features ATTRIBUTE_UNUSED,
-bool migratable ATTRIBUTE_UNUSED)
+virDomainCapsCPUModelsPtr models G_GNUC_UNUSED,
+const char **features G_GNUC_UNUSED,
+bool migratable G_GNUC_UNUSED)
 {
 struct ppc64_map *map;
 const struct ppc64_model *model;
diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c
index 8f52924383..712e249f23 100644
--- a/src/cpu/cpu_s390.c
+++ b/src/cpu/cpu_s390.c
@@ -31,9 +31,9 @@
 static const virArch archs[] = { VIR_ARCH_S390, VIR_ARCH_S390X };
 
 static virCPUCompareResult
-virCPUs390Compare(virCPUDefPtr host ATTRIBUTE_UNUSED,
-  virCPUDefPtr cpu ATTRIBUTE_UNUSED,
-  bool failMessages ATTRIBUTE_UNUSED)
+virCPUs390Compare(virCPUDefPtr host G_GNUC_UNUSED,
+  virCPUDefPtr cpu G_GNUC_UNUSED,
+  bool failMessages G_GNUC_UNUSED)
 {
 /* s390 relies on QEMU to perform all runability checking. Return
  * VIR_CPU_COMPARE_IDENTICAL to bypass Libvirt checking.
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 32b9836dd5..b2b16ca512 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3397,7 +3397,7 @@ virCPUx86FeatureIsMSR(const char *name)
  */
 bool
 virCPUx86FeatureFilterSelectMSR(const char *name,
-void *opaque ATTRIBUTE_UNUSED)
+void *opaque G_GNUC_UNUSED)
 {
 return virCPUx86FeatureIsMSR(name);
 }
@@ -3413,7 +3413,7 @@ virCPUx86FeatureFilterSelectMSR(const char *name,
  */
 bool
 virCPUx86FeatureFilterDropMSR(const char *name,
-  void *opaque ATTRIBUTE_UNUSED)
+  void *opaque G_GNUC_UNUSED)
 {
 return !virCPUx86FeatureIsMSR(name);
 }
-- 
2.19.2

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

[libvirt] [PATCH 07/35] access: use G_GNUC_UNUSED

2019-10-14 Thread Ján Tomko
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko 
---
 src/access/viraccessdrivernop.c| 90 +++---
 src/access/viraccessdriverpolkit.c |  4 +-
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/src/access/viraccessdrivernop.c b/src/access/viraccessdrivernop.c
index 5e9d9db759..5772a9c5c6 100644
--- a/src/access/viraccessdrivernop.c
+++ b/src/access/viraccessdrivernop.c
@@ -23,101 +23,101 @@
 #include "access/viraccessdrivernop.h"
 
 static int
-virAccessDriverNopCheckConnect(virAccessManagerPtr manager ATTRIBUTE_UNUSED,
-   const char *driverName ATTRIBUTE_UNUSED,
-   virAccessPermConnect perm ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckConnect(virAccessManagerPtr manager G_GNUC_UNUSED,
+   const char *driverName G_GNUC_UNUSED,
+   virAccessPermConnect perm G_GNUC_UNUSED)
 {
 return 1; /* Allow */
 }
 
 static int
-virAccessDriverNopCheckDomain(virAccessManagerPtr manager ATTRIBUTE_UNUSED,
-  const char *driverName ATTRIBUTE_UNUSED,
-  virDomainDefPtr domain ATTRIBUTE_UNUSED,
-  virAccessPermDomain perm ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckDomain(virAccessManagerPtr manager G_GNUC_UNUSED,
+  const char *driverName G_GNUC_UNUSED,
+  virDomainDefPtr domain G_GNUC_UNUSED,
+  virAccessPermDomain perm G_GNUC_UNUSED)
 {
 return 1; /* Allow */
 }
 
 static int
-virAccessDriverNopCheckInterface(virAccessManagerPtr manager ATTRIBUTE_UNUSED,
- const char *driverName ATTRIBUTE_UNUSED,
- virInterfaceDefPtr iface ATTRIBUTE_UNUSED,
- virAccessPermInterface perm ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckInterface(virAccessManagerPtr manager G_GNUC_UNUSED,
+ const char *driverName G_GNUC_UNUSED,
+ virInterfaceDefPtr iface G_GNUC_UNUSED,
+ virAccessPermInterface perm G_GNUC_UNUSED)
 {
 return 1; /* Allow */
 }
 
 static int
-virAccessDriverNopCheckNetwork(virAccessManagerPtr manager ATTRIBUTE_UNUSED,
-   const char *driverName ATTRIBUTE_UNUSED,
-   virNetworkDefPtr network ATTRIBUTE_UNUSED,
-   virAccessPermNetwork perm ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckNetwork(virAccessManagerPtr manager G_GNUC_UNUSED,
+   const char *driverName G_GNUC_UNUSED,
+   virNetworkDefPtr network G_GNUC_UNUSED,
+   virAccessPermNetwork perm G_GNUC_UNUSED)
 {
 return 1; /* Allow */
 }
 
 static int
-virAccessDriverNopCheckNetworkPort(virAccessManagerPtr manager 
ATTRIBUTE_UNUSED,
-   const char *driverName ATTRIBUTE_UNUSED,
-   virNetworkDefPtr network ATTRIBUTE_UNUSED,
-   virNetworkPortDefPtr port ATTRIBUTE_UNUSED,
-   virAccessPermNetworkPort perm 
ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckNetworkPort(virAccessManagerPtr manager G_GNUC_UNUSED,
+   const char *driverName G_GNUC_UNUSED,
+   virNetworkDefPtr network G_GNUC_UNUSED,
+   virNetworkPortDefPtr port G_GNUC_UNUSED,
+   virAccessPermNetworkPort perm G_GNUC_UNUSED)
 {
 return 1; /* Allow */
 }
 
 static int
-virAccessDriverNopCheckNodeDevice(virAccessManagerPtr manager ATTRIBUTE_UNUSED,
-  const char *driverName ATTRIBUTE_UNUSED,
-  virNodeDeviceDefPtr nodedev ATTRIBUTE_UNUSED,
-  virAccessPermNodeDevice perm 
ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckNodeDevice(virAccessManagerPtr manager G_GNUC_UNUSED,
+  const char *driverName G_GNUC_UNUSED,
+  virNodeDeviceDefPtr nodedev G_GNUC_UNUSED,
+  virAccessPermNodeDevice perm G_GNUC_UNUSED)
 {
 return 1; /* Allow */
 }
 
 static int
-virAccessDriverNopCheckNWFilter(virAccessManagerPtr manager ATTRIBUTE_UNUSED,
-const char *driverName ATTRIBUTE_UNUSED,
-virNWFilterDefPtr nwfilter ATTRIBUTE_UNUSED,
-virAccessPermNWFilter perm ATTRIBUTE_UNUSED)
+virAccessDriverNopCheckNWFilter(virAccessManagerPtr manager G_GNUC_UNUSED,
+const char *driverName G_GNUC_UNUSED,
+virNWFilterDefPtr nwfilter G_GNUC_UNUSED,
+  

Re: [libvirt] [PATCH] util: ignore SIGPIPE when writingtostderr/stdout

2019-10-14 Thread wang.yechao255
> At this point you are int he child QEMU process.
>
> virFork resets all signal handlers back to their default setting so that
> libvirtd's choice of signals doesn't impact the child process.
>
> Perhaps the right answer is to use pthread_sigmask to block SIGPIPE
> until just before we execve

Thanks,  I'll push another patch later.

---
Best wishes
Wang Yechao--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] util: ignore SIGPIPE when writing tostderr/stdout

2019-10-14 Thread Daniel P . Berrangé
On Mon, Oct 14, 2019 at 06:46:54PM +0800, wang.yechao...@zte.com.cn wrote:
> > On Sat, Oct 12, 2019 at 16:04:11 +0800, Wang Yechao wrote:
> > > libvirtd's stderr/stdout redirected to journald by default, so if
> > > the journald has stopped, libvirtd and libvirtd's child process
> > > will receive SIGPIPE signal when writing logs to stderr/stdout.
> > >
> > > journald stopped reasons:
> > > 1. manual command "systemctl stop systemd-journald.service"
> > > 2. oom killer kill it.
> >
> > What is configuration of logging for libvirtd? Libvirtd should not log
> > to stdout by default so I think this is more of a misconfiguration than
> > something needing fix in code.
> >
> In my env, the libvirtd.conf like that:
> "
> log_level = 1
> log_outputs="2:file:/var/log/libvirt/libvirtd.log"
> "
> 
> Libvirtd works fine in this configuration, if i stop the journald.serivce.
> But the child process that forked by libvirtd, will face this problem:
> 
> # virsh create vm.xml
> error: Failed to create domain from vm.xml
> error: internal error: Child process (LC_ALL=C 
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin /usr/libexec/qemu-kvm 
> -S -no-user-config -nodefaults -nographic -machine none,accel=kvm:tcg -qmp 
> unix:/usr/local/var/lib/libvirt/qemu/qmp-vtKZqu/qmp.monitor,server,nowait 
> -pidfile /usr/local/var/lib/libvirt/qemu/qmp-vtKZqu/qmp.pid -daemonize) 
> unexpected fatal signal 13
> 
> 
> The version of libvirt that i test:
> # virsh version
> Compiled against library: libvirt 5.9.0
> Using library: libvirt 5.9.0
> Using API: QEMU 5.9.0
> 
> The child process recieve signal SIGPIPE, backtrace as follows:
> Program received signal SIGPIPE, Broken pipe.
> [Switching to Thread 0x7fa44dd25700 (LWP 67788)]
> 0x7fa45b63779d in write () from /lib64/libpthread.so.0
> (gdb) bt
> #0  0x7fa45b63779d in write () from /lib64/libpthread.so.0
> #1  0x7fa45e51f6ae in safewrite (fd=fd@entry=2, 
> buf=buf@entry=0x7fa43800e6e0, count=76) at util/virfile.c:1089
> #2  0x7fa45e53ba85 in virLogOutputToFd 
> (source=source@entry=0x7fa45ea9b8a0 , 
> priority=priority@entry=VIR_LOG_DEBUG,
> filename=filename@entry=0x7fa45e7829b8 "util/virfile.c", 
> linenr=linenr@entry=114,
> funcname=funcname@entry=0x7fa45e783d64 <__func__.19089> "virFileClose", 
> timestamp=timestamp@entry=0x7fa44dd23af0 "2019-10-14 09:11:06.087+",
> metadata=metadata@entry=0x0, flags=flags@entry=0, rawstr=0x7fa43800ed20 
> "Closed fd 3",
> str=0x7fa4380108d0 "67788: debug : virFileClose:114 : Closed fd 3\n", 
> data=data@entry=0x2) at util/virlog.c:738
> #3  0x7fa45e53cdae in virLogVMessage (source=0x7fa45ea9b8a0 , 
> priority=VIR_LOG_DEBUG, filename=0x7fa45e7829b8 "util/virfile.c",
> linenr=114, funcname=0x7fa45e783d64 <__func__.19089> "virFileClose", 
> metadata=0x0, fmt=fmt@entry=0x7fa45e782a48 "Closed fd %d",
> vargs=vargs@entry=0x7fa44dd23b70) at util/virlog.c:682
> #4  0x7fa45e53cfc7 in virLogMessage (source=source@entry=0x7fa45ea9b8a0 
> , priority=priority@entry=VIR_LOG_DEBUG,
> filename=filename@entry=0x7fa45e7829b8 "util/virfile.c", 
> linenr=linenr@entry=114,
> funcname=funcname@entry=0x7fa45e783d64 <__func__.19089> "virFileClose", 
> metadata=metadata@entry=0x0, fmt=fmt@entry=0x7fa45e782a48 "Closed fd %d")
> at util/virlog.c:556
> #5  0x7fa45e51ebaa in virFileClose (fdptr=fdptr@entry=0x7fa44dd24148,
> flags=flags@entry=(VIR_FILE_CLOSE_PRESERVE_ERRNO | 
> VIR_FILE_CLOSE_IGNORE_EBADF)) at util/virfile.c:114
> #6  0x7fa45e4efae7 in virCommandMassClose (childerr=, 
> childout=33, childin=31, cmd=0x7fa4380119f0) at util/vircommand.c:525
> #7  virExec (cmd=cmd@entry=0x7fa4380119f0) at util/vircommand.c:656

At this point you are int he child QEMU process.

virFork resets all signal handlers back to their default setting so that
libvirtd's choice of signals doesn't impact the child process.

Perhaps the right answer is to use pthread_sigmask to block SIGPIPE
until just before we execve

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] util: ignore SIGPIPE when writing tostderr/stdout

2019-10-14 Thread wang.yechao255
> On Sat, Oct 12, 2019 at 04:04:11PM +0800, Wang Yechao wrote:
> > libvirtd's stderr/stdout redirected to journald by default, so if
> > the journald has stopped, libvirtd and libvirtd's child process
> > will receive SIGPIPE signal when writing logs to stderr/stdout.
> >
> > journald stopped reasons:
> > 1. manual command "systemctl stop systemd-journald.service"
>
> Don't do that then IMHO.

I just do it to reproduce this scenes.

> > 2. oom killer kill it.
> > ...
>
> If OOM killer picked journald, then it is game over for the host IMHO
> and thed right answer is a reboot. This would be very surprising though.
> OOM killer is more likely to pick QEMU or libvirtd as they're bigger
> targets.
>

Reboot is the best way. But sometimes, the oom is caused by a abnormal process,
if we stop it, the system's free memory will back to normal. And i think it's
no need to reboot.

> >
> > Signed-off-by: Wang Yechao 
> > ---
> >  src/util/virlog.c | 8 
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/src/util/virlog.c b/src/util/virlog.c
> > index 4c76fbc..127e121 100644
> > --- a/src/util/virlog.c
> > +++ b/src/util/virlog.c
> > @@ -39,6 +39,7 @@
> >  # include 
> >  #endif
> >  #include 
> > +#include 
> >
> >  #include "virerror.h"
> >  #include "virlog.h"
> > @@ -732,6 +733,9 @@ virLogOutputToFd(virLogSourcePtr source 
> > ATTRIBUTE_UNUSED,
> >  if (fd < 0)
> >  return;
> >
> > +if (fd == STDERR_FILENO || fd == STDOUT_FILENO)
> > +signal(SIGPIPE, SIG_IGN);
>
> This is very wrong
>
> This code is run in both client & server, so we're messing with SIGPIPE
> in applications that link to libvirt.so.
>

Thanks to point my fault.

> The use of signal() is not safe in multi-threaded applications.
>
> In libvirtd we have set SIGPIPE to ignored already when starting up
> libvirtd.

Can set SIGPIPE to ignored in the child process that forked by libvirtd ?

---
Best wishes
Wang Yechao--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] util: ignore SIGPIPE when writing tostderr/stdout

2019-10-14 Thread wang.yechao255
> On Sat, Oct 12, 2019 at 16:04:11 +0800, Wang Yechao wrote:
> > libvirtd's stderr/stdout redirected to journald by default, so if
> > the journald has stopped, libvirtd and libvirtd's child process
> > will receive SIGPIPE signal when writing logs to stderr/stdout.
> >
> > journald stopped reasons:
> > 1. manual command "systemctl stop systemd-journald.service"
> > 2. oom killer kill it.
>
> What is configuration of logging for libvirtd? Libvirtd should not log
> to stdout by default so I think this is more of a misconfiguration than
> something needing fix in code.
>
In my env, the libvirtd.conf like that:
"
log_level = 1
log_outputs="2:file:/var/log/libvirt/libvirtd.log"
"

Libvirtd works fine in this configuration, if i stop the journald.serivce.
But the child process that forked by libvirtd, will face this problem:

# virsh create vm.xml
error: Failed to create domain from vm.xml
error: internal error: Child process (LC_ALL=C 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin /usr/libexec/qemu-kvm -S 
-no-user-config -nodefaults -nographic -machine none,accel=kvm:tcg -qmp 
unix:/usr/local/var/lib/libvirt/qemu/qmp-vtKZqu/qmp.monitor,server,nowait 
-pidfile /usr/local/var/lib/libvirt/qemu/qmp-vtKZqu/qmp.pid -daemonize) 
unexpected fatal signal 13


The version of libvirt that i test:
# virsh version
Compiled against library: libvirt 5.9.0
Using library: libvirt 5.9.0
Using API: QEMU 5.9.0

The child process recieve signal SIGPIPE, backtrace as follows:
Program received signal SIGPIPE, Broken pipe.
[Switching to Thread 0x7fa44dd25700 (LWP 67788)]
0x7fa45b63779d in write () from /lib64/libpthread.so.0
(gdb) bt
#0  0x7fa45b63779d in write () from /lib64/libpthread.so.0
#1  0x7fa45e51f6ae in safewrite (fd=fd@entry=2, 
buf=buf@entry=0x7fa43800e6e0, count=76) at util/virfile.c:1089
#2  0x7fa45e53ba85 in virLogOutputToFd (source=source@entry=0x7fa45ea9b8a0 
, priority=priority@entry=VIR_LOG_DEBUG,
filename=filename@entry=0x7fa45e7829b8 "util/virfile.c", 
linenr=linenr@entry=114,
funcname=funcname@entry=0x7fa45e783d64 <__func__.19089> "virFileClose", 
timestamp=timestamp@entry=0x7fa44dd23af0 "2019-10-14 09:11:06.087+",
metadata=metadata@entry=0x0, flags=flags@entry=0, rawstr=0x7fa43800ed20 
"Closed fd 3",
str=0x7fa4380108d0 "67788: debug : virFileClose:114 : Closed fd 3\n", 
data=data@entry=0x2) at util/virlog.c:738
#3  0x7fa45e53cdae in virLogVMessage (source=0x7fa45ea9b8a0 , 
priority=VIR_LOG_DEBUG, filename=0x7fa45e7829b8 "util/virfile.c",
linenr=114, funcname=0x7fa45e783d64 <__func__.19089> "virFileClose", 
metadata=0x0, fmt=fmt@entry=0x7fa45e782a48 "Closed fd %d",
vargs=vargs@entry=0x7fa44dd23b70) at util/virlog.c:682
#4  0x7fa45e53cfc7 in virLogMessage (source=source@entry=0x7fa45ea9b8a0 
, priority=priority@entry=VIR_LOG_DEBUG,
filename=filename@entry=0x7fa45e7829b8 "util/virfile.c", 
linenr=linenr@entry=114,
funcname=funcname@entry=0x7fa45e783d64 <__func__.19089> "virFileClose", 
metadata=metadata@entry=0x0, fmt=fmt@entry=0x7fa45e782a48 "Closed fd %d")
at util/virlog.c:556
#5  0x7fa45e51ebaa in virFileClose (fdptr=fdptr@entry=0x7fa44dd24148,
flags=flags@entry=(VIR_FILE_CLOSE_PRESERVE_ERRNO | 
VIR_FILE_CLOSE_IGNORE_EBADF)) at util/virfile.c:114
#6  0x7fa45e4efae7 in virCommandMassClose (childerr=, 
childout=33, childin=31, cmd=0x7fa4380119f0) at util/vircommand.c:525
#7  virExec (cmd=cmd@entry=0x7fa4380119f0) at util/vircommand.c:656
#8  0x7fa45e50d374 in virCommandRunAsync (cmd=cmd@entry=0x7fa4380119f0, 
pid=pid@entry=0x0) at util/vircommand.c:2644
#9  0x7fa45e50d6c6 in virCommandRun (cmd=0x7fa4380119f0, 
exitstatus=exitstatus@entry=0x7fa44dd24490) at util/vircommand.c:2463
#10 0x7fa418bcc9b9 in qemuProcessQMPLaunch (proc=0x7fa43800f0e0) at 
qemu/qemu_process.c:8605


If i change the log_level to 3, it can avoid this scene. But i want INFO 
messages in my logfile.

> For logging to the journal we use different means.
>
> > ...
> >
> > Signed-off-by: Wang Yechao 
> > ---
> >  src/util/virlog.c | 8 
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/src/util/virlog.c b/src/util/virlog.c
> > index 4c76fbc..127e121 100644
> > --- a/src/util/virlog.c
> > +++ b/src/util/virlog.c
> > @@ -39,6 +39,7 @@
> >  # include 
> >  #endif
> >  #include 
> > +#include 
> >
> >  #include "virerror.h"
> >  #include "virlog.h"
> > @@ -732,6 +733,9 @@ virLogOutputToFd(virLogSourcePtr source 
> > ATTRIBUTE_UNUSED,
> >  if (fd < 0)
> >  return;
> >
> > +if (fd == STDERR_FILENO || fd == STDOUT_FILENO)
> > +signal(SIGPIPE, SIG_IGN);
>
> man signal says:
>
> The effects of signal() in a multithreaded process are unspecified.
>

I didn't notice the effects of signal, thank you for pointing out.

And is there any good way to avoid this other than change the log_level ?

---
Best wishes
Wang Yechao--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] util: ignore SIGPIPE when writing to stderr/stdout

2019-10-14 Thread Daniel P . Berrangé
On Sat, Oct 12, 2019 at 04:04:11PM +0800, Wang Yechao wrote:
> libvirtd's stderr/stdout redirected to journald by default, so if
> the journald has stopped, libvirtd and libvirtd's child process
> will receive SIGPIPE signal when writing logs to stderr/stdout.
> 
> journald stopped reasons:
> 1. manual command "systemctl stop systemd-journald.service"

Don't do that then IMHO.

> 2. oom killer kill it.
> ...

If OOM killer picked journald, then it is game over for the host IMHO
and thed right answer is a reboot. This would be very surprising though.
OOM killer is more likely to pick QEMU or libvirtd as they're bigger
targets.

> 
> Signed-off-by: Wang Yechao 
> ---
>  src/util/virlog.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/util/virlog.c b/src/util/virlog.c
> index 4c76fbc..127e121 100644
> --- a/src/util/virlog.c
> +++ b/src/util/virlog.c
> @@ -39,6 +39,7 @@
>  # include 
>  #endif
>  #include 
> +#include 
>  
>  #include "virerror.h"
>  #include "virlog.h"
> @@ -732,6 +733,9 @@ virLogOutputToFd(virLogSourcePtr source ATTRIBUTE_UNUSED,
>  if (fd < 0)
>  return;
>  
> +if (fd == STDERR_FILENO || fd == STDOUT_FILENO)
> +signal(SIGPIPE, SIG_IGN);

This is very wrong

This code is run in both client & server, so we're messing with SIGPIPE
in applications that link to libvirt.so.

The use of signal() is not safe in multi-threaded applications.

In libvirtd we have set SIGPIPE to ignored already when starting up
libvirtd.


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] Question about migration confirm phase

2019-10-14 Thread Jiri Denemark
On Fri, Oct 11, 2019 at 23:18:29 +, Jim Fehlig wrote:
> I've been investigating a lockd lock ordering bug in a migration error 
> handling 
> path in the libxl driver. In the perform phase, the src calls 
> virDomainLockProcessPause to release the lock before sending the VM to dst. 
> In 
> this case the send fails for other reasons and an attempt is made to 
> reacquire 
> the lock with virDomainLockProcessResume. But that fails since the dst has 
> not 
> finished cleaning up the failed VM and releasing the lock it acquired when 
> starting to receive the VM. My immediate reaction was "why not reacquire the 
> lock in the confirm phase", but then I saw my older comment a few lines later 
> in 
> the perform phase code
> 
>  /*
>   * Confirm phase will not be executed if perform fails. End the
>   * job started in begin phase.
>   */
> 
> Is that just a bug in the implementation, or is it intended to skip the 
> confirm 
> phase if perform fails?

It's intended. The Perform phase runs on the source hosts so why should
we call Confirm to let the source know about the failure? But of course,
the source has to cleanup after the failed migration similarly to what
Confirm would do.

Jirka

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


Re: [libvirt] [PATCH] util: ignore SIGPIPE when writing to stderr/stdout

2019-10-14 Thread Peter Krempa
On Sat, Oct 12, 2019 at 16:04:11 +0800, Wang Yechao wrote:
> libvirtd's stderr/stdout redirected to journald by default, so if
> the journald has stopped, libvirtd and libvirtd's child process
> will receive SIGPIPE signal when writing logs to stderr/stdout.
> 
> journald stopped reasons:
> 1. manual command "systemctl stop systemd-journald.service"
> 2. oom killer kill it.

What is configuration of logging for libvirtd? Libvirtd should not log
to stdout by default so I think this is more of a misconfiguration than
something needing fix in code.

For logging to the journal we use different means.

> ...
> 
> Signed-off-by: Wang Yechao 
> ---
>  src/util/virlog.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/util/virlog.c b/src/util/virlog.c
> index 4c76fbc..127e121 100644
> --- a/src/util/virlog.c
> +++ b/src/util/virlog.c
> @@ -39,6 +39,7 @@
>  # include 
>  #endif
>  #include 
> +#include 
>  
>  #include "virerror.h"
>  #include "virlog.h"
> @@ -732,6 +733,9 @@ virLogOutputToFd(virLogSourcePtr source ATTRIBUTE_UNUSED,
>  if (fd < 0)
>  return;
>  
> +if (fd == STDERR_FILENO || fd == STDOUT_FILENO)
> +signal(SIGPIPE, SIG_IGN);

man signal says:

The effects of signal() in a multithreaded process are unspecified.

NACK

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