Re: [PATCH 04/14] softmmu: remove '-usbdevice' command line option

2021-02-24 Thread Thomas Huth

On 24/02/2021 15.10, Daniel P. Berrangé wrote:

On Wed, Feb 24, 2021 at 02:58:19PM +0100, Thomas Huth wrote:

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

This was replaced by the '-device usb-DEV' option.

Signed-off-by: Daniel P. Berrangé 
---
   docs/system/deprecated.rst   |  9 ---
   docs/system/removed-features.rst |  9 +++
   softmmu/vl.c | 42 
   3 files changed, 9 insertions(+), 51 deletions(-)


Last time I tried to remove -usbdevice, there was some concerns that
-usbdevice braille might still be useful for some people, see the thread
that started here:

  https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg00651.html

(and Gerd's summary here:
https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg01520.html )


Urgh, so the current deprecation docs are a bit misleading by saying
-usbdevice is directly mapped to -device.


So we might need a new "sugared" option like "-braille" instead before we
can fully remove -usbdevice? ... or we just keep -usbdevice as a bittersweet
remainder?


I'm not going to implement new CLI options, and if that's needed, we
ought to re-start the clock on the deprecation at that point. So this
points towards just removing the deprecation warning that exists
today. Or alternatively drop support for -usbdevice, except for the
braille type.


After that discussion in 2018, I've removed all of the "annoying" -usbdevice 
parameters already (see commit 99761176eeaf8525). I then more or less waited 
for someone to step up and implement "-braille", but it never happened and I 
forgot about the removal of the remaining -usbdevice parameters. Thinking 
about this again, replacing "-usbdevice braille" with a "-braille usb" does 
indeed not buy us much, so I think the best is maybe to keep the simple 
devices and braille around, update our documentation and remove the 
deprecation warning instead.


 Thomas




Re: [PATCH] block/file-posix: Optimize for macOS

2021-02-24 Thread Akihiko Odaki
2021年2月25日(木) 2:31 Kevin Wolf :
>
> Am 24.02.2021 um 17:27 hat Stefan Hajnoczi geschrieben:
> > On Fri, Feb 19, 2021 at 05:51:48PM +0900, Akihiko Odaki wrote:
> > > This commit introduces "punch hole" operation and optimizes transfer
> > > block size for macOS.
> > >
> > > This commit introduces two additional members,
> > > discard_granularity and opt_io to BlockSizes type in
> > > include/block/block.h. Also, the members of the type are now
> > > optional. Set -1 to discard_granularity and 0 to other members
> > > for the default values.
> >
> > I remember BlockSizes was added specifically for s390 DASD devices.
> > Normally QEMU does not automatically expose details of the underlying
> > hardware to the guest because it breaks live migration compatibility.
> >
> > If a VM is running on host A where the value happens to be 512 bytes and
> > is migrated to host B where the value happens to be 4KB then:
> >
> > 1. The value reported to the guest by the storage device will change
> >unexpectedly and the guest software is probably not prepared for this
> >to happen.
> >
> > 2. I/O requests that violate the constraint imposed by host B's value
> >will suddenly start failing and the VM may no longer be operational.
> >
> > I think there was an argument that DASDs are passthrough devices and the
> > user always knows what they are doing, so we can ignore this problem for
> > DASDs.
> >
> > This reasoning does not apply to POSIX files on macOS hosts, so I think
> > we need to figure out what to do here. The easiest option is not to
> > merge this patch series, but if this feature is important to you then we
> > need to think about how to extend the block size probing to be live
> > migration friendly or to change the QEMU command-line to support this
> > use case without unexpected live migration breakage.
>
> Dave actually made a good point on IRC: Even if we change live migration
> so that it doesn't break when we move to a host where different defaults
> are autodetected (we could do this by including these values in the
> migration stream and letting that override what the user specific on the
> command line), it still means that the guest visible device would change
> after the next reboot.
>
> The same can happen without live migration, either by copying the image
> to a different host, or by changing the hardware of the host.
>
> I'm not sure how critical such changes are now, but I seem to remember
> that in the past, one big reason to avoid them was that Windows guests
> would require reactivation after a few changes.
>
> (Also adding Peter to CC as the libvirt representative who, I suspect,
> might not like the idea of autodetecting by default very much :-))
>
> Kevin

The "copy" concern perhaps also applies to the host device backend,
which already has some auto detections. When the physical backend
device fails, a user may create a live snapshot, "dd" it to another
disk, and resume with the new disk, which can have different block
sizes.

I wonder if it is worthwhile to have an option to disable any kind of
autodetection depending on the host, including those of the host
device backend and maybe of subsystems other than block devices.

Regards,
Akihiko Odaki



[PATCH v4] virtio-blk: Respect discard granularity

2021-02-24 Thread Akihiko Odaki
Report the configured granularity for discard operation to the
guest. If this is not set use the block size.

Since until now we have ignored the configured discard granularity
and always reported the block size, let's add
'report-discard-granularity' property and disable it for older
machine types to avoid migration issues.

Signed-off-by: Akihiko Odaki 
---
 hw/block/virtio-blk.c  | 8 +++-
 hw/core/machine.c  | 4 +++-
 include/hw/virtio/virtio-blk.h | 1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index bac2d6fa2b2..f4378e61182 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -962,10 +962,14 @@ static void virtio_blk_update_config(VirtIODevice *vdev, 
uint8_t *config)
 blkcfg.wce = blk_enable_write_cache(s->blk);
 virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues);
 if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_DISCARD)) {
+uint32_t discard_granularity = conf->discard_granularity;
+if (discard_granularity == -1 || !s->conf.report_discard_granularity) {
+discard_granularity = blk_size;
+}
 virtio_stl_p(vdev, &blkcfg.max_discard_sectors,
  s->conf.max_discard_sectors);
 virtio_stl_p(vdev, &blkcfg.discard_sector_alignment,
- blk_size >> BDRV_SECTOR_BITS);
+ discard_granularity >> BDRV_SECTOR_BITS);
 /*
  * We support only one segment per request since multiple segments
  * are not widely used and there are no userspace APIs that allow
@@ -1299,6 +1303,8 @@ static Property virtio_blk_properties[] = {
  IOThread *),
 DEFINE_PROP_BIT64("discard", VirtIOBlock, host_features,
   VIRTIO_BLK_F_DISCARD, true),
+DEFINE_PROP_BOOL("report-discard-granularity", VirtIOBlock,
+ conf.report_discard_granularity, true),
 DEFINE_PROP_BIT64("write-zeroes", VirtIOBlock, host_features,
   VIRTIO_BLK_F_WRITE_ZEROES, true),
 DEFINE_PROP_UINT32("max-discard-sectors", VirtIOBlock,
diff --git a/hw/core/machine.c b/hw/core/machine.c
index de3b8f1b318..e4df5797e72 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -33,7 +33,9 @@
 #include "migration/global_state.h"
 #include "migration/vmstate.h"
 
-GlobalProperty hw_compat_5_2[] = {};
+GlobalProperty hw_compat_5_2[] = {
+{ "virtio-blk-device", "report-discard-granularity", "off" },
+};
 const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
 
 GlobalProperty hw_compat_5_1[] = {
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 214ab748229..29655a406dd 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -41,6 +41,7 @@ struct VirtIOBlkConf
 uint16_t num_queues;
 uint16_t queue_size;
 bool seg_max_adjust;
+bool report_discard_granularity;
 uint32_t max_discard_sectors;
 uint32_t max_write_zeroes_sectors;
 bool x_enable_wce_if_config_wce;
-- 
2.24.3 (Apple Git-128)




RE: [PATCH v2 01/22] block: add eMMC block device type

2021-02-24 Thread Sai Pavan Boddu
Hi Cedric,


> -Original Message-
> From: Cédric Le Goater 
> Sent: Wednesday, February 24, 2021 7:25 PM
> To: Stefan Hajnoczi ; Sai Pavan Boddu
> 
> Cc: Philippe Mathieu-Daudé ; Markus Armbruster
> ; Kevin Wolf ; Max Reitz
> ; Vladimir Sementsov-Ogievskiy
> ; Eric Blake ; Joel Stanley
> ; Vincent Palatin ; Dr. David Alan
> Gilbert ; Thomas Huth ; Peter
> Maydell ; Alistair Francis
> ; Edgar Iglesias ; Luc Michel
> ; Paolo Bonzini ; qemu-
> de...@nongnu.org; qemu-block@nongnu.org
> Subject: Re: [PATCH v2 01/22] block: add eMMC block device type
> 
> On 2/24/21 12:40 PM, Stefan Hajnoczi wrote:
> > On Tue, Feb 23, 2021 at 05:35:20PM +, Sai Pavan Boddu wrote:
> >> Hi Philippe,
> >>
> >>> -Original Message-
> >>> From: Philippe Mathieu-Daudé 
> >>> Sent: Monday, February 22, 2021 5:34 PM
> >>> To: Sai Pavan Boddu ; Markus Armbruster
> >>> ; Kevin Wolf ; Max Reitz
> >>> ; Vladimir Sementsov-Ogievskiy
> >>> ; Eric Blake ; Joel
> >>> Stanley ; Cédric Le Goater ; Vincent
> >>> Palatin ; Dr. David Alan Gilbert
> >>> ; Thomas Huth ; Stefan
> >>> Hajnoczi ; Peter Maydell
> >>> ; Alistair Francis
> >>> ; Edgar Iglesias ; Luc
> >>> Michel ; Paolo Bonzini
> >>> 
> >>> Cc: Sai Pavan Boddu ; qemu-de...@nongnu.org;
> >>> qemu- bl...@nongnu.org
> >>> Subject: Re: [PATCH v2 01/22] block: add eMMC block device type
> >>>
> >>> On 2/22/21 9:20 AM, Sai Pavan Boddu wrote:
>  From: Vincent Palatin 
> 
>  Add new block device type.
> 
>  Signed-off-by: Vincent Palatin 
>  [SPB: Rebased over 5.1 version]
>  Signed-off-by: Sai Pavan Boddu 
>  Signed-off-by: Joel Stanley 
>  Signed-off-by: Cédric Le Goater 
>  Reviewed-by: Alistair Francis 
>  ---
>   include/sysemu/blockdev.h | 1 +
>   blockdev.c| 1 +
>   2 files changed, 2 insertions(+)
> 
>  diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
>  index 3b5fcda..eefae9f 100644
>  --- a/include/sysemu/blockdev.h
>  +++ b/include/sysemu/blockdev.h
>  @@ -24,6 +24,7 @@ typedef enum {
>    */
>   IF_NONE = 0,
>   IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD,
>  IF_VIRTIO, IF_XEN,
>  +IF_EMMC,
>   IF_COUNT
>   } BlockInterfaceType;
> 
>  diff --git a/blockdev.c b/blockdev.c index cd438e6..390d43c 100644
>  --- a/blockdev.c
>  +++ b/blockdev.c
>  @@ -83,6 +83,7 @@ static const char *const if_name[IF_COUNT] = {
>   [IF_SD] = "sd",
>   [IF_VIRTIO] = "virtio",
>   [IF_XEN] = "xen",
>  +[IF_EMMC] = "emmc",
>   };
> >>>
> >>> We don't need to introduce support for the legacy -drive magic.
> >>>
> >>> -device should be enough for this device, right?
> >> [Sai Pavan Boddu] I was seeing to use -device for emmc. But I see we
> anyway need blockdev support for this, which would require us the use -drive.
> >>
> >> Can you give some pointers, how to approach this ?
> >
> > It is probably not necessary to add a new IF_ constant. Would this work:
> >
> >   -drive if=none,id=emmc0,file=test.img,format=raw
> >   -device emmc,...,drive=emmc0
> >
> > Or the more modern:
> >
> >   -blockdev node-name=emmc0,driver=file,filename=test.img
> >   -device emmc,...,drive=emmc0
> >
> > ?
> >
> > (The syntax might need small tweaks but is shows the general idea.)
> 
> Yes. This is better.
> 
> We could have an "emmc" device inheriting from "sd-card". The "emmc"
> property would not be necessary anymore and may be, we could cleanup up
> some parts doing :
> 
> if (sd->emmc) { /* eMMC */
> ...
> } else {
> 
> }
> 
> with SDCardClass handlers. the SWITCH_FUNCTION command is a good
> candidate, CMD8 also.
[Sai Pavan Boddu] Nice, this approach looks clean.
But we still may be depending on emmc property. Not sure!

I would get back with v3, your review on those patches would be great.

Thanks & Regards,
Sai Pavan
> 
> C.



RE: [PATCH v2 01/22] block: add eMMC block device type

2021-02-24 Thread Sai Pavan Boddu
Hi Stefan

> -Original Message-
> From: Stefan Hajnoczi 
> Sent: Wednesday, February 24, 2021 5:10 PM
> To: Sai Pavan Boddu 
> Cc: Philippe Mathieu-Daudé ; Markus Armbruster
> ; Kevin Wolf ; Max Reitz
> ; Vladimir Sementsov-Ogievskiy
> ; Eric Blake ; Joel Stanley
> ; Cédric Le Goater ; Vincent Palatin
> ; Dr. David Alan Gilbert ;
> Thomas Huth ; Peter Maydell
> ; Alistair Francis ; Edgar
> Iglesias ; Luc Michel ; Paolo
> Bonzini ; qemu-de...@nongnu.org; qemu-
> bl...@nongnu.org
> Subject: Re: [PATCH v2 01/22] block: add eMMC block device type
> 
> On Tue, Feb 23, 2021 at 05:35:20PM +, Sai Pavan Boddu wrote:
> > Hi Philippe,
> >
> > > -Original Message-
> > > From: Philippe Mathieu-Daudé 
> > > Sent: Monday, February 22, 2021 5:34 PM
> > > To: Sai Pavan Boddu ; Markus Armbruster
> > > ; Kevin Wolf ; Max Reitz
> > > ; Vladimir Sementsov-Ogievskiy
> > > ; Eric Blake ; Joel
> > > Stanley ; Cédric Le Goater ; Vincent
> > > Palatin ; Dr. David Alan Gilbert
> > > ; Thomas Huth ; Stefan
> > > Hajnoczi ; Peter Maydell
> > > ; Alistair Francis
> > > ; Edgar Iglesias ; Luc
> > > Michel ; Paolo Bonzini
> > > 
> > > Cc: Sai Pavan Boddu ; qemu-de...@nongnu.org;
> > > qemu- bl...@nongnu.org
> > > Subject: Re: [PATCH v2 01/22] block: add eMMC block device type
> > >
> > > On 2/22/21 9:20 AM, Sai Pavan Boddu wrote:
> > > > From: Vincent Palatin 
> > > >
> > > > Add new block device type.
> > > >
> > > > Signed-off-by: Vincent Palatin 
> > > > [SPB: Rebased over 5.1 version]
> > > > Signed-off-by: Sai Pavan Boddu 
> > > > Signed-off-by: Joel Stanley 
> > > > Signed-off-by: Cédric Le Goater 
> > > > Reviewed-by: Alistair Francis 
> > > > ---
> > > >  include/sysemu/blockdev.h | 1 +
> > > >  blockdev.c| 1 +
> > > >  2 files changed, 2 insertions(+)
> > > >
> > > > diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
> > > > index 3b5fcda..eefae9f 100644
> > > > --- a/include/sysemu/blockdev.h
> > > > +++ b/include/sysemu/blockdev.h
> > > > @@ -24,6 +24,7 @@ typedef enum {
> > > >   */
> > > >  IF_NONE = 0,
> > > >  IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD,
> > > > IF_VIRTIO, IF_XEN,
> > > > +IF_EMMC,
> > > >  IF_COUNT
> > > >  } BlockInterfaceType;
> > > >
> > > > diff --git a/blockdev.c b/blockdev.c index cd438e6..390d43c 100644
> > > > --- a/blockdev.c
> > > > +++ b/blockdev.c
> > > > @@ -83,6 +83,7 @@ static const char *const if_name[IF_COUNT] = {
> > > >  [IF_SD] = "sd",
> > > >  [IF_VIRTIO] = "virtio",
> > > >  [IF_XEN] = "xen",
> > > > +[IF_EMMC] = "emmc",
> > > >  };
> > >
> > > We don't need to introduce support for the legacy -drive magic.
> > >
> > > -device should be enough for this device, right?
> > [Sai Pavan Boddu] I was seeing to use -device for emmc. But I see we anyway
> need blockdev support for this, which would require us the use -drive.
> >
> > Can you give some pointers, how to approach this ?
> 
> It is probably not necessary to add a new IF_ constant. Would this work:
> 
>   -drive if=none,id=emmc0,file=test.img,format=raw
>   -device emmc,...,drive=emmc0
[Sai Pavan Boddu] Great, this works for me.
> 
> Or the more modern:
> 
>   -blockdev node-name=emmc0,driver=file,filename=test.img
>   -device emmc,...,drive=emmc0
[Sai Pavan Boddu] Thanks, I would try to follow the modern approach then!

Regards,
Sai Pavan
> 
> ?
> 
> (The syntax might need small tweaks but is shows the general idea.)
> 
> Stefan



Re: [PATCH] block/file-posix: Optimize for macOS

2021-02-24 Thread Kevin Wolf
Am 24.02.2021 um 17:27 hat Stefan Hajnoczi geschrieben:
> On Fri, Feb 19, 2021 at 05:51:48PM +0900, Akihiko Odaki wrote:
> > This commit introduces "punch hole" operation and optimizes transfer
> > block size for macOS.
> > 
> > This commit introduces two additional members,
> > discard_granularity and opt_io to BlockSizes type in
> > include/block/block.h. Also, the members of the type are now
> > optional. Set -1 to discard_granularity and 0 to other members
> > for the default values.
> 
> I remember BlockSizes was added specifically for s390 DASD devices.
> Normally QEMU does not automatically expose details of the underlying
> hardware to the guest because it breaks live migration compatibility.
> 
> If a VM is running on host A where the value happens to be 512 bytes and
> is migrated to host B where the value happens to be 4KB then:
> 
> 1. The value reported to the guest by the storage device will change
>unexpectedly and the guest software is probably not prepared for this
>to happen.
> 
> 2. I/O requests that violate the constraint imposed by host B's value
>will suddenly start failing and the VM may no longer be operational.
> 
> I think there was an argument that DASDs are passthrough devices and the
> user always knows what they are doing, so we can ignore this problem for
> DASDs.
> 
> This reasoning does not apply to POSIX files on macOS hosts, so I think
> we need to figure out what to do here. The easiest option is not to
> merge this patch series, but if this feature is important to you then we
> need to think about how to extend the block size probing to be live
> migration friendly or to change the QEMU command-line to support this
> use case without unexpected live migration breakage.

Dave actually made a good point on IRC: Even if we change live migration
so that it doesn't break when we move to a host where different defaults
are autodetected (we could do this by including these values in the
migration stream and letting that override what the user specific on the
command line), it still means that the guest visible device would change
after the next reboot.

The same can happen without live migration, either by copying the image
to a different host, or by changing the hardware of the host.

I'm not sure how critical such changes are now, but I seem to remember
that in the past, one big reason to avoid them was that Windows guests
would require reactivation after a few changes.

(Also adding Peter to CC as the libvirt representative who, I suspect,
might not like the idea of autodetecting by default very much :-))

Kevin


signature.asc
Description: PGP signature


Re: [PATCH] blockjob: report a better error message

2021-02-24 Thread Stefano Garzarella

On Wed, Feb 24, 2021 at 06:04:14PM +0100, Kevin Wolf wrote:

Am 24.02.2021 um 16:59 hat Stefano Garzarella geschrieben:

On Wed, Feb 24, 2021 at 03:36:20PM +0100, Kevin Wolf wrote:
> Am 23.02.2021 um 14:11 hat Stefano Garzarella geschrieben:
> > When a block job fails, we report 'strerror(-job->job.ret)' error
> > message, also if the job set an error object.
> > Let's report a better error message using 'error_get_pretty(job->job.err)'.
> >
> > If an error object was not set, strerror(-job->ret) is used as fallback,
> > as explained in include/qemu/job.h:
> >
> > typedef struct Job {
> > ...
> > /**
> >  * Error object for a failed job.
> >  * If job->ret is nonzero and an error object was not set, it will be 
set
> >  * to strerror(-job->ret) during job_completed.
> >  */
> > Error *err;
> > }
>
> This is true, but there is a short time where job->ret is already set,
> but not turned into job->err yet if necessary. The latter is done in a
> bottom half scheduled after the former has happened.
>
> It doesn't matter for block_job_event_completed(), which is called only
> after both, but block_job_query() could in theory be called in this
> window.
>
> > Suggested-by: Kevin Wolf 
> > Signed-off-by: Stefano Garzarella 
> > ---
> >  blockjob.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/blockjob.c b/blockjob.c
> > index f2feff051d..a696f3408d 100644
> > --- a/blockjob.c
> > +++ b/blockjob.c
> > @@ -319,7 +319,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error 
**errp)
> >  info->auto_finalize = job->job.auto_finalize;
> >  info->auto_dismiss  = job->job.auto_dismiss;
> >  info->has_error = job->job.ret != 0;
> > -info->error = job->job.ret ? g_strdup(strerror(-job->job.ret)) : 
NULL;
> > +info->error = job->job.ret ?
> > +g_strdup(error_get_pretty(job->job.err)) : NULL;
>
> So I think we can't rely on job->job.err being non-NULL here.

Do you think is better to leave it as it was or do something like this?

if (job->job.ret) {
info->has_error = true;
info->error = job->job.err ? g_strdup(error_get_pretty(job->job.err)) :
g_strdup(strerror(-job->job.ret);
}


Yes, I think this is the best solution. Use the error when we have it,
fall back to strerror() when we don't have it.



Okay, I'll send v2 with that fixed.

Thanks,
Stefano




Re: [PATCH] blockjob: report a better error message

2021-02-24 Thread Kevin Wolf
Am 24.02.2021 um 16:59 hat Stefano Garzarella geschrieben:
> On Wed, Feb 24, 2021 at 03:36:20PM +0100, Kevin Wolf wrote:
> > Am 23.02.2021 um 14:11 hat Stefano Garzarella geschrieben:
> > > When a block job fails, we report 'strerror(-job->job.ret)' error
> > > message, also if the job set an error object.
> > > Let's report a better error message using 
> > > 'error_get_pretty(job->job.err)'.
> > > 
> > > If an error object was not set, strerror(-job->ret) is used as fallback,
> > > as explained in include/qemu/job.h:
> > > 
> > > typedef struct Job {
> > > ...
> > > /**
> > >  * Error object for a failed job.
> > >  * If job->ret is nonzero and an error object was not set, it will be 
> > > set
> > >  * to strerror(-job->ret) during job_completed.
> > >  */
> > > Error *err;
> > > }
> > 
> > This is true, but there is a short time where job->ret is already set,
> > but not turned into job->err yet if necessary. The latter is done in a
> > bottom half scheduled after the former has happened.
> > 
> > It doesn't matter for block_job_event_completed(), which is called only
> > after both, but block_job_query() could in theory be called in this
> > window.
> > 
> > > Suggested-by: Kevin Wolf 
> > > Signed-off-by: Stefano Garzarella 
> > > ---
> > >  blockjob.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/blockjob.c b/blockjob.c
> > > index f2feff051d..a696f3408d 100644
> > > --- a/blockjob.c
> > > +++ b/blockjob.c
> > > @@ -319,7 +319,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error 
> > > **errp)
> > >  info->auto_finalize = job->job.auto_finalize;
> > >  info->auto_dismiss  = job->job.auto_dismiss;
> > >  info->has_error = job->job.ret != 0;
> > > -info->error = job->job.ret ? g_strdup(strerror(-job->job.ret)) : 
> > > NULL;
> > > +info->error = job->job.ret ?
> > > +g_strdup(error_get_pretty(job->job.err)) : NULL;
> > 
> > So I think we can't rely on job->job.err being non-NULL here.
> 
> Do you think is better to leave it as it was or do something like this?
> 
> if (job->job.ret) {
> info->has_error = true;
> info->error = job->job.err ? g_strdup(error_get_pretty(job->job.err)) 
> :
> g_strdup(strerror(-job->job.ret);
> }

Yes, I think this is the best solution. Use the error when we have it,
fall back to strerror() when we don't have it.

Kevin




Re: [PATCH] block/file-posix: Optimize for macOS

2021-02-24 Thread Stefan Hajnoczi
On Fri, Feb 19, 2021 at 05:51:48PM +0900, Akihiko Odaki wrote:
> This commit introduces "punch hole" operation and optimizes transfer
> block size for macOS.
> 
> This commit introduces two additional members,
> discard_granularity and opt_io to BlockSizes type in
> include/block/block.h. Also, the members of the type are now
> optional. Set -1 to discard_granularity and 0 to other members
> for the default values.

I remember BlockSizes was added specifically for s390 DASD devices.
Normally QEMU does not automatically expose details of the underlying
hardware to the guest because it breaks live migration compatibility.

If a VM is running on host A where the value happens to be 512 bytes and
is migrated to host B where the value happens to be 4KB then:

1. The value reported to the guest by the storage device will change
   unexpectedly and the guest software is probably not prepared for this
   to happen.

2. I/O requests that violate the constraint imposed by host B's value
   will suddenly start failing and the VM may no longer be operational.

I think there was an argument that DASDs are passthrough devices and the
user always knows what they are doing, so we can ignore this problem for
DASDs.

This reasoning does not apply to POSIX files on macOS hosts, so I think
we need to figure out what to do here. The easiest option is not to
merge this patch series, but if this feature is important to you then we
need to think about how to extend the block size probing to be live
migration friendly or to change the QEMU command-line to support this
use case without unexpected live migration breakage.

CCing Kevin Wolf and Markus Armbruster.

> Signed-off-by: Akihiko Odaki 
> ---
>  block/file-posix.c| 40 ++--
>  block/nvme.c  |  2 ++
>  hw/block/block.c  | 12 ++--
>  include/block/block.h |  2 ++
>  4 files changed, 52 insertions(+), 4 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 00cdaaa2d41..defbc04c8e7 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -44,6 +44,7 @@
>  #if defined(__APPLE__) && (__MACH__)
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1274,6 +1275,8 @@ static int hdev_probe_blocksizes(BlockDriverState *bs, 
> BlockSizes *bsz)
>  if (check_for_dasd(s->fd) < 0) {
>  return -ENOTSUP;
>  }
> +bsz->opt_io = 0;
> +bsz->discard_granularity = -1;
>  ret = probe_logical_blocksize(s->fd, &bsz->log);
>  if (ret < 0) {
>  return ret;
> @@ -1568,6 +1571,7 @@ out:
>  }
>  }
>  
> +G_GNUC_UNUSED
>  static int translate_err(int err)
>  {
>  if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP ||
> @@ -1777,16 +1781,27 @@ static int handle_aiocb_discard(void *opaque)
>  }
>  } while (errno == EINTR);
>  
> -ret = -errno;
> +ret = translate_err(-errno);
>  #endif
>  } else {
>  #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
>  ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> aiocb->aio_offset, aiocb->aio_nbytes);
> +ret = translate_err(-errno);
> +#elif defined(__APPLE__) && (__MACH__)
> +fpunchhole_t fpunchhole;
> +fpunchhole.fp_flags = 0;
> +fpunchhole.reserved = 0;
> +fpunchhole.fp_offset = aiocb->aio_offset;
> +fpunchhole.fp_length = aiocb->aio_nbytes;
> +if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) {
> +ret = errno == ENODEV ? -ENOTSUP : -errno;
> +} else {
> +ret = 0;
> +}
>  #endif
>  }
>  
> -ret = translate_err(ret);
>  if (ret == -ENOTSUP) {
>  s->has_discard = false;
>  }
> @@ -2095,6 +2110,26 @@ static int raw_co_flush_to_disk(BlockDriverState *bs)
>  return raw_thread_pool_submit(bs, handle_aiocb_flush, &acb);
>  }
>  
> +static int raw_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
> +{
> +#if defined(__APPLE__) && (__MACH__)
> +BDRVRawState *s = bs->opaque;
> +struct statfs buf;
> +
> +if (!fstatfs(s->fd, &buf)) {
> +bsz->phys = 0;
> +bsz->log = 0;
> +bsz->opt_io = buf.f_iosize;
> +bsz->discard_granularity = buf.f_bsize;
> +return 0;
> +}
> +
> +return -errno;
> +#else
> +return -ENOTSUP;
> +#endif
> +}
> +
>  static void raw_aio_attach_aio_context(BlockDriverState *bs,
> AioContext *new_context)
>  {
> @@ -3229,6 +3264,7 @@ BlockDriver bdrv_file = {
>  .bdrv_refresh_limits = raw_refresh_limits,
>  .bdrv_io_plug = raw_aio_plug,
>  .bdrv_io_unplug = raw_aio_unplug,
> +.bdrv_probe_blocksizes = raw_probe_blocksizes,
>  .bdrv_attach_aio_context = raw_aio_attach_aio_context,
>  
>  .bdrv_co_truncate = raw_co_truncate,
> diff --git a/block/nvme.c b/block/nvme.c
> index 5a6fbacf4a5..6d84bbdb632 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -983,6 +983

Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support

2021-02-24 Thread Kevin Wolf
Am 24.02.2021 um 16:21 hat Dr. David Alan Gilbert geschrieben:
> * Kevin Wolf (kw...@redhat.com) wrote:
> > This adds a QAPI schema for the properties of the objects implementing
> > the confidential-guest-support interface.
> > 
> > pef-guest and s390x-pv-guest don't have any properties, so they only
> > need to be added to the ObjectType enum without adding a new branch to
> > ObjectOptions.
> > 
> > Signed-off-by: Kevin Wolf 
> > ---
> >  qapi/qom.json | 37 +
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/qapi/qom.json b/qapi/qom.json
> > index e7184122e9..d5f68b5c89 100644
> > --- a/qapi/qom.json
> > +++ b/qapi/qom.json
> > @@ -633,6 +633,38 @@
> >'base': 'RngProperties',
> >'data': { '*filename': 'str' } }
> >  
> > +##
> > +# @SevGuestProperties:
> > +#
> > +# Properties for sev-guest objects.
> > +#
> > +# @sev-device: SEV device to use (default: "/dev/sev")
> > +#
> > +# @dh-cert-file: guest owners DH certificate (encoded with base64)
> > +#
> > +# @session-file: guest owners session parameters (encoded with base64)
> > +#
> > +# @policy: SEV policy value (default: 0x1)
> > +#
> > +# @handle: SEV firmware handle (default: 0)
> > +#
> > +# @cbitpos: C-bit location in page table entry (default: 0)
> > +#
> > +# @reduced-phys-bits: number of bits in physical addresses that become
> > +# unavailable when SEV is enabled
> > +#
> > +# Since: 2.12
> > +##
> > +{ 'struct': 'SevGuestProperties',
> > +  'data': { '*sev-device': 'str',
> > +'*dh-cert-file': 'str',
> > +'*session-file': 'str',
> > +'*policy': 'uint32',
> > +'*handle': 'uint32',
> > +'*cbitpos': 'uint32',
> > +'reduced-phys-bits': 'uint32' },
> > +  'if': 'defined(CONFIG_SEV)' }
> > +
> >  ##
> >  # @ObjectType:
> >  #
> > @@ -661,12 +693,15 @@
> >  'memory-backend-file',
> >  'memory-backend-memfd',
> >  'memory-backend-ram',
> > +{'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' },
> >  'pr-manager-helper',
> >  'rng-builtin',
> >  'rng-egd',
> >  'rng-random',
> >  'secret',
> >  'secret_keyring',
> > +{'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' },
> > +'s390-pv-guest',
> 
> If pef-guest is conditional on PSERIES< shouldn't this be dependent on
> s390?

The difference is that s390-pv-guest is compiled unconditionally if the
s390x target is built, whereas CONFIG_PSERIES is a separate thing from
building a ppc target.

I actually tried making it conditional on TARGET_S390X at first, but the
code generated from this schema is supposed to be target independent, so
it rightly failed to build because TARGET_* are marked as poisoned in
most of the codebase.

Kevin




Re: [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add

2021-02-24 Thread Peter Krempa
On Wed, Feb 24, 2021 at 14:52:24 +0100, Kevin Wolf wrote:
> This series adds a QAPI type for the properties of all user creatable
> QOM types and finally makes the --object command line option (in all
> binaries) and the object-add monitor commands (in QMP and HMP) use the
> new ObjectOptions union.
> 
> This change improves things in more than just one way:
> 
> 1. Documentation for QOM object types has always been lacking. Adding
>the schema, we get documentation for every property.
> 
> 2. It prevents bugs by performing parts of the input validation (e.g.
>checking presence of mandatory properties) already in QAPI instead of
>relying on separate manual implementations in each class.
> 
> 3. It provides QAPI introspection for user creatable objects.
> 
> 4. Non-scalar properties are now supported everywhere because the
>command line parsers (including HMP) use the keyval parser now.

I've updated and posted another version of the libvirt patches which add
testing that our generated props conform to the schema and also deals
with the dropped 'props' wrapper:

https://listman.redhat.com/archives/libvir-list/2021-February/msg01212.html

Libvirt's test pass after it without any change, so on behalf of libvirt

ACKed-by: Peter Krempa 




Re: [PATCH] blockjob: report a better error message

2021-02-24 Thread Stefano Garzarella

On Wed, Feb 24, 2021 at 03:36:20PM +0100, Kevin Wolf wrote:

Am 23.02.2021 um 14:11 hat Stefano Garzarella geschrieben:

When a block job fails, we report 'strerror(-job->job.ret)' error
message, also if the job set an error object.
Let's report a better error message using 'error_get_pretty(job->job.err)'.

If an error object was not set, strerror(-job->ret) is used as fallback,
as explained in include/qemu/job.h:

typedef struct Job {
...
/**
 * Error object for a failed job.
 * If job->ret is nonzero and an error object was not set, it will be set
 * to strerror(-job->ret) during job_completed.
 */
Error *err;
}


This is true, but there is a short time where job->ret is already set,
but not turned into job->err yet if necessary. The latter is done in a
bottom half scheduled after the former has happened.

It doesn't matter for block_job_event_completed(), which is called only
after both, but block_job_query() could in theory be called in this
window.


Suggested-by: Kevin Wolf 
Signed-off-by: Stefano Garzarella 
---
 blockjob.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/blockjob.c b/blockjob.c
index f2feff051d..a696f3408d 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -319,7 +319,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
 info->auto_finalize = job->job.auto_finalize;
 info->auto_dismiss  = job->job.auto_dismiss;
 info->has_error = job->job.ret != 0;
-info->error = job->job.ret ? g_strdup(strerror(-job->job.ret)) : NULL;
+info->error = job->job.ret ?
+g_strdup(error_get_pretty(job->job.err)) : NULL;


So I think we can't rely on job->job.err being non-NULL here.


Do you think is better to leave it as it was or do something like this?

if (job->job.ret) {
info->has_error = true;
info->error = job->job.err ? g_strdup(error_get_pretty(job->job.err)) :
g_strdup(strerror(-job->job.ret);
}

Thanks,
Stefano




 return info;
 }

@@ -356,7 +357,7 @@ static void block_job_event_completed(Notifier *n, void 
*opaque)
 }

 if (job->job.ret < 0) {
-msg = strerror(-job->job.ret);
+msg = error_get_pretty(job->job.err);
 }

 qapi_event_send_block_job_completed(job_type(&job->job),


Kevin






Re: [PATCH 3/3] iotests/283: Check that finalize drops backup-top

2021-02-24 Thread Kevin Wolf
Am 19.02.2021 um 16:59 hat Max Reitz geschrieben:
> On 19.02.21 16:33, Max Reitz wrote:
> > Without any of HEAD^ or HEAD^^ applied, qemu will most likely crash on
> > the qemu-io invocation, for a variety of immediate reasons.  The
> > underlying problem is generally a use-after-free access into
> > backup-top's BlockCopyState.
> > 
> > With only HEAD^ applied, qemu-io will run into an EIO (which is not
> > capture by the output, but you can see that the qemu-io invocation will
> > be accepted (i.e., qemu-io will run) in contrast to the reference
> > output, where the node name cannot be found), and qemu will then crash
> > in query-named-block-nodes: bdrv_get_allocated_file_size() detects
> > backup-top to be a filter and passes the request through to its child.
> > However, after bdrv_backup_top_drop(), that child is NULL, so the
> > recursive call crashes.
> > 
> > With HEAD^^ applied, this test should pass.
> > 
> > Signed-off-by: Max Reitz 
> > ---
> >   tests/qemu-iotests/283 | 55 ++
> >   tests/qemu-iotests/283.out | 15 +++
> >   2 files changed, 70 insertions(+)
> > 
> > diff --git a/tests/qemu-iotests/283 b/tests/qemu-iotests/283
> > index 79643e375b..509dcbbcf4 100755
> > --- a/tests/qemu-iotests/283
> > +++ b/tests/qemu-iotests/283
> > @@ -97,3 +97,58 @@ vm.qmp_log('blockdev-add', **{
> >   vm.qmp_log('blockdev-backup', sync='full', device='source', 
> > target='target')
> >   vm.shutdown()
> > +
> > +
> > +"""
> > +Check that the backup-top node is gone after job-finalize.
> > +
> > +During finalization, the node becomes inactive and can no longer
> > +function.  If it is still present, new parents might be attached, and
> > +there would be no meaningful way to handle their I/O requests.
> > +"""
> 
> Oh no, 297/pylint complains that this “string statement has no effect”.
> Guess it should be a normal comment under the following print() then...

Thanks, fixed up the comment as you suggest and applied to the block
branch.

Kevin




Re: [PATCH 1/3] backup: Remove nodes from job in .clean()

2021-02-24 Thread Kevin Wolf
Am 19.02.2021 um 16:33 hat Max Reitz geschrieben:
> The block job holds a reference to the backup-top node (because it is
> passed as the main job BDS to block_job_create()).  Therefore,
> bdrv_backup_top_drop() cannot delete the backup-top node (replacing it
> by its child does not affect the job parent, because that has
> .stay_at_node set).  That is a problem, because all of its I/O functions
> assume the BlockCopyState (s->bcs) to be valid and that it has a
> filtered child; but after bdrv_backup_top_drop(), neither of those
> things are true.

This kind of suggests that block_copy_state_free() doesn't really belong
in bdrv_backup_top_drop(), but in a .bdrv_close callback.

Doesn't make this patch less correct, of course. We still want to have
all references dropped at the end of bdrv_backup_top_drop().

> It does not make sense to add new parents to backup-top after
> backup_clean(), so we should detach it from the job before
> bdrv_backup_top_drop().  Because there is no function to do that for a
> single node, just detach all of the job's nodes -- the job does not do
> anything past backup_clean() anyway.
> 
> Signed-off-by: Max Reitz 

Reviewed-by: Kevin Wolf 




Re: [PATCH v2 28/31] hmp: QAPIfy object_add

2021-02-24 Thread Dr. David Alan Gilbert
* Kevin Wolf (kw...@redhat.com) wrote:
> This switches the HMP command object_add from a QemuOpts-based parser to
> user_creatable_add_from_str() which uses a keyval parser and enforces
> the QAPI schema.
> 
> Apart from being a cleanup, this makes non-scalar properties and help
> accessible. In order for help to be printed to the monitor instead of
> stdout, the printf() calls in the help functions are changed to
> qemu_printf().
> 
> Signed-off-by: Kevin Wolf 

Reviewed-by: Dr. David Alan Gilbert 

> ---
>  monitor/hmp-cmds.c  | 17 ++---
>  qom/object_interfaces.c | 11 ++-
>  hmp-commands.hx |  2 +-
>  3 files changed, 9 insertions(+), 21 deletions(-)
> 
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 3c88a4faef..652cf9ff21 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1670,24 +1670,11 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
>  
>  void hmp_object_add(Monitor *mon, const QDict *qdict)
>  {
> +const char *options = qdict_get_str(qdict, "object");
>  Error *err = NULL;
> -QemuOpts *opts;
> -Object *obj = NULL;
> -
> -opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
> -if (err) {
> -goto end;
> -}
>  
> -obj = user_creatable_add_opts(opts, &err);
> -qemu_opts_del(opts);
> -
> -end:
> +user_creatable_add_from_str(options, &err);
>  hmp_handle_error(mon, err);
> -
> -if (obj) {
> -object_unref(obj);
> -}
>  }
>  
>  void hmp_getfd(Monitor *mon, const QDict *qdict)
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 54f0dadfea..c4982dd7a0 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -13,6 +13,7 @@
>  #include "qemu/help_option.h"
>  #include "qemu/module.h"
>  #include "qemu/option.h"
> +#include "qemu/qemu-print.h"
>  #include "qapi/opts-visitor.h"
>  #include "qemu/config-file.h"
>  
> @@ -212,11 +213,11 @@ static void user_creatable_print_types(void)
>  {
>  GSList *l, *list;
>  
> -printf("List of user creatable objects:\n");
> +qemu_printf("List of user creatable objects:\n");
>  list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
>  for (l = list; l != NULL; l = l->next) {
>  ObjectClass *oc = OBJECT_CLASS(l->data);
> -printf("  %s\n", object_class_get_name(oc));
> +qemu_printf("  %s\n", object_class_get_name(oc));
>  }
>  g_slist_free(list);
>  }
> @@ -247,12 +248,12 @@ static bool user_creatable_print_type_properites(const 
> char *type)
>  }
>  g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
>  if (array->len > 0) {
> -printf("%s options:\n", type);
> +qemu_printf("%s options:\n", type);
>  } else {
> -printf("There are no options for %s.\n", type);
> +qemu_printf("There are no options for %s.\n", type);
>  }
>  for (i = 0; i < array->len; i++) {
> -printf("%s\n", (char *)array->pdata[i]);
> +qemu_printf("%s\n", (char *)array->pdata[i]);
>  }
>  g_ptr_array_set_free_func(array, g_free);
>  g_ptr_array_free(array, true);
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index d4001f9c5d..6f5d9ce2fb 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1337,7 +1337,7 @@ ERST
>  
>  {
>  .name   = "object_add",
> -.args_type  = "object:O",
> +.args_type  = "object:S",
>  .params = "[qom-type=]type,id=str[,prop=value][,...]",
>  .help   = "create QOM object",
>  .cmd= hmp_object_add,
> -- 
> 2.29.2
> 
-- 
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK




Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support

2021-02-24 Thread Dr. David Alan Gilbert
* Kevin Wolf (kw...@redhat.com) wrote:
> This adds a QAPI schema for the properties of the objects implementing
> the confidential-guest-support interface.
> 
> pef-guest and s390x-pv-guest don't have any properties, so they only
> need to be added to the ObjectType enum without adding a new branch to
> ObjectOptions.
> 
> Signed-off-by: Kevin Wolf 
> ---
>  qapi/qom.json | 37 +
>  1 file changed, 37 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index e7184122e9..d5f68b5c89 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -633,6 +633,38 @@
>'base': 'RngProperties',
>'data': { '*filename': 'str' } }
>  
> +##
> +# @SevGuestProperties:
> +#
> +# Properties for sev-guest objects.
> +#
> +# @sev-device: SEV device to use (default: "/dev/sev")
> +#
> +# @dh-cert-file: guest owners DH certificate (encoded with base64)
> +#
> +# @session-file: guest owners session parameters (encoded with base64)
> +#
> +# @policy: SEV policy value (default: 0x1)
> +#
> +# @handle: SEV firmware handle (default: 0)
> +#
> +# @cbitpos: C-bit location in page table entry (default: 0)
> +#
> +# @reduced-phys-bits: number of bits in physical addresses that become
> +# unavailable when SEV is enabled
> +#
> +# Since: 2.12
> +##
> +{ 'struct': 'SevGuestProperties',
> +  'data': { '*sev-device': 'str',
> +'*dh-cert-file': 'str',
> +'*session-file': 'str',
> +'*policy': 'uint32',
> +'*handle': 'uint32',
> +'*cbitpos': 'uint32',
> +'reduced-phys-bits': 'uint32' },
> +  'if': 'defined(CONFIG_SEV)' }
> +
>  ##
>  # @ObjectType:
>  #
> @@ -661,12 +693,15 @@
>  'memory-backend-file',
>  'memory-backend-memfd',
>  'memory-backend-ram',
> +{'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' },
>  'pr-manager-helper',
>  'rng-builtin',
>  'rng-egd',
>  'rng-random',
>  'secret',
>  'secret_keyring',
> +{'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' },
> +'s390-pv-guest',

If pef-guest is conditional on PSERIES< shouldn't this be dependent on
s390?

Dave

>  'throttle-group',
>  'tls-creds-anon',
>  'tls-creds-psk',
> @@ -716,6 +751,8 @@
>'rng-random': 'RngRandomProperties',
>'secret': 'SecretProperties',
>'secret_keyring': 'SecretKeyringProperties',
> +  'sev-guest':  { 'type': 'SevGuestProperties',
> +  'if': 'defined(CONFIG_SEV)' },
>'throttle-group': 'ThrottleGroupProperties',
>'tls-creds-anon': 'TlsCredsAnonProperties',
>'tls-creds-psk':  'TlsCredsPskProperties',
> -- 
> 2.29.2
> 
-- 
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK




Re: [PATCH v2] iotests: Drop deprecated 'props' from object-add

2021-02-24 Thread Kevin Wolf
Am 22.02.2021 um 12:57 hat Alberto Garcia geschrieben:
> Signed-off-by: Alberto Garcia 
> ---
> v2: Don't use the x-* interface to specify limits [Kevin]

Thanks, applied to the block branch.

Kevin




Re: [PATCH v3 01/12] vhost-user-blk: fix blkcfg->num_queues endianness

2021-02-24 Thread Stefan Hajnoczi
On Tue, Feb 23, 2021 at 11:13:47AM -0500, Michael S. Tsirkin wrote:
> On Tue, Feb 23, 2021 at 02:46:42PM +, Stefan Hajnoczi wrote:
> > Treat the num_queues field as virtio-endian. On big-endian hosts the
> > vhost-user-blk num_queues field was in the wrong endianness.
> > 
> > Move the blkcfg.num_queues store operation from realize to
> > vhost_user_blk_update_config() so feature negotiation has finished and
> > we know the endianness of the device. VIRTIO 1.0 devices are
> > little-endian, but in case someone wants to use legacy VIRTIO we support
> > all endianness cases.
> > 
> > Cc: qemu-sta...@nongnu.org
> > Signed-off-by: Stefan Hajnoczi 
> > Reviewed-by: Raphael Norwitz 
> > Reviewed-by: Michael S. Tsirkin 
> 
> okay but as we recently discovered config space can in theory
> be read before FEATURES_OK. Nasty, I know. Things kind of work
> right now but we really need some other path to notify backends
> when legacy guest is active. E.g. VDPA also has this problem.

Thanks for mentioning it.

Do you know specifics about this type of guest driver? If it's only
legacy drivers then device implementations can ensure compatibility by
using host-endian until FEATURES_OK :). I guess existing code needs to
be audited to check if this can be done.

Stefan


signature.asc
Description: PGP signature


Re: [PATCH v4 0/8] hw/sh4: Kconfig cleanups

2021-02-24 Thread Richard Henderson
On 2/22/21 6:15 AM, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (8):
>   hw/sh4: Add missing license
>   hw/sh4: Add missing Kconfig dependency on SH7750 for the R2D board
>   hw/intc: Introduce SH_INTC Kconfig entry
>   hw/char: Introduce SH_SCI Kconfig entry
>   hw/timer: Introduce SH_TIMER Kconfig entry
>   hw/block: Introduce TC58128 eeprom Kconfig entry
>   hw/pci-host: Introduce SH_PCI Kconfig entry
>   hw/sh4: Remove now unused CONFIG_SH4 from Kconfig

Reviewed-by: Richard Henderson 

r~



Re: [PATCH 00/14] deprecations: remove many old deprecations

2021-02-24 Thread Daniel P . Berrangé
On Wed, Feb 24, 2021 at 02:38:43PM +, Peter Maydell wrote:
> On Wed, 24 Feb 2021 at 13:21, Daniel P. Berrangé  wrote:
> >
> > The following features have been deprecated for well over the 2
> > release cycle we promise
> >
> >   ``-usbdevice`` (since 2.10.0)
> >   ``-drive file=3Djson:{...{'driver':'file'}}`` (since 3.0)
> >   ``-vnc acl`` (since 4.0.0)
> >   ``-mon ...,control=3Dreadline,pretty=3Don|off`` (since 4.1)
> 
> Are the literal '=3D' here intended ?

git-publish has done something wierd to the cover letter encoding that
I don't understand.


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 :|




Re: [PATCH 11/14] block: remove 'encryption_key_missing' flag from QAPI

2021-02-24 Thread Thomas Huth

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

This has been hardcoded to "false" since 2.10.0, since secrets required
to unlock block devices are now always provided upfront instead of using
interactive prompts.

Signed-off-by: Daniel P. Berrangé 
---
  block/qapi.c |  1 -
  docs/system/deprecated.rst   | 10 ---
  docs/system/removed-features.rst | 10 +++
  qapi/block-core.json |  8 --
  tests/qemu-iotests/184.out   |  6 ++--
  tests/qemu-iotests/191.out   | 48 +++-
  tests/qemu-iotests/273.out   | 15 --
  7 files changed, 33 insertions(+), 65 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index 84a0aadc09..3acc118c44 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -62,7 +62,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
  info->ro = bs->read_only;
  info->drv= g_strdup(bs->drv->format_name);
  info->encrypted  = bs->encrypted;
-info->encryption_key_missing = false;
  
  info->cache = g_new(BlockdevCacheInfo, 1);

  *info->cache = (BlockdevCacheInfo) {
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index cb88fea94f..e746a63edf 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -147,16 +147,6 @@ Use argument ``id`` instead.
  
  Use argument ``id`` instead.
  
-``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)

-
-
-Always false.
-
-``query-block`` result ``inserted.encryption_key_missing`` (since 2.10.0)
-'
-
-Always false.
-
  ``blockdev-add`` empty string argument ``backing`` (since 2.10.0)
  '
  
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst

index bb6bc8dfc8..583f14f02e 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -112,6 +112,16 @@ chardev client socket with ``wait`` option (removed in 6.0)
  Character devices creating sockets in client mode should not specify
  the 'wait' field, which is only applicable to sockets in server mode
  
+``query-named-block-nodes`` result ``encryption_key_missing`` (removed in 6.0)

+''
+
+Always false.


Should that be "Removed with no replacement", too ? (just like the one below)


+``query-block`` result ``inserted.encryption_key_missing`` (removed in 6.0)
+'''
+
+Removed with no replacement
+


Apart from that nit:
Reviewed-by: Thomas Huth 




Re: [PATCH 00/14] deprecations: remove many old deprecations

2021-02-24 Thread Philippe Mathieu-Daudé
On 2/24/21 3:38 PM, Peter Maydell wrote:
> On Wed, 24 Feb 2021 at 13:21, Daniel P. Berrangé  wrote:
>>
>> The following features have been deprecated for well over the 2
>> release cycle we promise
>>
>>   ``-usbdevice`` (since 2.10.0)
>>   ``-drive file=3Djson:{...{'driver':'file'}}`` (since 3.0)
>>   ``-vnc acl`` (since 4.0.0)
>>   ``-mon ...,control=3Dreadline,pretty=3Don|off`` (since 4.1)
> 
> Are the literal '=3D' here intended ?

No, this is a git-publish bug:
https://github.com/stefanha/git-publish/issues/88

Apparently the fix is not yet backported to Fedora.




Re: [PATCH 10/14] hw/scsi: remove 'scsi-disk' device

2021-02-24 Thread Thomas Huth

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

The 'scsi-hd' and 'scsi-cd' devices provide suitable alternatives.

Signed-off-by: Daniel P. Berrangé 
---
  docs/system/deprecated.rst   |  9 -
  docs/system/removed-features.rst |  6 
  hw/i386/pc.c |  1 -
  hw/scsi/scsi-disk.c  | 62 
  hw/sparc64/sun4u.c   |  1 -
  scripts/device-crash-test|  1 -
  tests/qemu-iotests/051   |  2 --
  tests/qemu-iotests/051.pc.out| 10 --
  8 files changed, 6 insertions(+), 86 deletions(-)


I see some occurrances of "scsi-disk" in the config files in the 
docs/config/ directory, too ... I guess they should also be removed?



diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index d7c27144ba..cda7df36e3 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -749,7 +749,6 @@ static char *sun4u_fw_dev_path(FWPathProvider *p, BusState 
*bus,
 DeviceState *dev)
  {
  PCIDevice *pci;
-int bus_id;
  
  if (!strcmp(object_get_typename(OBJECT(dev)), "pbm-bridge")) {

  pci = PCI_DEVICE(dev);


This lonely hunk should be squashed into the previous (ide-disk) patch instead.

 Thomas




Re: [PATCH 09/14] hw/ide: remove 'ide-drive' device

2021-02-24 Thread Thomas Huth

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

The 'ide-hd' and 'ide-cd' devices provide suitable alternatives.

Signed-off-by: Daniel P. Berrangé 
---
  docs/qdev-device-use.txt |  2 +-
  docs/system/deprecated.rst   |  6 -
  docs/system/removed-features.rst |  9 
  hw/i386/pc.c |  1 -
  hw/ide/qdev.c| 38 
  hw/ppc/mac_newworld.c| 13 ---
  hw/ppc/mac_oldworld.c| 13 ---
  hw/sparc64/sun4u.c   | 14 
  scripts/device-crash-test|  1 -
  softmmu/vl.c |  1 -
  tests/qemu-iotests/051   |  2 --
  tests/qemu-iotests/051.pc.out| 10 -
  12 files changed, 10 insertions(+), 100 deletions(-)

diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
index 245cdf29c7..2408889334 100644
--- a/docs/qdev-device-use.txt
+++ b/docs/qdev-device-use.txt
@@ -388,7 +388,7 @@ type.
  some DEVNAMEs:
  
  default device  suppressing DEVNAMEs

-CD-ROM  ide-cd, ide-drive, ide-hd, scsi-cd, scsi-hd
+CD-ROM  ide-cd, ide-hd, scsi-cd, scsi-hd
  floppy  floppy, isa-fdc
  parallelisa-parallel
  serial  isa-serial
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index c69887dca8..f5c82a46dc 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -242,12 +242,6 @@ this CPU is also deprecated.
  System emulator devices
  ---
  
-``ide-drive`` (since 4.2)

-'
-
-The 'ide-drive' device is deprecated. Users should use 'ide-hd' or
-'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed.
-
  ``scsi-disk`` (since 4.2)
  '
  
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst

index 870a222062..8fd3fafb32 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -213,6 +213,15 @@ This machine has been renamed ``fuloong2e``.
  These machine types were very old and likely could not be used for live
  migration from old QEMU versions anymore. Use a newer machine type instead.
  
+System emulator devices

+---
+
+``ide-drive`` (removed in 6.0)
+''
+
+The 'ide-drive' device has been removed. Users should use 'ide-hd' or
+'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed.
+
  Related binaries
  
  
diff --git a/hw/i386/pc.c b/hw/i386/pc.c

index 8aa85dec54..828122e21e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -342,7 +342,6 @@ GlobalProperty pc_compat_1_4[] = {
  { "scsi-disk", "discard_granularity", "0" },
  { "ide-hd", "discard_granularity", "0" },
  { "ide-cd", "discard_granularity", "0" },
-{ "ide-drive", "discard_granularity", "0" },
  { "virtio-blk-pci", "discard_granularity", "0" },
  /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string: */
  { "virtio-serial-pci", "vectors", "0x" },
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 8cd19fa5e9..e70ebc83a0 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -283,20 +283,6 @@ static void ide_cd_realize(IDEDevice *dev, Error **errp)
  ide_dev_initfn(dev, IDE_CD, errp);
  }
  
-static void ide_drive_realize(IDEDevice *dev, Error **errp)

-{
-DriveInfo *dinfo = NULL;
-
-warn_report("'ide-drive' is deprecated, "
-"please use 'ide-hd' or 'ide-cd' instead");
-
-if (dev->conf.blk) {
-dinfo = blk_legacy_dinfo(dev->conf.blk);
-}
-
-ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD, errp);
-}


I wonder whether we now could also make the "media" parameter of "-drive" as 
deprecated?


Anyway, for this patch:
Reviewed-by: Thomas Huth 




Re: [PATCH 04/14] softmmu: remove '-usbdevice' command line option

2021-02-24 Thread Daniel P . Berrangé
On Wed, Feb 24, 2021 at 02:58:19PM +0100, Thomas Huth wrote:
> On 24/02/2021 14.11, Daniel P. Berrangé wrote:
> > This was replaced by the '-device usb-DEV' option.
> > 
> > Signed-off-by: Daniel P. Berrangé 
> > ---
> >   docs/system/deprecated.rst   |  9 ---
> >   docs/system/removed-features.rst |  9 +++
> >   softmmu/vl.c | 42 
> >   3 files changed, 9 insertions(+), 51 deletions(-)
> 
> Last time I tried to remove -usbdevice, there was some concerns that
> -usbdevice braille might still be useful for some people, see the thread
> that started here:
> 
>  https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg00651.html
> 
> (and Gerd's summary here:
> https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg01520.html )

Urgh, so the current deprecation docs are a bit misleading by saying
-usbdevice is directly mapped to -device.

> So we might need a new "sugared" option like "-braille" instead before we
> can fully remove -usbdevice? ... or we just keep -usbdevice as a bittersweet
> remainder?

I'm not going to implement new CLI options, and if that's needed, we
ought to re-start the clock on the deprecation at that point. So this
points towards just removing the deprecation warning that exists
today. Or alternatively drop support for -usbdevice, except for the
braille type.

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 :|




[PATCH v2 30/31] vl: QAPIfy -object

2021-02-24 Thread Kevin Wolf
This switches the system emulator from a QemuOpts-based parser for
-object to user_creatable_parse_str() which uses a keyval parser and
enforces the QAPI schema.

Apart from being a cleanup, this makes non-scalar properties accessible.

This adopts a similar model as -blockdev uses: When parsing the option,
create the ObjectOptions and queue them. At the later point where we
used to create objects for the collected QemuOpts, the ObjectOptions
queue is processed instead.

A complication compared to -blockdev is that object definitions are
supported in -readconfig and -writeconfig.

After this patch, -readconfig still works, though it still goes through
the QemuOpts parser, which means that improvements like non-scalar
properties are still not available in config files.

-writeconfig stops working for -object. Tough luck. It has never
supported all options (not even the common ones), so supporting one less
isn't the end of the world. As object definitions from -readconfig still
go through QemuOpts, they are still included in -writeconfig output,
which at least prevents destroying your existing configuration when you
just wanted to add another option.

Signed-off-by: Kevin Wolf 
---
 softmmu/vl.c | 109 +++
 1 file changed, 84 insertions(+), 25 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index b219ce1f35..205c254542 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -113,6 +113,7 @@
 #include "sysemu/replay.h"
 #include "qapi/qapi-events-run-state.h"
 #include "qapi/qapi-visit-block-core.h"
+#include "qapi/qapi-visit-qom.h"
 #include "qapi/qapi-visit-ui.h"
 #include "qapi/qapi-commands-block-core.h"
 #include "qapi/qapi-commands-migration.h"
@@ -132,6 +133,14 @@ typedef struct BlockdevOptionsQueueEntry {
 
 typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue;
 
+typedef struct ObjectOptionsQueueEntry {
+ObjectOptions *options;
+Location loc;
+QTAILQ_ENTRY(ObjectOptionsQueueEntry) next;
+} ObjectOptionsQueueEntry;
+
+typedef QTAILQ_HEAD(, ObjectOptionsQueueEntry) ObjectOptionsQueue;
+
 static const char *cpu_option;
 static const char *mem_path;
 static const char *incoming;
@@ -143,6 +152,7 @@ static int snapshot;
 static bool preconfig_requested;
 static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
 static BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
+static ObjectOptionsQueue obj_queue = QTAILQ_HEAD_INITIALIZER(obj_queue);
 static bool nographic = false;
 static int mem_prealloc; /* force preallocation of physical target memory */
 static ram_addr_t ram_size;
@@ -1691,12 +1701,9 @@ static int machine_set_property(void *opaque,
  * cannot be created here, as it depends on the chardev
  * already existing.
  */
-static bool object_create_early(const char *type, QemuOpts *opts)
+static bool object_create_early(ObjectOptions *options)
 {
-if (user_creatable_print_help(type, opts)) {
-exit(0);
-}
-
+const char *type = ObjectType_str(options->qom_type);
 /*
  * Objects should not be made "delayed" without a reason.  If you
  * add one, state the reason in a comment!
@@ -1744,6 +1751,56 @@ static bool object_create_early(const char *type, 
QemuOpts *opts)
 return true;
 }
 
+static void object_queue_create(bool early)
+{
+ObjectOptionsQueueEntry *entry, *next;
+
+QTAILQ_FOREACH_SAFE(entry, &obj_queue, next, next) {
+if (early != object_create_early(entry->options)) {
+continue;
+}
+QTAILQ_REMOVE(&obj_queue, entry, next);
+loc_push_restore(&entry->loc);
+user_creatable_add_qapi(entry->options, &error_fatal);
+loc_pop(&entry->loc);
+qapi_free_ObjectOptions(entry->options);
+g_free(entry);
+}
+}
+
+/*
+ * -readconfig still parses things into QemuOpts. Convert any such
+ *  configurations to an ObjectOptionsQueueEntry.
+ *
+ *  This is more restricted than the normal -object parser because QemuOpts
+ *  parsed things, so no support for non-scalar properties. Help is also not
+ *  supported (but this shouldn't be requested in a config file anyway).
+ */
+static int object_readconfig_to_qapi(void *opaque, QemuOpts *opts, Error 
**errp)
+{
+ERRP_GUARD();
+ObjectOptionsQueueEntry *entry;
+ObjectOptions *options;
+QDict *args = qemu_opts_to_qdict(opts, NULL);
+Visitor *v;
+
+v = qobject_input_visitor_new_keyval(QOBJECT(args));
+visit_type_ObjectOptions(v, NULL, &options, errp);
+visit_free(v);
+qobject_unref(args);
+
+if (*errp) {
+return -1;
+}
+
+entry = g_new0(ObjectOptionsQueueEntry, 1);
+entry->options = options;
+loc_save(&entry->loc);
+QTAILQ_INSERT_TAIL(&obj_queue, entry, next);
+
+return 0;
+}
+
 static void qemu_apply_machine_options(void)
 {
 MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
@@ -1816,8 +1873,8 @@ static void qemu_create_early_backends(void)
 }
 
 

[PATCH v2 22/31] qom: Remove user_creatable_add_dict()

2021-02-24 Thread Kevin Wolf
This function is now unused and can be removed.

Signed-off-by: Kevin Wolf 
---
 include/qom/object_interfaces.h | 18 --
 qom/object_interfaces.c | 32 
 2 files changed, 50 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 9b9938b8c0..5299603f50 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -86,24 +86,6 @@ Object *user_creatable_add_type(const char *type, const char 
*id,
 const QDict *qdict,
 Visitor *v, Error **errp);
 
-/**
- * user_creatable_add_dict:
- * @qdict: the object definition
- * @keyval: if true, use a keyval visitor for processing @qdict (i.e.
- *  assume that all @qdict values are strings); otherwise, use
- *  the normal QObject visitor (i.e. assume all @qdict values
- *  have the QType expected by the QOM object type)
- * @errp: if an error occurs, a pointer to an area to store the error
- *
- * Create an instance of the user creatable object that is defined by
- * @qdict.  The object type is taken from the QDict key 'qom-type', its
- * ID from the key 'id'. The remaining entries in @qdict are used to
- * initialize the object properties.
- *
- * Returns: %true on success, %false on failure.
- */
-bool user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp);
-
 /**
  * user_creatable_add_opts:
  * @opts: the object definition
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index b9a99c8bf4..7d8a4b77b8 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -104,38 +104,6 @@ out:
 return obj;
 }
 
-bool user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp)
-{
-Visitor *v;
-Object *obj;
-g_autofree char *type = NULL;
-g_autofree char *id = NULL;
-
-type = g_strdup(qdict_get_try_str(qdict, "qom-type"));
-if (!type) {
-error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
-return false;
-}
-qdict_del(qdict, "qom-type");
-
-id = g_strdup(qdict_get_try_str(qdict, "id"));
-if (!id) {
-error_setg(errp, QERR_MISSING_PARAMETER, "id");
-return false;
-}
-qdict_del(qdict, "id");
-
-if (keyval) {
-v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
-} else {
-v = qobject_input_visitor_new(QOBJECT(qdict));
-}
-obj = user_creatable_add_type(type, id, qdict, v, errp);
-visit_free(v);
-object_unref(obj);
-return !!obj;
-}
-
 Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
 {
 Visitor *v;
-- 
2.29.2




[PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object

2021-02-24 Thread Kevin Wolf
This switches qemu-io from a QemuOpts-based parser for --object to
user_creatable_process_cmdline() which uses a keyval parser and enforces
the QAPI schema.

Apart from being a cleanup, this makes non-scalar properties accessible.

Signed-off-by: Kevin Wolf 
---
 qemu-io.c | 33 +++--
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index ac88d8bd40..bf902302e9 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -477,23 +477,6 @@ enum {
 OPTION_IMAGE_OPTS = 257,
 };
 
-static QemuOptsList qemu_object_opts = {
-.name = "object",
-.implied_opt_name = "qom-type",
-.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
-.desc = {
-{ }
-},
-};
-
-static bool qemu_io_object_print_help(const char *type, QemuOpts *opts)
-{
-if (user_creatable_print_help(type, opts)) {
-exit(0);
-}
-return true;
-}
-
 static QemuOptsList file_opts = {
 .name = "file",
 .implied_opt_name = "file",
@@ -550,7 +533,6 @@ int main(int argc, char **argv)
 qcrypto_init(&error_fatal);
 
 module_call_init(MODULE_INIT_QOM);
-qemu_add_opts(&qemu_object_opts);
 qemu_add_opts(&qemu_trace_opts);
 bdrv_init();
 
@@ -612,14 +594,9 @@ int main(int argc, char **argv)
 case 'U':
 force_share = true;
 break;
-case OPTION_OBJECT: {
-QemuOpts *qopts;
-qopts = qemu_opts_parse_noisily(&qemu_object_opts,
-optarg, true);
-if (!qopts) {
-exit(1);
-}
-}   break;
+case OPTION_OBJECT:
+user_creatable_process_cmdline(optarg);
+break;
 case OPTION_IMAGE_OPTS:
 imageOpts = true;
 break;
@@ -644,10 +621,6 @@ int main(int argc, char **argv)
 exit(1);
 }
 
-qemu_opts_foreach(&qemu_object_opts,
-  user_creatable_add_opts_foreach,
-  qemu_io_object_print_help, &error_fatal);
-
 if (!trace_init_backends()) {
 exit(1);
 }
-- 
2.29.2




[PATCH v2 29/31] qom: Add user_creatable_parse_str()

2021-02-24 Thread Kevin Wolf
The system emulator has a more complicated way of handling command line
options in that it reorders options before it processes them. This means
that parsing object options and creating the object happen at two
different points. Split the parsing part into a separate function that
can be reused by the system emulator command line.

Signed-off-by: Kevin Wolf 
---
 include/qom/object_interfaces.h | 15 +++
 qom/object_interfaces.c | 20 ++--
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 07511e6cff..fb32330901 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -144,6 +144,21 @@ typedef bool (*user_creatable_add_opts_predicate)(const 
char *type);
 int user_creatable_add_opts_foreach(void *opaque,
 QemuOpts *opts, Error **errp);
 
+/**
+ * user_creatable_parse_str:
+ * @optarg: the object definition string as passed on the command line
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Parses the option for the user creatable object with a keyval parser and
+ * implicit key 'qom-type', converting the result to ObjectOptions.
+ *
+ * If a help option is given, print help instead.
+ *
+ * Returns: ObjectOptions on success, NULL when an error occurred (*errp is set
+ * then) or help was printed (*errp is not set).
+ */
+ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp);
+
 /**
  * user_creatable_add_from_str:
  * @optarg: the object definition string as passed on the command line
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index c4982dd7a0..1c29f45b41 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -283,7 +283,7 @@ static void user_creatable_print_help_from_qdict(QDict 
*args)
 }
 }
 
-bool user_creatable_add_from_str(const char *optarg, Error **errp)
+ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
 {
 ERRP_GUARD();
 QDict *args;
@@ -293,12 +293,12 @@ bool user_creatable_add_from_str(const char *optarg, 
Error **errp)
 
 args = keyval_parse(optarg, "qom-type", &help, errp);
 if (*errp) {
-return false;
+return NULL;
 }
 if (help) {
 user_creatable_print_help_from_qdict(args);
 qobject_unref(args);
-return false;
+return NULL;
 }
 
 v = qobject_input_visitor_new_keyval(QOBJECT(args));
@@ -306,12 +306,20 @@ bool user_creatable_add_from_str(const char *optarg, 
Error **errp)
 visit_free(v);
 qobject_unref(args);
 
-if (*errp) {
-goto out;
+return options;
+}
+
+bool user_creatable_add_from_str(const char *optarg, Error **errp)
+{
+ERRP_GUARD();
+ObjectOptions *options;
+
+options = user_creatable_parse_str(optarg, errp);
+if (!options) {
+return false;
 }
 
 user_creatable_add_qapi(options, errp);
-out:
 qapi_free_ObjectOptions(options);
 return !*errp;
 }
-- 
2.29.2




[PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline()

2021-02-24 Thread Kevin Wolf
The implementation for --object can be shared between
qemu-storage-daemon and other binaries, so move it into a function in
qom/object_interfaces.c that is accessible from everywhere.

This also requires moving the implementation of qmp_object_add() into a
new user_creatable_add_qapi(), because qom/qom-qmp-cmds.c is not linked
for tools.

user_creatable_print_help_from_qdict() can become static now.

Signed-off-by: Kevin Wolf 
---
 include/qom/object_interfaces.h  | 41 +++
 qom/object_interfaces.c  | 50 +++-
 qom/qom-qmp-cmds.c   | 20 +--
 storage-daemon/qemu-storage-daemon.c | 22 +---
 4 files changed, 79 insertions(+), 54 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 5299603f50..1e6c51b541 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -2,6 +2,7 @@
 #define OBJECT_INTERFACES_H
 
 #include "qom/object.h"
+#include "qapi/qapi-types-qom.h"
 #include "qapi/visitor.h"
 
 #define TYPE_USER_CREATABLE "user-creatable"
@@ -86,6 +87,18 @@ Object *user_creatable_add_type(const char *type, const char 
*id,
 const QDict *qdict,
 Visitor *v, Error **errp);
 
+/**
+ * user_creatable_add_qapi:
+ * @options: the object definition
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Create an instance of the user creatable object according to the
+ * options passed in @opts as described in the QAPI schema documentation.
+ *
+ * Returns: the newly created object or NULL on error
+ */
+void user_creatable_add_qapi(ObjectOptions *options, Error **errp);
+
 /**
  * user_creatable_add_opts:
  * @opts: the object definition
@@ -131,6 +144,21 @@ typedef bool (*user_creatable_add_opts_predicate)(const 
char *type);
 int user_creatable_add_opts_foreach(void *opaque,
 QemuOpts *opts, Error **errp);
 
+/**
+ * user_creatable_process_cmdline:
+ * @optarg: the object definition string as passed on the command line
+ *
+ * Create an instance of the user creatable object by parsing optarg
+ * with a keyval parser and implicit key 'qom-type', converting the
+ * result to ObjectOptions and calling into qmp_object_add().
+ *
+ * If a help option is given, print help instead and exit.
+ *
+ * This function is only meant to be called during command line parsing.
+ * It exits the process on failure or after printing help.
+ */
+void user_creatable_process_cmdline(const char *optarg);
+
 /**
  * user_creatable_print_help:
  * @type: the QOM type to be added
@@ -145,19 +173,6 @@ int user_creatable_add_opts_foreach(void *opaque,
  */
 bool user_creatable_print_help(const char *type, QemuOpts *opts);
 
-/**
- * user_creatable_print_help_from_qdict:
- * @args: options to create
- *
- * Prints help considering the other options given in @args (if "qom-type" is
- * given and valid, print properties for the type, otherwise print valid types)
- *
- * In contrast to user_creatable_print_help(), this function can't return that
- * no help was requested. It should only be called if we know that help is
- * requested and it will always print some help.
- */
-void user_creatable_print_help_from_qdict(QDict *args);
-
 /**
  * user_creatable_del:
  * @id: the unique ID for the object
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d8a4b77b8..efb48249d5 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -2,10 +2,13 @@
 
 #include "qemu/cutils.h"
 #include "qapi/error.h"
+#include "qapi/qapi-commands-qom.h"
+#include "qapi/qapi-visit-qom.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
 #include "qom/object_interfaces.h"
 #include "qemu/help_option.h"
 #include "qemu/module.h"
@@ -104,6 +107,29 @@ out:
 return obj;
 }
 
+void user_creatable_add_qapi(ObjectOptions *options, Error **errp)
+{
+Visitor *v;
+QObject *qobj;
+QDict *props;
+Object *obj;
+
+v = qobject_output_visitor_new(&qobj);
+visit_type_ObjectOptions(v, NULL, &options, &error_abort);
+visit_complete(v, &qobj);
+visit_free(v);
+
+props = qobject_to(QDict, qobj);
+qdict_del(props, "qom-type");
+qdict_del(props, "id");
+
+v = qobject_input_visitor_new(QOBJECT(props));
+obj = user_creatable_add_type(ObjectType_str(options->qom_type),
+  options->id, props, v, errp);
+object_unref(obj);
+visit_free(v);
+}
+
 Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
 {
 Visitor *v;
@@ -247,7 +273,7 @@ bool user_creatable_print_help(const char *type, QemuOpts 
*opts)
 return false;
 }
 
-void user_creatable_print_help_from_qdict(QDict *args)
+static void user_creatable_print_help_from_qdict(QDict *args)
 {
 const char *type = q

[PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the colo-compare object.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 49 +
 1 file changed, 49 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 4b1cd4b8dc..8e4414f843 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -222,6 +222,53 @@
   'data': { 'if': 'str',
 'canbus': 'str' } }
 
+##
+# @ColoCompareProperties:
+#
+# Properties for colo-compare objects.
+#
+# @primary_in: name of the character device backend to use for the primary
+#  input (incoming packets are redirected to @outdev)
+#
+# @secondary_in: name of the character device backend to use for secondary
+#input (incoming packets are only compared to the input on
+#@primary_in and then dropped)
+#
+# @outdev: name of the character device backend to use for output
+#
+# @iothread: name of the iothread to run in
+#
+# @notify_dev: name of the character device backend to be used to communicate
+#  with the remote colo-frame (only for Xen COLO)
+#
+# @compare_timeout: the maximum time to hold a packet from @primary_in for
+#   comparison with an incoming packet on @secondary_in in
+#   milliseconds (default: 3000)
+#
+# @expired_scan_cycle: the interval at which colo-compare checks whether
+#  packets from @primary have timed out, in milliseconds
+#  (default: 3000)
+#
+# @max_queue_size: the maximum number of packets to keep in the queue for
+#  comparing with incoming packets from @secondary_in.  If the
+#  queue is full and addtional packets are received, the
+#  addtional packets are dropped. (default: 1024)
+#
+# @vnet_hdr_support: if true, vnet header support is enabled (default: false)
+#
+# Since: 2.8
+##
+{ 'struct': 'ColoCompareProperties',
+  'data': { 'primary_in': 'str',
+'secondary_in': 'str',
+'outdev': 'str',
+'iothread': 'str',
+'*notify_dev': 'str',
+'*compare_timeout': 'uint64',
+'*expired_scan_cycle': 'uint32',
+'*max_queue_size': 'uint32',
+'*vnet_hdr_support': 'bool' } }
+
 ##
 # @CryptodevBackendProperties:
 #
@@ -456,6 +503,7 @@
 'authz-simple',
 'can-bus',
 'can-host-socketcan',
+'colo-compare',
 'cryptodev-backend',
 'cryptodev-backend-builtin',
 'cryptodev-vhost-user',
@@ -497,6 +545,7 @@
   'authz-pam':  'AuthZPAMProperties',
   'authz-simple':   'AuthZSimpleProperties',
   'can-host-socketcan': 'CanHostSocketcanProperties',
+  'colo-compare':   'ColoCompareProperties',
   'cryptodev-backend':  'CryptodevBackendProperties',
   'cryptodev-backend-builtin':  'CryptodevBackendProperties',
   'cryptodev-vhost-user':   'CryptodevVhostUserProperties',
-- 
2.29.2




[PATCH v2 27/31] qom: Add user_creatable_add_from_str()

2021-02-24 Thread Kevin Wolf
This is a version of user_creatable_process_cmdline() with an Error
parameter that never calls exit() and is therefore usable in HMP.

Signed-off-by: Kevin Wolf 
---
 include/qom/object_interfaces.h | 16 
 qom/object_interfaces.c | 29 -
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 1e6c51b541..07511e6cff 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -144,6 +144,22 @@ typedef bool (*user_creatable_add_opts_predicate)(const 
char *type);
 int user_creatable_add_opts_foreach(void *opaque,
 QemuOpts *opts, Error **errp);
 
+/**
+ * user_creatable_add_from_str:
+ * @optarg: the object definition string as passed on the command line
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Create an instance of the user creatable object by parsing optarg
+ * with a keyval parser and implicit key 'qom-type', converting the
+ * result to ObjectOptions and calling into qmp_object_add().
+ *
+ * If a help option is given, print help instead.
+ *
+ * Returns: true when an object was successfully created, false when an error
+ * occurred (*errp is set then) or help was printed (*errp is not set).
+ */
+bool user_creatable_add_from_str(const char *optarg, Error **errp);
+
 /**
  * user_creatable_process_cmdline:
  * @optarg: the object definition string as passed on the command line
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index efb48249d5..54f0dadfea 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -282,26 +282,45 @@ static void user_creatable_print_help_from_qdict(QDict 
*args)
 }
 }
 
-void user_creatable_process_cmdline(const char *optarg)
+bool user_creatable_add_from_str(const char *optarg, Error **errp)
 {
+ERRP_GUARD();
 QDict *args;
 bool help;
 Visitor *v;
 ObjectOptions *options;
 
-args = keyval_parse(optarg, "qom-type", &help, &error_fatal);
+args = keyval_parse(optarg, "qom-type", &help, errp);
+if (*errp) {
+return false;
+}
 if (help) {
 user_creatable_print_help_from_qdict(args);
-exit(EXIT_SUCCESS);
+qobject_unref(args);
+return false;
 }
 
 v = qobject_input_visitor_new_keyval(QOBJECT(args));
-visit_type_ObjectOptions(v, NULL, &options, &error_fatal);
+visit_type_ObjectOptions(v, NULL, &options, errp);
 visit_free(v);
 qobject_unref(args);
 
-user_creatable_add_qapi(options, &error_fatal);
+if (*errp) {
+goto out;
+}
+
+user_creatable_add_qapi(options, errp);
+out:
 qapi_free_ObjectOptions(options);
+return !*errp;
+}
+
+void user_creatable_process_cmdline(const char *optarg)
+{
+if (!user_creatable_add_from_str(optarg, &error_fatal)) {
+/* Help was printed */
+exit(EXIT_SUCCESS);
+}
 }
 
 bool user_creatable_del(const char *id, Error **errp)
-- 
2.29.2




Re: [PATCH] blockjob: report a better error message

2021-02-24 Thread Kevin Wolf
Am 23.02.2021 um 14:11 hat Stefano Garzarella geschrieben:
> When a block job fails, we report 'strerror(-job->job.ret)' error
> message, also if the job set an error object.
> Let's report a better error message using 'error_get_pretty(job->job.err)'.
> 
> If an error object was not set, strerror(-job->ret) is used as fallback,
> as explained in include/qemu/job.h:
> 
> typedef struct Job {
> ...
> /**
>  * Error object for a failed job.
>  * If job->ret is nonzero and an error object was not set, it will be set
>  * to strerror(-job->ret) during job_completed.
>  */
> Error *err;
> }

This is true, but there is a short time where job->ret is already set,
but not turned into job->err yet if necessary. The latter is done in a
bottom half scheduled after the former has happened.

It doesn't matter for block_job_event_completed(), which is called only
after both, but block_job_query() could in theory be called in this
window.

> Suggested-by: Kevin Wolf 
> Signed-off-by: Stefano Garzarella 
> ---
>  blockjob.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/blockjob.c b/blockjob.c
> index f2feff051d..a696f3408d 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -319,7 +319,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
>  info->auto_finalize = job->job.auto_finalize;
>  info->auto_dismiss  = job->job.auto_dismiss;
>  info->has_error = job->job.ret != 0;
> -info->error = job->job.ret ? g_strdup(strerror(-job->job.ret)) : 
> NULL;
> +info->error = job->job.ret ?
> +g_strdup(error_get_pretty(job->job.err)) : NULL;

So I think we can't rely on job->job.err being non-NULL here.

>  return info;
>  }
>  
> @@ -356,7 +357,7 @@ static void block_job_event_completed(Notifier *n, void 
> *opaque)
>  }
>  
>  if (job->job.ret < 0) {
> -msg = strerror(-job->job.ret);
> +msg = error_get_pretty(job->job.err);
>  }
>  
>  qapi_event_send_block_job_completed(job_type(&job->job),

Kevin




[PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the throttle-group object.

The only purpose of the x-* properties is to make the nested options in
'limits' available for a command line parser that doesn't support
structs. Any parser that will use the QAPI schema will supports structs,
though, so they will not be needed in the schema in the future.

To keep the conversion straightforward, add them to the schema anyway.
We can then remove the options and adjust documentation, test cases etc.
in a separate patch.

Signed-off-by: Kevin Wolf 
---
 qapi/block-core.json | 27 +++
 qapi/qom.json|  7 +--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9f555d5c1d..a67fa0cc59 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2504,6 +2504,33 @@
 '*bps-write-max' : 'int', '*bps-write-max-length' : 'int',
 '*iops-size' : 'int' } }
 
+##
+# @ThrottleGroupProperties:
+#
+# Properties for throttle-group objects.
+#
+# The options starting with x- are aliases for the same key without x- in
+# the @limits object. As indicated by the x- prefix, this is not a stable
+# interface and may be removed or changed incompatibly in the future. Use
+# @limits for a supported stable interface.
+#
+# @limits: limits to apply for this throttle group
+#
+# Since: 2.11
+##
+{ 'struct': 'ThrottleGroupProperties',
+  'data': { '*limits': 'ThrottleLimits',
+'*x-iops-total' : 'int', '*x-iops-total-max' : 'int',
+'*x-iops-total-max-length' : 'int', '*x-iops-read' : 'int',
+'*x-iops-read-max' : 'int', '*x-iops-read-max-length' : 'int',
+'*x-iops-write' : 'int', '*x-iops-write-max' : 'int',
+'*x-iops-write-max-length' : 'int', '*x-bps-total' : 'int',
+'*x-bps-total-max' : 'int', '*x-bps-total-max-length' : 'int',
+'*x-bps-read' : 'int', '*x-bps-read-max' : 'int',
+'*x-bps-read-max-length' : 'int', '*x-bps-write' : 'int',
+'*x-bps-write-max' : 'int', '*x-bps-write-max-length' : 'int',
+'*x-iops-size' : 'int' } }
+
 ##
 # @block-stream:
 #
diff --git a/qapi/qom.json b/qapi/qom.json
index 73f28f9608..449dca8ec5 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -5,6 +5,7 @@
 # See the COPYING file in the top-level directory.
 
 { 'include': 'authz.json' }
+{ 'include': 'block-core.json' }
 { 'include': 'common.json' }
 
 ##
@@ -447,7 +448,8 @@
 'memory-backend-ram',
 'rng-builtin',
 'rng-egd',
-'rng-random'
+'rng-random',
+'throttle-group'
   ] }
 
 ##
@@ -480,7 +482,8 @@
   'memory-backend-ram': 'MemoryBackendProperties',
   'rng-builtin':'RngProperties',
   'rng-egd':'RngEgdProperties',
-  'rng-random': 'RngRandomProperties'
+  'rng-random': 'RngRandomProperties',
+  'throttle-group': 'ThrottleGroupProperties'
   } }
 
 ##
-- 
2.29.2




[PATCH v2 25/31] qemu-img: Use user_creatable_process_cmdline() for --object

2021-02-24 Thread Kevin Wolf
This switches qemu-img from a QemuOpts-based parser for --object to
user_creatable_process_cmdline() which uses a keyval parser and enforces
the QAPI schema.

Apart from being a cleanup, this makes non-scalar properties accessible.

Signed-off-by: Kevin Wolf 
---
 qemu-img.c | 239 -
 1 file changed, 33 insertions(+), 206 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index e2952fe955..ebf8661e2a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -226,23 +226,6 @@ static void QEMU_NORETURN help(void)
 exit(EXIT_SUCCESS);
 }
 
-static QemuOptsList qemu_object_opts = {
-.name = "object",
-.implied_opt_name = "qom-type",
-.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
-.desc = {
-{ }
-},
-};
-
-static bool qemu_img_object_print_help(const char *type, QemuOpts *opts)
-{
-if (user_creatable_print_help(type, opts)) {
-exit(0);
-}
-return true;
-}
-
 /*
  * Is @optarg safe for accumulate_options()?
  * It is when multiple of them can be joined together separated by ','.
@@ -566,14 +549,9 @@ static int img_create(int argc, char **argv)
 case 'u':
 flags |= BDRV_O_NO_BACKING;
 break;
-case OPTION_OBJECT: {
-QemuOpts *opts;
-opts = qemu_opts_parse_noisily(&qemu_object_opts,
-   optarg, true);
-if (!opts) {
-goto fail;
-}
-}   break;
+case OPTION_OBJECT:
+user_creatable_process_cmdline(optarg);
+break;
 }
 }
 
@@ -589,12 +567,6 @@ static int img_create(int argc, char **argv)
 }
 optind++;
 
-if (qemu_opts_foreach(&qemu_object_opts,
-  user_creatable_add_opts_foreach,
-  qemu_img_object_print_help, &error_fatal)) {
-goto fail;
-}
-
 /* Get image size, if specified */
 if (optind < argc) {
 int64_t sval;
@@ -804,14 +776,9 @@ static int img_check(int argc, char **argv)
 case 'U':
 force_share = true;
 break;
-case OPTION_OBJECT: {
-QemuOpts *opts;
-opts = qemu_opts_parse_noisily(&qemu_object_opts,
-   optarg, true);
-if (!opts) {
-return 1;
-}
-}   break;
+case OPTION_OBJECT:
+user_creatable_process_cmdline(optarg);
+break;
 case OPTION_IMAGE_OPTS:
 image_opts = true;
 break;
@@ -831,12 +798,6 @@ static int img_check(int argc, char **argv)
 return 1;
 }
 
-if (qemu_opts_foreach(&qemu_object_opts,
-  user_creatable_add_opts_foreach,
-  qemu_img_object_print_help, &error_fatal)) {
-return 1;
-}
-
 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough);
 if (ret < 0) {
 error_report("Invalid source cache option: %s", cache);
@@ -1034,14 +995,9 @@ static int img_commit(int argc, char **argv)
 return 1;
 }
 break;
-case OPTION_OBJECT: {
-QemuOpts *opts;
-opts = qemu_opts_parse_noisily(&qemu_object_opts,
-   optarg, true);
-if (!opts) {
-return 1;
-}
-}   break;
+case OPTION_OBJECT:
+user_creatable_process_cmdline(optarg);
+break;
 case OPTION_IMAGE_OPTS:
 image_opts = true;
 break;
@@ -1058,12 +1014,6 @@ static int img_commit(int argc, char **argv)
 }
 filename = argv[optind++];
 
-if (qemu_opts_foreach(&qemu_object_opts,
-  user_creatable_add_opts_foreach,
-  qemu_img_object_print_help, &error_fatal)) {
-return 1;
-}
-
 flags = BDRV_O_RDWR | BDRV_O_UNMAP;
 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough);
 if (ret < 0) {
@@ -1423,15 +1373,9 @@ static int img_compare(int argc, char **argv)
 case 'U':
 force_share = true;
 break;
-case OPTION_OBJECT: {
-QemuOpts *opts;
-opts = qemu_opts_parse_noisily(&qemu_object_opts,
-   optarg, true);
-if (!opts) {
-ret = 2;
-goto out4;
-}
-}   break;
+case OPTION_OBJECT:
+user_creatable_process_cmdline(optarg);
+break;
 case OPTION_IMAGE_OPTS:
 image_opts = true;
 break;
@@ -1450,13 +1394,6 @@ static int img_compare(int argc, char **argv)
 filename1 = argv[optind++];
 filename2 = argv[optind++];
 
-if (qemu_opts_foreach(&qemu_object_opts,
-  user_creatable_add_opts_foreach,
-  qemu_img_object_print_he

[PATCH v2 28/31] hmp: QAPIfy object_add

2021-02-24 Thread Kevin Wolf
This switches the HMP command object_add from a QemuOpts-based parser to
user_creatable_add_from_str() which uses a keyval parser and enforces
the QAPI schema.

Apart from being a cleanup, this makes non-scalar properties and help
accessible. In order for help to be printed to the monitor instead of
stdout, the printf() calls in the help functions are changed to
qemu_printf().

Signed-off-by: Kevin Wolf 
---
 monitor/hmp-cmds.c  | 17 ++---
 qom/object_interfaces.c | 11 ++-
 hmp-commands.hx |  2 +-
 3 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 3c88a4faef..652cf9ff21 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1670,24 +1670,11 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
 
 void hmp_object_add(Monitor *mon, const QDict *qdict)
 {
+const char *options = qdict_get_str(qdict, "object");
 Error *err = NULL;
-QemuOpts *opts;
-Object *obj = NULL;
-
-opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
-if (err) {
-goto end;
-}
 
-obj = user_creatable_add_opts(opts, &err);
-qemu_opts_del(opts);
-
-end:
+user_creatable_add_from_str(options, &err);
 hmp_handle_error(mon, err);
-
-if (obj) {
-object_unref(obj);
-}
 }
 
 void hmp_getfd(Monitor *mon, const QDict *qdict)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 54f0dadfea..c4982dd7a0 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -13,6 +13,7 @@
 #include "qemu/help_option.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
+#include "qemu/qemu-print.h"
 #include "qapi/opts-visitor.h"
 #include "qemu/config-file.h"
 
@@ -212,11 +213,11 @@ static void user_creatable_print_types(void)
 {
 GSList *l, *list;
 
-printf("List of user creatable objects:\n");
+qemu_printf("List of user creatable objects:\n");
 list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
 for (l = list; l != NULL; l = l->next) {
 ObjectClass *oc = OBJECT_CLASS(l->data);
-printf("  %s\n", object_class_get_name(oc));
+qemu_printf("  %s\n", object_class_get_name(oc));
 }
 g_slist_free(list);
 }
@@ -247,12 +248,12 @@ static bool user_creatable_print_type_properites(const 
char *type)
 }
 g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
 if (array->len > 0) {
-printf("%s options:\n", type);
+qemu_printf("%s options:\n", type);
 } else {
-printf("There are no options for %s.\n", type);
+qemu_printf("There are no options for %s.\n", type);
 }
 for (i = 0; i < array->len; i++) {
-printf("%s\n", (char *)array->pdata[i]);
+qemu_printf("%s\n", (char *)array->pdata[i]);
 }
 g_ptr_array_set_free_func(array, g_free);
 g_ptr_array_free(array, true);
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d4001f9c5d..6f5d9ce2fb 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1337,7 +1337,7 @@ ERST
 
 {
 .name   = "object_add",
-.args_type  = "object:O",
+.args_type  = "object:S",
 .params = "[qom-type=]type,id=str[,prop=value][,...]",
 .help   = "create QOM object",
 .cmd= hmp_object_add,
-- 
2.29.2




[PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-*

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the authz-* objects.

Signed-off-by: Kevin Wolf 
---
 qapi/authz.json  | 62 
 qapi/qom.json| 10 +
 storage-daemon/qapi/qapi-schema.json |  1 +
 3 files changed, 73 insertions(+)

diff --git a/qapi/authz.json b/qapi/authz.json
index 42afe752d1..99d49aa563 100644
--- a/qapi/authz.json
+++ b/qapi/authz.json
@@ -59,3 +59,65 @@
 ##
 { 'struct': 'QAuthZListRuleListHack',
   'data': { 'unused': ['QAuthZListRule'] } }
+
+##
+# @AuthZListProperties:
+#
+# Properties for authz-list objects.
+#
+# @policy: Default policy to apply when no rule matches (default: deny)
+#
+# @rules: Authorization rules based on matching user
+#
+# Since: 4.0
+##
+{ 'struct': 'AuthZListProperties',
+  'data': { '*policy': 'QAuthZListPolicy',
+'*rules': ['QAuthZListRule'] } }
+
+##
+# @AuthZListFileProperties:
+#
+# Properties for authz-listfile objects.
+#
+# @filename: File name to load the configuration from. The file must
+#contain valid JSON for AuthZListProperties.
+#
+# @refresh: If true, inotify is used to monitor the file, automatically
+#   reloading changes. If an error occurs during reloading, all
+#   authorizations will fail until the file is next successfully
+#   loaded. (default: true if the binary was built with
+#   CONFIG_INOTIFY1, false otherwise)
+#
+# Since: 4.0
+##
+{ 'struct': 'AuthZListFileProperties',
+  'data': { 'filename': 'str',
+'*refresh': 'bool' } }
+
+##
+# @AuthZPAMProperties:
+#
+# Properties for authz-pam objects.
+#
+# @service: PAM service name to use for authorization
+#
+# Since: 4.0
+##
+{ 'struct': 'AuthZPAMProperties',
+  'data': { 'service': 'str' } }
+
+##
+# @AuthZSimpleProperties:
+#
+# Properties for authz-simple objects.
+#
+# @identity: Identifies the allowed user. Its format depends on the network
+#service that authorization object is associated with. For
+#authorizing based on TLS x509 certificates, the identity must be
+#the x509 distinguished name.
+#
+# Since: 4.0
+##
+{ 'struct': 'AuthZSimpleProperties',
+  'data': { 'identity': 'str' } }
diff --git a/qapi/qom.json b/qapi/qom.json
index bf2ecb34be..30ed179bc1 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -4,6 +4,8 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+{ 'include': 'authz.json' }
+
 ##
 # = QEMU Object Model (QOM)
 ##
@@ -233,6 +235,10 @@
 ##
 { 'enum': 'ObjectType',
   'data': [
+'authz-list',
+'authz-listfile',
+'authz-pam',
+'authz-simple',
 'iothread'
   ] }
 
@@ -252,6 +258,10 @@
 'id': 'str' },
   'discriminator': 'qom-type',
   'data': {
+  'authz-list': 'AuthZListProperties',
+  'authz-listfile': 'AuthZListFileProperties',
+  'authz-pam':  'AuthZPAMProperties',
+  'authz-simple':   'AuthZSimpleProperties',
   'iothread':   'IothreadProperties'
   } }
 
diff --git a/storage-daemon/qapi/qapi-schema.json 
b/storage-daemon/qapi/qapi-schema.json
index 28117c3aac..67749d1101 100644
--- a/storage-daemon/qapi/qapi-schema.json
+++ b/storage-daemon/qapi/qapi-schema.json
@@ -26,6 +26,7 @@
 { 'include': '../../qapi/crypto.json' }
 { 'include': '../../qapi/introspect.json' }
 { 'include': '../../qapi/job.json' }
+{ 'include': '../../qapi/authz.json' }
 { 'include': '../../qapi/qom.json' }
 { 'include': '../../qapi/sockets.json' }
 { 'include': '../../qapi/transaction.json' }
-- 
2.29.2




[PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the tls-* objects.

The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true in ucc->complete, and
explicitly setting it to true earlier just means that additional options
will be silently ignored.

In other words, the 'loaded' property is useless. Mark it as deprecated
in the schema from the start.

Signed-off-by: Kevin Wolf 
---
 qapi/crypto.json | 98 
 qapi/qom.json| 12 +-
 2 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 0fef3de66d..7116ae9a46 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -442,3 +442,101 @@
 { 'struct': 'SecretKeyringProperties',
   'base': 'SecretCommonProperties',
   'data': { 'serial': 'int32' } }
+
+##
+# @TlsCredsProperties:
+#
+# Properties for objects of classes derived from tls-creds.
+#
+# @verify-peer: if true the peer credentials will be verified once the
+#   handshake is completed.  This is a no-op for anonymous
+#   credentials. (default: true)
+#
+# @dir: the path of the directory that contains the credential files
+#
+# @endpoint: whether the QEMU network backend that uses the credentials will be
+#acting as a client or as a server (default: client)
+#
+# @priority: a gnutls priority string as described at
+#https://gnutls.org/manual/html_node/Priority-Strings.html
+#
+# Since: 2.5
+##
+{ 'struct': 'TlsCredsProperties',
+  'data': { '*verify-peer': 'bool',
+'*dir': 'str',
+'*endpoint': 'QCryptoTLSCredsEndpoint',
+'*priority': 'str' } }
+
+##
+# @TlsCredsAnonProperties:
+#
+# Properties for tls-creds-anon objects.
+#
+# @loaded: if true, the credentials are loaded immediately when applying this
+#  option and will ignore options that are processed later. Don't use;
+#  only provided for compatibility. (default: false)
+#
+# Features:
+# @deprecated: Member @loaded is deprecated.  Setting true doesn't make sense,
+#  and false is already the default.
+#
+# Since: 2.5
+##
+{ 'struct': 'TlsCredsAnonProperties',
+  'base': 'TlsCredsProperties',
+  'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] } } }
+
+##
+# @TlsCredsPskProperties:
+#
+# Properties for tls-creds-psk objects.
+#
+# @loaded: if true, the credentials are loaded immediately when applying this
+#  option and will ignore options that are processed later. Don't use;
+#  only provided for compatibility. (default: false)
+#
+# @username: the username which will be sent to the server.  For clients only.
+#If absent, "qemu" is sent and the property will read back as an
+#empty string.
+#
+# Features:
+# @deprecated: Member @loaded is deprecated.  Setting true doesn't make sense,
+#  and false is already the default.
+#
+# Since: 3.0
+##
+{ 'struct': 'TlsCredsPskProperties',
+  'base': 'TlsCredsProperties',
+  'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] },
+'*username': 'str' } }
+
+##
+# @TlsCredsX509Properties:
+#
+# Properties for tls-creds-x509 objects.
+#
+# @loaded: if true, the credentials are loaded immediately when applying this
+#  option and will ignore options that are processed later. Don't use;
+#  only provided for compatibility. (default: false)
+#
+# @sanity-check: if true, perform some sanity checks before using the
+#credentials (default: true)
+#
+# @passwordid: For the server-key.pem and client-key.pem files which contain
+#  sensitive private keys, it is possible to use an encrypted
+#  version by providing the @passwordid parameter.  This provides
+#  the ID of a previously created secret object containing the
+#  password for decryption.
+#
+# Features:
+# @deprecated: Member @loaded is deprecated.  Setting true doesn't make sense,
+#  and false is already the default.
+#
+# Since: 2.5
+##
+{ 'struct': 'TlsCredsX509Properties',
+  'base': 'TlsCredsProperties',
+  'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] },
+'*sanity-check': 'bool',
+'*passwordid': 'str' } }
diff --git a/qapi/qom.json b/qapi/qom.json
index 2668ad8369..f22b7aa99b 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -452,7 +452,11 @@
 'rng-random',
 'secret',
 'secret_keyring',
-'throttle-group'
+'throttle-group',
+'tls-creds-anon',
+'tls-creds-psk',
+'tls-creds-x509',
+'tls-cipher-suites'
   ] }
 
 ##
@@ -488,7 +492,11 @@
   'rng-random': 'RngRandomProperties',
   'secret': 'SecretProperties',
   'secret_keyring': 'SecretKeyringProperties',
-  'throttle-group': 'ThrottleGroupProperties'
+  'throttle-group': 'ThrottleGroupProperties',
+  '

Re: [PATCH 04/14] softmmu: remove '-usbdevice' command line option

2021-02-24 Thread Thomas Huth

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

This was replaced by the '-device usb-DEV' option.

Signed-off-by: Daniel P. Berrangé 
---
  docs/system/deprecated.rst   |  9 ---
  docs/system/removed-features.rst |  9 +++
  softmmu/vl.c | 42 
  3 files changed, 9 insertions(+), 51 deletions(-)


Last time I tried to remove -usbdevice, there was some concerns that 
-usbdevice braille might still be useful for some people, see the thread 
that started here:


 https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg00651.html

(and Gerd's summary here: 
https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg01520.html )


So we might need a new "sugared" option like "-braille" instead before we 
can fully remove -usbdevice? ... or we just keep -usbdevice as a bittersweet 
remainder?


 Thomas




[PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add()

2021-02-24 Thread Kevin Wolf
This QAPIfies --object and ensures that QMP and the command line option
behave the same.

Signed-off-by: Kevin Wolf 
---
 storage-daemon/qemu-storage-daemon.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/storage-daemon/qemu-storage-daemon.c 
b/storage-daemon/qemu-storage-daemon.c
index d8d172cc60..0dfb9c1448 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -38,6 +38,7 @@
 #include "qapi/qapi-visit-block-core.h"
 #include "qapi/qapi-visit-block-export.h"
 #include "qapi/qapi-visit-control.h"
+#include "qapi/qapi-visit-qom.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/qobject-input-visitor.h"
@@ -130,15 +131,6 @@ enum {
 
 extern QemuOptsList qemu_chardev_opts;
 
-static QemuOptsList qemu_object_opts = {
-.name = "object",
-.implied_opt_name = "qom-type",
-.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
-.desc = {
-{ }
-},
-};
-
 static void init_qmp_commands(void)
 {
 qmp_init_marshal(&qmp_commands);
@@ -263,14 +255,22 @@ static void process_options(int argc, char *argv[])
 {
 QDict *args;
 bool help;
+Visitor *v;
+ObjectOptions *options;
 
 args = keyval_parse(optarg, "qom-type", &help, &error_fatal);
 if (help) {
 user_creatable_print_help_from_qdict(args);
 exit(EXIT_SUCCESS);
 }
-user_creatable_add_dict(args, true, &error_fatal);
+
+v = qobject_input_visitor_new_keyval(QOBJECT(args));
+visit_type_ObjectOptions(v, NULL, &options, &error_fatal);
+visit_free(v);
 qobject_unref(args);
+
+qmp_object_add(options, &error_fatal);
+qapi_free_ObjectOptions(options);
 break;
 }
 default:
@@ -295,7 +295,6 @@ int main(int argc, char *argv[])
 
 module_call_init(MODULE_INIT_QOM);
 module_call_init(MODULE_INIT_TRACE);
-qemu_add_opts(&qemu_object_opts);
 qemu_add_opts(&qemu_trace_opts);
 qcrypto_init(&error_fatal);
 bdrv_init();
-- 
2.29.2




[PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the pr-manager-helper
object.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index e3357f5123..e7184122e9 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -575,6 +575,18 @@
 '*hugetlbsize': 'size',
 '*seal': 'bool' } }
 
+##
+# @PrManagerHelperProperties:
+#
+# Properties for pr-manager-helper objects.
+#
+# @path: the path to a Unix domain socket for connecting to the external helper
+#
+# Since: 2.11
+##
+{ 'struct': 'PrManagerHelperProperties',
+  'data': { 'path': 'str' } }
+
 ##
 # @RngProperties:
 #
@@ -649,6 +661,7 @@
 'memory-backend-file',
 'memory-backend-memfd',
 'memory-backend-ram',
+'pr-manager-helper',
 'rng-builtin',
 'rng-egd',
 'rng-random',
@@ -697,6 +710,7 @@
   'memory-backend-file':'MemoryBackendFileProperties',
   'memory-backend-memfd':   'MemoryBackendMemfdProperties',
   'memory-backend-ram': 'MemoryBackendProperties',
+  'pr-manager-helper':  'PrManagerHelperProperties',
   'rng-builtin':'RngProperties',
   'rng-egd':'RngEgdProperties',
   'rng-random': 'RngRandomProperties',
-- 
2.29.2




[PATCH v2 31/31] qom: Drop QemuOpts based interfaces

2021-02-24 Thread Kevin Wolf
user_creatable_add_opts() has only a single user left, which is a test
case. Rewrite the test to use user_creatable_add_type() instead (which
is the remaining function that doesn't require a QAPI schema) and drop
the QemuOpts related functions.

Signed-off-by: Kevin Wolf 
---
 include/qom/object_interfaces.h | 59 
 qom/object_interfaces.c | 81 -
 tests/check-qom-proplist.c  | 42 -
 3 files changed, 20 insertions(+), 162 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index fb32330901..ac6c33ceac 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -99,51 +99,6 @@ Object *user_creatable_add_type(const char *type, const char 
*id,
  */
 void user_creatable_add_qapi(ObjectOptions *options, Error **errp);
 
-/**
- * user_creatable_add_opts:
- * @opts: the object definition
- * @errp: if an error occurs, a pointer to an area to store the error
- *
- * Create an instance of the user creatable object whose type
- * is defined in @opts by the 'qom-type' option, placing it
- * in the object composition tree with name provided by the
- * 'id' field. The remaining options in @opts are used to
- * initialize the object properties.
- *
- * Returns: the newly created object or NULL on error
- */
-Object *user_creatable_add_opts(QemuOpts *opts, Error **errp);
-
-
-/**
- * user_creatable_add_opts_predicate:
- * @type: the QOM type to be added
- *
- * A callback function to determine whether an object
- * of type @type should be created. Instances of this
- * callback should be passed to user_creatable_add_opts_foreach
- */
-typedef bool (*user_creatable_add_opts_predicate)(const char *type);
-
-/**
- * user_creatable_add_opts_foreach:
- * @opaque: a user_creatable_add_opts_predicate callback or NULL
- * @opts: options to create
- * @errp: unused
- *
- * An iterator callback to be used in conjunction with
- * the qemu_opts_foreach() method for creating a list of
- * objects from a set of QemuOpts
- *
- * The @opaque parameter can be passed a user_creatable_add_opts_predicate
- * callback to filter which types of object are created during iteration.
- * When it fails, report the error.
- *
- * Returns: 0 on success, -1 when an error was reported.
- */
-int user_creatable_add_opts_foreach(void *opaque,
-QemuOpts *opts, Error **errp);
-
 /**
  * user_creatable_parse_str:
  * @optarg: the object definition string as passed on the command line
@@ -190,20 +145,6 @@ bool user_creatable_add_from_str(const char *optarg, Error 
**errp);
  */
 void user_creatable_process_cmdline(const char *optarg);
 
-/**
- * user_creatable_print_help:
- * @type: the QOM type to be added
- * @opts: options to create
- *
- * Prints help if requested in @type or @opts. Note that if @type is neither
- * "help"/"?" nor a valid user creatable type, no help will be printed
- * regardless of @opts.
- *
- * Returns: true if a help option was found and help was printed, false
- * otherwise.
- */
-bool user_creatable_print_help(const char *type, QemuOpts *opts);
-
 /**
  * user_creatable_del:
  * @id: the unique ID for the object
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 1c29f45b41..25cc54fcd7 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -10,12 +10,9 @@
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qom/object_interfaces.h"
-#include "qemu/help_option.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include "qemu/qemu-print.h"
-#include "qapi/opts-visitor.h"
-#include "qemu/config-file.h"
 
 bool user_creatable_complete(UserCreatable *uc, Error **errp)
 {
@@ -131,60 +128,6 @@ void user_creatable_add_qapi(ObjectOptions *options, Error 
**errp)
 visit_free(v);
 }
 
-Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
-{
-Visitor *v;
-QDict *pdict;
-Object *obj;
-const char *id = qemu_opts_id(opts);
-char *type = qemu_opt_get_del(opts, "qom-type");
-
-if (!type) {
-error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
-return NULL;
-}
-if (!id) {
-error_setg(errp, QERR_MISSING_PARAMETER, "id");
-qemu_opt_set(opts, "qom-type", type, &error_abort);
-g_free(type);
-return NULL;
-}
-
-qemu_opts_set_id(opts, NULL);
-pdict = qemu_opts_to_qdict(opts, NULL);
-
-v = opts_visitor_new(opts);
-obj = user_creatable_add_type(type, id, pdict, v, errp);
-visit_free(v);
-
-qemu_opts_set_id(opts, (char *) id);
-qemu_opt_set(opts, "qom-type", type, &error_abort);
-g_free(type);
-qobject_unref(pdict);
-return obj;
-}
-
-
-int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
-{
-bool (*type_opt_predicate)(const char *, QemuOpts *) = opaque;
-Object *obj = NULL;
-const char *type;
-
-type = qemu_opt_get(opt

[PATCH v2 20/31] qom: Make "object" QemuOptsList optional

2021-02-24 Thread Kevin Wolf
This code is going away anyway, but for a few more commits, we'll be in
a state where some binaries still use QemuOpts and others don't. If the
"object" QemuOptsList doesn't even exist, we don't have to remove (or
fail to remove, and therefore abort) a user creatable object from it.

Signed-off-by: Kevin Wolf 
---
 qom/object_interfaces.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 1e9ad6f08a..b9a99c8bf4 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -290,6 +290,7 @@ void user_creatable_print_help_from_qdict(QDict *args)
 
 bool user_creatable_del(const char *id, Error **errp)
 {
+QemuOptsList *opts_list;
 Object *container;
 Object *obj;
 
@@ -309,8 +310,10 @@ bool user_creatable_del(const char *id, Error **errp)
  * if object was defined on the command-line, remove its corresponding
  * option group entry
  */
-qemu_opts_del(qemu_opts_find(qemu_find_opts_err("object", &error_abort),
- id));
+opts_list = qemu_find_opts_err("object", NULL);
+if (opts_list) {
+qemu_opts_del(qemu_opts_find(opts_list, id));
+}
 
 object_unparent(obj);
 return true;
-- 
2.29.2




[PATCH v2 26/31] qemu-nbd: Use user_creatable_process_cmdline() for --object

2021-02-24 Thread Kevin Wolf
This switches qemu-nbd from a QemuOpts-based parser for --object to
user_creatable_process_cmdline() which uses a keyval parser and enforces
the QAPI schema.

Apart from being a cleanup, this makes non-scalar properties accessible.

Signed-off-by: Kevin Wolf 
---
 qemu-nbd.c | 34 +++---
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index b1b9430a8f..93ef4e288f 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -401,24 +401,6 @@ static QemuOptsList file_opts = {
 },
 };
 
-static QemuOptsList qemu_object_opts = {
-.name = "object",
-.implied_opt_name = "qom-type",
-.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
-.desc = {
-{ }
-},
-};
-
-static bool qemu_nbd_object_print_help(const char *type, QemuOpts *opts)
-{
-if (user_creatable_print_help(type, opts)) {
-exit(0);
-}
-return true;
-}
-
-
 static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list,
   Error **errp)
 {
@@ -594,7 +576,6 @@ int main(int argc, char **argv)
 qcrypto_init(&error_fatal);
 
 module_call_init(MODULE_INIT_QOM);
-qemu_add_opts(&qemu_object_opts);
 qemu_add_opts(&qemu_trace_opts);
 qemu_init_exec_dir(argv[0]);
 
@@ -747,14 +728,9 @@ int main(int argc, char **argv)
 case '?':
 error_report("Try `%s --help' for more information.", argv[0]);
 exit(EXIT_FAILURE);
-case QEMU_NBD_OPT_OBJECT: {
-QemuOpts *opts;
-opts = qemu_opts_parse_noisily(&qemu_object_opts,
-   optarg, true);
-if (!opts) {
-exit(EXIT_FAILURE);
-}
-}   break;
+case QEMU_NBD_OPT_OBJECT:
+user_creatable_process_cmdline(optarg);
+break;
 case QEMU_NBD_OPT_TLSCREDS:
 tlscredsid = optarg;
 break;
@@ -802,10 +778,6 @@ int main(int argc, char **argv)
 export_name = "";
 }
 
-qemu_opts_foreach(&qemu_object_opts,
-  user_creatable_add_opts_foreach,
-  qemu_nbd_object_print_help, &error_fatal);
-
 if (!trace_init_backends()) {
 exit(1);
 }
-- 
2.29.2




[PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add

2021-02-24 Thread Kevin Wolf
The option has been deprecated in QEMU 5.0, remove it.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json|  6 +-
 docs/system/deprecated.rst   |  5 -
 docs/system/removed-features.rst |  5 +
 qom/qom-qmp-cmds.c   | 21 -
 4 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 0b0b92944b..96c91c1faf 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -211,10 +211,6 @@
 #
 # @id: the name of the new object
 #
-# @props: a dictionary of properties to be passed to the backend. Deprecated
-# since 5.0, specify the properties on the top level instead. It is an
-# error to specify the same option both on the top level and in @props.
-#
 # Additional arguments depend on qom-type and are passed to the backend
 # unchanged.
 #
@@ -232,7 +228,7 @@
 #
 ##
 { 'command': 'object-add',
-  'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'},
+  'data': {'qom-type': 'str', 'id': 'str'},
   'gen': false } # so we can get the additional arguments
 
 ##
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 2fcac7861e..00b694e053 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -199,11 +199,6 @@ Use ``migrate-set-parameters`` and 
``query-migrate-parameters`` instead.
 
 Use arguments ``base-node`` and ``top-node`` instead.
 
-``object-add`` option ``props`` (since 5.0)
-'''
-
-Specify the properties for the object as top-level arguments instead.
-
 ``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].status 
(since 4.0)
 
''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index c8481cafbd..95f3fb2912 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -58,6 +58,11 @@ documentation of ``query-hotpluggable-cpus`` for additional 
details.
 
 Use ``blockdev-change-medium`` or ``change-vnc-password`` instead.
 
+``object-add`` option ``props`` (removed in 6.0)
+
+
+Specify the properties for the object as top-level arguments instead.
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index b40ac39f30..19fd5e117f 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -225,27 +225,6 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char 
*typename,
 
 void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp)
 {
-QObject *props;
-QDict *pdict;
-
-props = qdict_get(qdict, "props");
-if (props) {
-pdict = qobject_to(QDict, props);
-if (!pdict) {
-error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
-return;
-}
-qobject_ref(pdict);
-qdict_del(qdict, "props");
-qdict_join(qdict, pdict, false);
-if (qdict_size(pdict) != 0) {
-error_setg(errp, "Option in 'props' conflicts with top level");
-qobject_unref(pdict);
-return;
-}
-qobject_unref(pdict);
-}
-
 user_creatable_add_dict(qdict, false, errp);
 }
 
-- 
2.29.2




[PATCH v2 19/31] qapi/qom: QAPIfy object-add

2021-02-24 Thread Kevin Wolf
This converts object-add from 'gen': false to the ObjectOptions QAPI
type. As an immediate benefit, clients can now use QAPI schema
introspection for user creatable QOM objects.

It is also the first step towards making the QAPI schema the only
external interface for the creation of user creatable objects. Once all
other places (HMP and command lines of the system emulator and all
tools) go through QAPI, too, some object implementations can be
simplified because some checks (e.g. that mandatory options are set) are
already performed by QAPI, and in another step, QOM boilerplate code
could be generated from the schema.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json| 11 +--
 include/qom/object_interfaces.h  |  7 ---
 hw/block/xen-block.c | 16 
 monitor/misc.c   |  2 --
 qom/qom-qmp-cmds.c   | 25 +++--
 storage-daemon/qemu-storage-daemon.c |  2 --
 6 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 6793342e81..e5b219df58 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -839,13 +839,6 @@
 #
 # Create a QOM object.
 #
-# @qom-type: the class name for the object to be created
-#
-# @id: the name of the new object
-#
-# Additional arguments depend on qom-type and are passed to the backend
-# unchanged.
-#
 # Returns: Nothing on success
 #  Error if @qom-type is not a valid class name
 #
@@ -859,9 +852,7 @@
 # <- { "return": {} }
 #
 ##
-{ 'command': 'object-add',
-  'data': {'qom-type': 'str', 'id': 'str'},
-  'gen': false } # so we can get the additional arguments
+{ 'command': 'object-add', 'data': 'ObjectOptions', 'boxed': true }
 
 ##
 # @object-del:
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 07d5cc8832..9b9938b8c0 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -196,11 +196,4 @@ bool user_creatable_del(const char *id, Error **errp);
  */
 void user_creatable_cleanup(void);
 
-/**
- * qmp_object_add:
- *
- * QMP command handler for object-add. See the QAPI schema for documentation.
- */
-void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp);
-
 #endif
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index a3b69e2709..ac82d54063 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -836,17 +836,17 @@ static XenBlockIOThread *xen_block_iothread_create(const 
char *id,
 {
 ERRP_GUARD();
 XenBlockIOThread *iothread = g_new(XenBlockIOThread, 1);
-QDict *opts;
-QObject *ret_data = NULL;
+ObjectOptions *opts;
 
 iothread->id = g_strdup(id);
 
-opts = qdict_new();
-qdict_put_str(opts, "qom-type", TYPE_IOTHREAD);
-qdict_put_str(opts, "id", id);
-qmp_object_add(opts, &ret_data, errp);
-qobject_unref(opts);
-qobject_unref(ret_data);
+opts = g_new(ObjectOptions, 1);
+*opts = (ObjectOptions) {
+.qom_type = OBJECT_TYPE_IOTHREAD,
+.id = g_strdup(id),
+};
+qmp_object_add(opts, errp);
+qapi_free_ObjectOptions(opts);
 
 if (*errp) {
 g_free(iothread->id);
diff --git a/monitor/misc.c b/monitor/misc.c
index a7650ed747..42efd9e2ab 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -235,8 +235,6 @@ static void monitor_init_qmp_commands(void)
  qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG);
 qmp_register_command(&qmp_commands, "device_add", qmp_device_add,
  QCO_NO_OPTIONS);
-qmp_register_command(&qmp_commands, "object-add", qmp_object_add,
- QCO_NO_OPTIONS);
 
 QTAILQ_INIT(&qmp_cap_negotiation_commands);
 qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 19fd5e117f..e577a96adf 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -19,8 +19,11 @@
 #include "qapi/error.h"
 #include "qapi/qapi-commands-qdev.h"
 #include "qapi/qapi-commands-qom.h"
+#include "qapi/qapi-visit-qom.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qerror.h"
+#include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
 #include "qemu/cutils.h"
 #include "qom/object_interfaces.h"
 #include "qom/qom-qobject.h"
@@ -223,9 +226,27 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char 
*typename,
 return prop_list;
 }
 
-void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp)
+void qmp_object_add(ObjectOptions *options, Error **errp)
 {
-user_creatable_add_dict(qdict, false, errp);
+Visitor *v;
+QObject *qobj;
+QDict *props;
+Object *obj;
+
+v = qobject_output_visitor_new(&qobj);
+visit_type_ObjectOptions(v, NULL, &options, &error_abort);
+visit_complete(v, &qobj);
+visit_free(v);
+
+props = qobject_to(QDict, qobj);
+qdict_del(props, "qom-type");
+qdict_del(props, "id");
+
+v = qobject_input_visitor_new(QOB

[PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-*

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the memory-backend-*
objects.

HostMemPolicy has to be moved to an include file that can be used by the
storage daemon, too, because ObjectOptions must be the same in all
binaries if we don't want to compile the whole code multiple times.

Signed-off-by: Kevin Wolf 
---
 qapi/common.json  |  20 
 qapi/machine.json |  22 +
 qapi/qom.json | 118 +-
 3 files changed, 138 insertions(+), 22 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 716712d4b3..2dad4fadc3 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -145,3 +145,23 @@
 ##
 { 'enum': 'PCIELinkWidth',
   'data': [ '1', '2', '4', '8', '12', '16', '32' ] }
+
+##
+# @HostMemPolicy:
+#
+# Host memory policy types
+#
+# @default: restore default policy, remove any nondefault policy
+#
+# @preferred: set the preferred host nodes for allocation
+#
+# @bind: a strict policy that restricts memory allocation to the
+#host nodes specified
+#
+# @interleave: memory allocations are interleaved across the set
+#  of host nodes specified
+#
+# Since: 2.1
+##
+{ 'enum': 'HostMemPolicy',
+  'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
diff --git a/qapi/machine.json b/qapi/machine.json
index 330189efe3..4322aee782 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -8,6 +8,8 @@
 # = Machines
 ##
 
+{ 'include': 'common.json' }
+
 ##
 # @SysEmuTarget:
 #
@@ -897,26 +899,6 @@
'policy': 'HmatCacheWritePolicy',
'line': 'uint16' }}
 
-##
-# @HostMemPolicy:
-#
-# Host memory policy types
-#
-# @default: restore default policy, remove any nondefault policy
-#
-# @preferred: set the preferred host nodes for allocation
-#
-# @bind: a strict policy that restricts memory allocation to the
-#host nodes specified
-#
-# @interleave: memory allocations are interleaved across the set
-#  of host nodes specified
-#
-# Since: 2.1
-##
-{ 'enum': 'HostMemPolicy',
-  'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
-
 ##
 # @memsave:
 #
diff --git a/qapi/qom.json b/qapi/qom.json
index a6a5049707..1a869006a1 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -5,6 +5,7 @@
 # See the COPYING file in the top-level directory.
 
 { 'include': 'authz.json' }
+{ 'include': 'common.json' }
 
 ##
 # = QEMU Object Model (QOM)
@@ -272,6 +273,113 @@
 '*poll-grow': 'int',
 '*poll-shrink': 'int' } }
 
+##
+# @MemoryBackendProperties:
+#
+# Properties for objects of classes derived from memory-backend.
+#
+# @merge: if true, mark the memory as mergeable (default depends on the machine
+# type)
+#
+# @dump: if true, include the memory in core dumps (default depends on the
+#machine type)
+#
+# @host-nodes: the list of NUMA host nodes to bind the memory to
+#
+# @policy: the NUMA policy (default: 'default')
+#
+# @prealloc: if true, preallocate memory (default: false)
+#
+# @prealloc-threads: number of CPU threads to use for prealloc (default: 1)
+#
+# @share: if false, the memory is private to QEMU; if true, it is shared
+# (default: false)
+#
+# @size: size of the memory region in bytes
+#
+# @x-use-canonical-path-for-ramblock-id: if true, the canoncial path is used
+#for ramblock-id. Disable this for 4.0
+#machine types or older to allow
+#migration with newer QEMU versions.
+#(default: false generally, but true
+#for machine types <= 4.0)
+#
+# Since: 2.1
+##
+{ 'struct': 'MemoryBackendProperties',
+  'data': { '*dump': 'bool',
+'*host-nodes': ['uint16'],
+'*merge': 'bool',
+'*policy': 'HostMemPolicy',
+'*prealloc': 'bool',
+'*prealloc-threads': 'uint32',
+'*share': 'bool',
+'size': 'size',
+'*x-use-canonical-path-for-ramblock-id': 'bool' } }
+
+##
+# @MemoryBackendFileProperties:
+#
+# Properties for memory-backend-file objects.
+#
+# @align: the base address alignment when QEMU mmap(2) @mem-path. Some
+# backend store specified by @mem-path requires an alignment different
+# than the default one used by QEMU, e.g. the device DAX /dev/dax0.0
+# requires 2M alignment rather than 4K. In such cases, users can
+# specify the required alignment via this option.
+# 0 selects a default alignment (currently the page size). (default: 0)
+#
+# @discard-data: if true, the file contents can be destroyed when QEMU exits,
+#to avoid unnecessarily flushing data to the backing file. Note
+#that ``discard-data`` is only an optimization, and QEMU might
+#not discard file contents if it aborts unexpectedly or is
+#terminated using SIGKILL. (default: false)
+#
+# @mem-path: th

[PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the objects implementing
the confidential-guest-support interface.

pef-guest and s390x-pv-guest don't have any properties, so they only
need to be added to the ObjectType enum without adding a new branch to
ObjectOptions.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 37 +
 1 file changed, 37 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index e7184122e9..d5f68b5c89 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -633,6 +633,38 @@
   'base': 'RngProperties',
   'data': { '*filename': 'str' } }
 
+##
+# @SevGuestProperties:
+#
+# Properties for sev-guest objects.
+#
+# @sev-device: SEV device to use (default: "/dev/sev")
+#
+# @dh-cert-file: guest owners DH certificate (encoded with base64)
+#
+# @session-file: guest owners session parameters (encoded with base64)
+#
+# @policy: SEV policy value (default: 0x1)
+#
+# @handle: SEV firmware handle (default: 0)
+#
+# @cbitpos: C-bit location in page table entry (default: 0)
+#
+# @reduced-phys-bits: number of bits in physical addresses that become
+# unavailable when SEV is enabled
+#
+# Since: 2.12
+##
+{ 'struct': 'SevGuestProperties',
+  'data': { '*sev-device': 'str',
+'*dh-cert-file': 'str',
+'*session-file': 'str',
+'*policy': 'uint32',
+'*handle': 'uint32',
+'*cbitpos': 'uint32',
+'reduced-phys-bits': 'uint32' },
+  'if': 'defined(CONFIG_SEV)' }
+
 ##
 # @ObjectType:
 #
@@ -661,12 +693,15 @@
 'memory-backend-file',
 'memory-backend-memfd',
 'memory-backend-ram',
+{'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' },
 'pr-manager-helper',
 'rng-builtin',
 'rng-egd',
 'rng-random',
 'secret',
 'secret_keyring',
+{'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' },
+'s390-pv-guest',
 'throttle-group',
 'tls-creds-anon',
 'tls-creds-psk',
@@ -716,6 +751,8 @@
   'rng-random': 'RngRandomProperties',
   'secret': 'SecretProperties',
   'secret_keyring': 'SecretKeyringProperties',
+  'sev-guest':  { 'type': 'SevGuestProperties',
+  'if': 'defined(CONFIG_SEV)' },
   'throttle-group': 'ThrottleGroupProperties',
   'tls-creds-anon': 'TlsCredsAnonProperties',
   'tls-creds-psk':  'TlsCredsPskProperties',
-- 
2.29.2




[PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the rng-* objects.

The 'opened' property doesn't seem to make sense as an external
interface: It is automatically set to true in ucc->complete, and
explicitly setting it to true earlier just means that trying to set
additional options will result in an error. After the property has once
been set to true (i.e. when the object construction has completed), it
can never be reset to false. In other words, the 'opened' property is
useless. Mark it as deprecated in the schema from the start.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json  | 56 --
 docs/system/deprecated.rst |  9 ++
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 1a869006a1..73f28f9608 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -380,6 +380,52 @@
 '*hugetlbsize': 'size',
 '*seal': 'bool' } }
 
+##
+# @RngProperties:
+#
+# Properties for objects of classes derived from rng.
+#
+# @opened: if true, the device is opened immediately when applying this option
+#  and will probably fail when processing the next option. Don't use;
+#  only provided for compatibility. (default: false)
+#
+# Features:
+# @deprecated: Member @opened is deprecated.  Setting true doesn't make sense,
+#  and false is already the default.
+#
+# Since: 1.3
+##
+{ 'struct': 'RngProperties',
+  'data': { '*opened': { 'type': 'bool', 'features': ['deprecated'] } } }
+
+##
+# @RngEgdProperties:
+#
+# Properties for rng-egd objects.
+#
+# @chardev: the name of a character device backend that provides the connection
+#   to the RNG daemon
+#
+# Since: 1.3
+##
+{ 'struct': 'RngEgdProperties',
+  'base': 'RngProperties',
+  'data': { 'chardev': 'str' } }
+
+##
+# @RngRandomProperties:
+#
+# Properties for rng-random objects.
+#
+# @filename: the filename of the device on the host to obtain entropy from
+#(default: "/dev/urandom")
+#
+# Since: 1.3
+##
+{ 'struct': 'RngRandomProperties',
+  'base': 'RngProperties',
+  'data': { '*filename': 'str' } }
+
 ##
 # @ObjectType:
 #
@@ -398,7 +444,10 @@
 'iothread',
 'memory-backend-file',
 'memory-backend-memfd',
-'memory-backend-ram'
+'memory-backend-ram',
+'rng-builtin',
+'rng-egd',
+'rng-random'
   ] }
 
 ##
@@ -428,7 +477,10 @@
   'iothread':   'IothreadProperties',
   'memory-backend-file':'MemoryBackendFileProperties',
   'memory-backend-memfd':   'MemoryBackendMemfdProperties',
-  'memory-backend-ram': 'MemoryBackendProperties'
+  'memory-backend-ram': 'MemoryBackendProperties',
+  'rng-builtin':'RngProperties',
+  'rng-egd':'RngEgdProperties',
+  'rng-random': 'RngRandomProperties'
   } }
 
 ##
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 00b694e053..79991c2893 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -146,6 +146,15 @@ library enabled as a cryptography provider.
 Neither the ``nettle`` library, or the built-in cryptography provider are
 supported on FIPS enabled hosts.
 
+``opened`` property of ``rng-*`` objects (since 6.0.0)
+''
+
+The only effect of specifying ``opened=on`` in the command line or QMP
+``object-add`` is that the device is opened immediately, possibly before all
+other options have been processed.  This will either have no effect (if
+``opened`` was the last option) or cause errors.  The property is therefore
+useless and should not be specified.
+
 QEMU Machine Protocol (QMP) commands
 
 
-- 
2.29.2




[PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread

2021-02-24 Thread Kevin Wolf
Add an ObjectOptions union that will eventually describe the options of
all user creatable object types. As unions can't exist without any
branches, also add the first object type.

This adds a QAPI schema for the properties of the iothread object.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 53 +++
 1 file changed, 53 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 96c91c1faf..bf2ecb34be 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -202,6 +202,59 @@
   'returns': [ 'ObjectPropertyInfo' ],
   'allow-preconfig': true }
 
+##
+# @IothreadProperties:
+#
+# Properties for iothread objects.
+#
+# @poll-max-ns: the maximum number of nanoseconds to busy wait for events.
+#   0 means polling is disabled (default: 32768 on POSIX hosts,
+#   0 otherwise)
+#
+# @poll-grow: the multiplier used to increase the polling time when the
+# algorithm detects it is missing events due to not polling long
+# enough. 0 selects a default behaviour (default: 0)
+#
+# @poll-shrink: the divisor used to decrease the polling time when the
+#   algorithm detects it is spending too long polling without
+#   encountering events. 0 selects a default behaviour (default: 0)
+#
+# Since: 2.0
+##
+{ 'struct': 'IothreadProperties',
+  'data': { '*poll-max-ns': 'int',
+'*poll-grow': 'int',
+'*poll-shrink': 'int' } }
+
+##
+# @ObjectType:
+#
+# Since: 6.0
+##
+{ 'enum': 'ObjectType',
+  'data': [
+'iothread'
+  ] }
+
+##
+# @ObjectOptions:
+#
+# Describes the options of a user creatable QOM object.
+#
+# @qom-type: the class name for the object to be created
+#
+# @id: the name of the new object
+#
+# Since: 6.0
+##
+{ 'union': 'ObjectOptions',
+  'base': { 'qom-type': 'ObjectType',
+'id': 'str' },
+  'discriminator': 'qom-type',
+  'data': {
+  'iothread':   'IothreadProperties'
+  } }
+
 ##
 # @object-add:
 #
-- 
2.29.2




[PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the x-remote-object
object.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index f8ff322df0..6793342e81 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -641,6 +641,20 @@
 { 'struct': 'PrManagerHelperProperties',
   'data': { 'path': 'str' } }
 
+##
+# @RemoteObjectProperties:
+#
+# Properties for x-remote-object objects.
+#
+# @fd: file descriptor name previously passed via 'getfd' command
+#
+# @devid: the id of the device to be associated with the file descriptor
+#
+# Since: 6.0
+##
+{ 'struct': 'RemoteObjectProperties',
+  'data': { 'fd': 'str', 'devid': 'str' } }
+
 ##
 # @RngProperties:
 #
@@ -762,7 +776,8 @@
 'tls-creds-anon',
 'tls-creds-psk',
 'tls-creds-x509',
-'tls-cipher-suites'
+'tls-cipher-suites',
+'x-remote-object'
   ] }
 
 ##
@@ -815,7 +830,8 @@
   'tls-creds-anon': 'TlsCredsAnonProperties',
   'tls-creds-psk':  'TlsCredsPskProperties',
   'tls-creds-x509': 'TlsCredsX509Properties',
-  'tls-cipher-suites':  'TlsCredsProperties'
+  'tls-cipher-suites':  'TlsCredsProperties',
+  'x-remote-object':'RemoteObjectProperties'
   } }
 
 ##
-- 
2.29.2




[PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-*

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the input-* objects.

ui.json cannot be included in qom.json because the storage daemon can't
use it, so move GrabToggleKeys to common.json.

Signed-off-by: Kevin Wolf 
---
 qapi/common.json | 12 ++
 qapi/qom.json| 58 
 qapi/ui.json | 13 +--
 3 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index b87e7f9039..7c976296f0 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -185,3 +185,15 @@
 ##
 { 'enum': 'NetFilterDirection',
   'data': [ 'all', 'rx', 'tx' ] }
+
+##
+# @GrabToggleKeys:
+#
+# Keys to toggle input-linux between host and guest.
+#
+# Since: 4.0
+#
+##
+{ 'enum': 'GrabToggleKeys',
+  'data': [ 'ctrl-ctrl', 'alt-alt', 'shift-shift','meta-meta', 'scrolllock',
+'ctrl-scrolllock' ] }
diff --git a/qapi/qom.json b/qapi/qom.json
index d5f68b5c89..f8ff322df0 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -444,6 +444,60 @@
   'base': 'NetfilterProperties',
   'data': { '*vnet_hdr_support': 'bool' } }
 
+##
+# @InputBarrierProperties:
+#
+# Properties for input-barrier objects.
+#
+# @name: the screen name as declared in the screens section of barrier.conf
+#
+# @server: hostname of the Barrier server (default: "localhost")
+#
+# @port: TCP port of the Barrier server (default: "24800")
+#
+# @x-origin: x coordinate of the leftmost pixel on the guest screen
+#(default: "0")
+#
+# @y-origin: y coordinate of he topmost pixel on the guest screen (default: 
"0")
+#
+# @width: the width of secondary screen in pixels (default: "1920")
+#
+# @height: the height of secondary screen in pixels (default: "1080")
+#
+# Since: 4.2
+##
+{ 'struct': 'InputBarrierProperties',
+  'data': { 'name': 'str',
+'*server': 'str',
+'*port': 'str',
+'*x-origin': 'str',
+'*y-origin': 'str',
+'*width': 'str',
+'*height': 'str' } }
+
+##
+# @InputLinuxProperties:
+#
+# Properties for input-linux objects.
+#
+# @evdev: the path of the host evdev device to use
+#
+# @grab_all: if true, grab is toggled for all devices (e.g. both keyboard and
+#mouse) instead of just one device (default: false)
+#
+# @repeat: enables auto-repeat events (default: false)
+#
+# @grab-toggle: the key or key combination that toggles device grab
+#   (default: ctrl-ctrl)
+#
+# Since: 2.6
+##
+{ 'struct': 'InputLinuxProperties',
+  'data': { 'evdev': 'str',
+'*grab_all': 'bool',
+'*repeat': 'bool',
+'*grab-toggle': 'GrabToggleKeys' } }
+
 ##
 # @IothreadProperties:
 #
@@ -689,6 +743,8 @@
 'filter-redirector',
 'filter-replay',
 'filter-rewriter',
+'input-barrier',
+'input-linux',
 'iothread',
 'memory-backend-file',
 'memory-backend-memfd',
@@ -741,6 +797,8 @@
   'filter-redirector':  'FilterRedirectorProperties',
   'filter-replay':  'NetfilterProperties',
   'filter-rewriter':'FilterRewriterProperties',
+  'input-barrier':  'InputBarrierProperties',
+  'input-linux':'InputLinuxProperties',
   'iothread':   'IothreadProperties',
   'memory-backend-file':'MemoryBackendFileProperties',
   'memory-backend-memfd':   'MemoryBackendMemfdProperties',
diff --git a/qapi/ui.json b/qapi/ui.json
index d08d72b439..cc1882108b 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -6,6 +6,7 @@
 # = Remote desktop
 ##
 
+{ 'include': 'common.json' }
 { 'include': 'sockets.json' }
 
 ##
@@ -1021,18 +1022,6 @@
 '*head'  : 'int',
 'events' : [ 'InputEvent' ] } }
 
-##
-# @GrabToggleKeys:
-#
-# Keys to toggle input-linux between host and guest.
-#
-# Since: 4.0
-#
-##
-{ 'enum': 'GrabToggleKeys',
-  'data': [ 'ctrl-ctrl', 'alt-alt', 'shift-shift','meta-meta', 'scrolllock',
-'ctrl-scrolllock' ] }
-
 ##
 # @DisplayGTK:
 #
-- 
2.29.2




[PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the secret* objects.

The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true in ucc->complete, and
explicitly setting it to true earlier just means that additional options
will be silently ignored.

In other words, the 'loaded' property is useless. Mark it as deprecated
in the schema from the start.

Signed-off-by: Kevin Wolf 
---
 qapi/crypto.json   | 61 ++
 qapi/qom.json  |  5 
 docs/system/deprecated.rst | 11 +++
 3 files changed, 77 insertions(+)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 2aebe6fa20..0fef3de66d 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -381,3 +381,64 @@
   'discriminator': 'format',
   'data': {
   'luks': 'QCryptoBlockAmendOptionsLUKS' } }
+
+##
+# @SecretCommonProperties:
+#
+# Properties for objects of classes derived from secret-common.
+#
+# @loaded: if true, the secret is loaded immediately when applying this option
+#  and will probably fail when processing the next option. Don't use;
+#  only provided for compatibility. (default: false)
+#
+# @format: the data format that the secret is provided in (default: raw)
+#
+# @keyid: the name of another secret that should be used to decrypt the
+# provided data. If not present, the data is assumed to be unencrypted.
+#
+# @iv: the random initialization vector used for encryption of this particular
+#  secret. Should be a base64 encrypted string of the 16-byte IV. Mandatory
+#  if @keyid is given. Ignored if @keyid is absent.
+#
+# Features:
+# @deprecated: Member @loaded is deprecated.  Setting true doesn't make sense,
+#  and false is already the default.
+#
+# Since: 2.6
+##
+{ 'struct': 'SecretCommonProperties',
+  'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] },
+'*format': 'QCryptoSecretFormat',
+'*keyid': 'str',
+'*iv': 'str' } }
+
+##
+# @SecretProperties:
+#
+# Properties for secret objects.
+#
+# Either @data or @file must be provided, but not both.
+#
+# @data: the associated with the secret from
+#
+# @file: the filename to load the data associated with the secret from
+#
+# Since: 2.6
+##
+{ 'struct': 'SecretProperties',
+  'base': 'SecretCommonProperties',
+  'data': { '*data': 'str',
+'*file': 'str' } }
+
+##
+# @SecretKeyringProperties:
+#
+# Properties for secret_keyring objects.
+#
+# @serial: serial number that identifies a key to get from the kernel
+#
+# Since: 5.1
+##
+{ 'struct': 'SecretKeyringProperties',
+  'base': 'SecretCommonProperties',
+  'data': { 'serial': 'int32' } }
diff --git a/qapi/qom.json b/qapi/qom.json
index 449dca8ec5..2668ad8369 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -7,6 +7,7 @@
 { 'include': 'authz.json' }
 { 'include': 'block-core.json' }
 { 'include': 'common.json' }
+{ 'include': 'crypto.json' }
 
 ##
 # = QEMU Object Model (QOM)
@@ -449,6 +450,8 @@
 'rng-builtin',
 'rng-egd',
 'rng-random',
+'secret',
+'secret_keyring',
 'throttle-group'
   ] }
 
@@ -483,6 +486,8 @@
   'rng-builtin':'RngProperties',
   'rng-egd':'RngEgdProperties',
   'rng-random': 'RngRandomProperties',
+  'secret': 'SecretProperties',
+  'secret_keyring': 'SecretKeyringProperties',
   'throttle-group': 'ThrottleGroupProperties'
   } }
 
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 79991c2893..78b175cb59 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -155,6 +155,17 @@ other options have been processed.  This will either have 
no effect (if
 ``opened`` was the last option) or cause errors.  The property is therefore
 useless and should not be specified.
 
+``loaded`` property of ``secret`` and ``secret_keyring`` objects (since 6.0.0)
+''
+
+The only effect of specifying ``loaded=on`` in the command line or QMP
+``object-add`` is that the secret is loaded immediately, possibly before all
+other options have been processed.  This will either have no effect (if
+``loaded`` was the last option) or cause options to be effectively ignored as
+if they were not given.  The property is therefore useless and should not be
+specified.
+
+
 QEMU Machine Protocol (QMP) commands
 
 
-- 
2.29.2




[PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-*

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the cryptodev-* objects.

These interfaces have some questionable aspects (cryptodev-backend is
really an abstract base class without function, and the queues option
only makes sense for cryptodev-vhost-user), but as the goal is to
represent the existing interface in QAPI, leave these things in place.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 30ed179bc1..1dbc95fb53 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -204,6 +204,34 @@
   'returns': [ 'ObjectPropertyInfo' ],
   'allow-preconfig': true }
 
+##
+# @CryptodevBackendProperties:
+#
+# Properties for cryptodev-backend and cryptodev-backend-builtin objects.
+#
+# @queues: the number of queues for the cryptodev backend. Ignored for
+#  cryptodev-backend and must be 1 for cryptodev-backend-builtin.
+#  (default: 1)
+#
+# Since: 2.8
+##
+{ 'struct': 'CryptodevBackendProperties',
+  'data': { '*queues': 'uint32' } }
+
+##
+# @CryptodevVhostUserProperties:
+#
+# Properties for cryptodev-vhost-user objects.
+#
+# @chardev: the name of a unix domain socket character device that connects to
+#   the vhost-user server
+#
+# Since: 2.12
+##
+{ 'struct': 'CryptodevVhostUserProperties',
+  'base': 'CryptodevBackendProperties',
+  'data': { 'chardev': 'str' } }
+
 ##
 # @IothreadProperties:
 #
@@ -239,6 +267,9 @@
 'authz-listfile',
 'authz-pam',
 'authz-simple',
+'cryptodev-backend',
+'cryptodev-backend-builtin',
+'cryptodev-vhost-user',
 'iothread'
   ] }
 
@@ -262,6 +293,9 @@
   'authz-listfile': 'AuthZListFileProperties',
   'authz-pam':  'AuthZPAMProperties',
   'authz-simple':   'AuthZSimpleProperties',
+  'cryptodev-backend':  'CryptodevBackendProperties',
+  'cryptodev-backend-builtin':  'CryptodevBackendProperties',
+  'cryptodev-vhost-user':   'CryptodevVhostUserProperties',
   'iothread':   'IothreadProperties'
   } }
 
-- 
2.29.2




[PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-*

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the filter-* objects.

Some parts of the interface (in particular NetfilterProperties.position)
are very unusual for QAPI, but for now just describe the existing
interface.

net.json can't be included in qom.json because the storage daemon
doesn't have it. NetFilterDirection is still required in the new object
property definitions in qom.json, so move this enum to common.json.

Signed-off-by: Kevin Wolf 
---
 qapi/common.json |  20 +++
 qapi/net.json|  20 ---
 qapi/qom.json| 143 +++
 3 files changed, 163 insertions(+), 20 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 2dad4fadc3..b87e7f9039 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -165,3 +165,23 @@
 ##
 { 'enum': 'HostMemPolicy',
   'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
+
+##
+# @NetFilterDirection:
+#
+# Indicates whether a netfilter is attached to a netdev's transmit queue or
+# receive queue or both.
+#
+# @all: the filter is attached both to the receive and the transmit
+#   queue of the netdev (default).
+#
+# @rx: the filter is attached to the receive queue of the netdev,
+#  where it will receive packets sent to the netdev.
+#
+# @tx: the filter is attached to the transmit queue of the netdev,
+#  where it will receive packets sent by the netdev.
+#
+# Since: 2.5
+##
+{ 'enum': 'NetFilterDirection',
+  'data': [ 'all', 'rx', 'tx' ] }
diff --git a/qapi/net.json b/qapi/net.json
index c31748c87f..af3f5b0fda 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -492,26 +492,6 @@
 'vhost-user': 'NetdevVhostUserOptions',
 'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
 
-##
-# @NetFilterDirection:
-#
-# Indicates whether a netfilter is attached to a netdev's transmit queue or
-# receive queue or both.
-#
-# @all: the filter is attached both to the receive and the transmit
-#   queue of the netdev (default).
-#
-# @rx: the filter is attached to the receive queue of the netdev,
-#  where it will receive packets sent to the netdev.
-#
-# @tx: the filter is attached to the transmit queue of the netdev,
-#  where it will receive packets sent by the netdev.
-#
-# Since: 2.5
-##
-{ 'enum': 'NetFilterDirection',
-  'data': [ 'all', 'rx', 'tx' ] }
-
 ##
 # @RxState:
 #
diff --git a/qapi/qom.json b/qapi/qom.json
index 8e4414f843..e3357f5123 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -313,6 +313,137 @@
   'data': { 'addr': 'str' ,
 '*id-list': 'str' } }
 
+##
+# @NetfilterInsert:
+#
+# Indicates where to insert a netfilter relative to a given other filter.
+#
+# @before: insert before the specified filter
+#
+# @behind: insert behind the specified filter
+#
+# Since: 5.0
+##
+{ 'enum': 'NetfilterInsert',
+  'data': [ 'before', 'behind' ] }
+
+##
+# @NetfilterProperties:
+#
+# Properties for objects of classes derived from netfilter.
+#
+# @netdev: id of the network device backend to filter
+#
+# @queue: indicates which queue(s) to filter (default: all)
+#
+# @status: indicates whether the filter is enabled ("on") or disabled ("off")
+#  (default: "on")
+#
+# @position: specifies where the filter should be inserted in the filter list.
+#"head" means the filter is inserted at the head of the filter 
list,
+#before any existing filters.
+#"tail" means the filter is inserted at the tail of the filter 
list,
+#behind any existing filters (default).
+#"id=" means the filter is inserted before or behind the filter
+#specified by , depending on the @insert property.
+#(default: "tail")
+#
+# @insert: where to insert the filter relative to the filter given in 
@position.
+#  Ignored if @position is "head" or "tail". (default: behind)
+#
+# Since: 2.5
+##
+{ 'struct': 'NetfilterProperties',
+  'data': { 'netdev': 'str',
+'*queue': 'NetFilterDirection',
+'*status': 'str',
+'*position': 'str',
+'*insert': 'NetfilterInsert' } }
+
+##
+# @FilterBufferProperties:
+#
+# Properties for filter-buffer objects.
+#
+# @interval: a non-zero interval in microseconds.  All packets arriving in the
+#given interval are delayed until the end of the interval.
+#
+# Since: 2.5
+##
+{ 'struct': 'FilterBufferProperties',
+  'base': 'NetfilterProperties',
+  'data': { 'interval': 'uint32' } }
+
+##
+# @FilterDumpProperties:
+#
+# Properties for filter-dump objects.
+#
+# @file: the filename where the dumped packets should be stored
+#
+# @maxlen: maximum number of bytes in a packet that are stored (default: 65536)
+#
+# Since: 2.5
+##
+{ 'struct': 'FilterDumpProperties',
+  'base': 'NetfilterProperties',
+  'data': { 'file': 'str',
+'*maxlen': 'uint32' } }
+
+##
+# @FilterMirrorProperties:
+#
+# Properties for filter-mirror objects.
+#
+# @outdev: the name of a character device backend to which all incoming packets
+#

[PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the can-* objects.

can-bus doesn't have any properties, so it only needs to be added to the
ObjectType enum without adding a new branch to ObjectOptions.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index f22b7aa99b..4b1cd4b8dc 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -207,6 +207,21 @@
   'returns': [ 'ObjectPropertyInfo' ],
   'allow-preconfig': true }
 
+##
+# @CanHostSocketcanProperties:
+#
+# Properties for can-host-socketcan objects.
+#
+# @if: interface name of the host system CAN bus to connect to
+#
+# @canbus: object ID of the can-bus object to connect to the host interface
+#
+# Since: 2.12
+##
+{ 'struct': 'CanHostSocketcanProperties',
+  'data': { 'if': 'str',
+'canbus': 'str' } }
+
 ##
 # @CryptodevBackendProperties:
 #
@@ -439,6 +454,8 @@
 'authz-listfile',
 'authz-pam',
 'authz-simple',
+'can-bus',
+'can-host-socketcan',
 'cryptodev-backend',
 'cryptodev-backend-builtin',
 'cryptodev-vhost-user',
@@ -479,6 +496,7 @@
   'authz-listfile': 'AuthZListFileProperties',
   'authz-pam':  'AuthZPAMProperties',
   'authz-simple':   'AuthZSimpleProperties',
+  'can-host-socketcan': 'CanHostSocketcanProperties',
   'cryptodev-backend':  'CryptodevBackendProperties',
   'cryptodev-backend-builtin':  'CryptodevBackendProperties',
   'cryptodev-vhost-user':   'CryptodevVhostUserProperties',
-- 
2.29.2




[PATCH v2 01/31] tests: Drop 'props' from object-add calls

2021-02-24 Thread Kevin Wolf
The 'props' option has been deprecated in 5.0 in favour of a flattened
object-add command. Time to change our test cases to drop the deprecated
option.

Signed-off-by: Kevin Wolf 
---
 tests/qtest/qmp-cmd-test.c   | 16 +--
 tests/qtest/test-netfilter.c | 54 
 tests/qemu-iotests/087   |  8 ++
 tests/qemu-iotests/184   | 18 
 tests/qemu-iotests/218   |  2 +-
 tests/qemu-iotests/235   |  2 +-
 tests/qemu-iotests/245   |  4 +--
 tests/qemu-iotests/258   |  6 ++--
 tests/qemu-iotests/258.out   |  4 +--
 tests/qemu-iotests/295   |  2 +-
 tests/qemu-iotests/296   |  2 +-
 11 files changed, 51 insertions(+), 67 deletions(-)

diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index 1c7186e53c..c98b78d033 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -230,14 +230,14 @@ static void test_object_add_failure_modes(void)
 /* attempt to create 2 objects with duplicate id */
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'size': 1048576 } } }");
+ " 'size': 1048576 } }");
 g_assert_nonnull(resp);
 g_assert(qdict_haskey(resp, "return"));
 qobject_unref(resp);
 
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'size': 1048576 } } }");
+ " 'size': 1048576 } }");
 g_assert_nonnull(resp);
 qmp_expect_error_and_unref(resp, "GenericError");
 
@@ -251,14 +251,14 @@ static void test_object_add_failure_modes(void)
 /* attempt to create an object with a property of a wrong type */
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'size': '1048576' } } }");
+ " 'size': '1048576' } }");
 g_assert_nonnull(resp);
 /* now do it right */
 qmp_expect_error_and_unref(resp, "GenericError");
 
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'size': 1048576 } } }");
+ " 'size': 1048576 } }");
 g_assert_nonnull(resp);
 g_assert(qdict_haskey(resp, "return"));
 qobject_unref(resp);
@@ -273,14 +273,14 @@ static void test_object_add_failure_modes(void)
 /* attempt to create an object without the id */
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram',"
- " 'props': {'size': 1048576 } } }");
+ " 'size': 1048576 } }");
 g_assert_nonnull(resp);
 qmp_expect_error_and_unref(resp, "GenericError");
 
 /* now do it right */
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'size': 1048576 } } }");
+ " 'size': 1048576 } }");
 g_assert_nonnull(resp);
 g_assert(qdict_haskey(resp, "return"));
 qobject_unref(resp);
@@ -295,14 +295,14 @@ static void test_object_add_failure_modes(void)
 /* attempt to set a non existing property */
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'sized': 1048576 } } }");
+ " 'sized': 1048576 } }");
 g_assert_nonnull(resp);
 qmp_expect_error_and_unref(resp, "GenericError");
 
 /* now do it right */
 resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
  " {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
- " 'props': {'size': 1048576 } } }");
+ " 'size': 1048576 } }");
 g_assert_nonnull(resp);
 g_assert(qdict_haskey(resp, "return"));
 qobject_unref(resp);
diff --git a/tests/qtest/test-netfilter.c b/tests/qtest/test-netfilter.c
index 22927ee6ab..785b6f3226 100644
--- a/tests/qtest/test-netfilter.c
+++ b/tests/qtest/test-netfilter.c
@@ -21,11 +21,10 @@ static void add_one_netfilter(void)
" 'arguments': {"
"   'qom-type': 'filter-buffer',"
"   'id': 'qtest-f0',"
-   "   'props': {"
-   " 'netdev': 'qtest-bn0',"
-   " 'queue': 'rx',"
-   " 'interval': 1000"
-   "}}}");
+   "   'netdev': 'qtest-bn0',"
+   "   'queue': 'rx',"
+   "   'interval': 1000"
+   "}}");
 
 g_assert(response);
 g_assert(!qdict_haskey(response, "err

Re: [PATCH v2 4/4] utils: Deprecate inexact fractional suffix sizes

2021-02-24 Thread Eric Blake
On 2/23/21 11:20 AM, Daniel P. Berrangé wrote:
> On Thu, Feb 11, 2021 at 02:44:38PM -0600, Eric Blake wrote:
>> The value '1.1k' is inexact; 1126.4 bytes is not possible, so we
>> happen to truncate it to 1126.  Our use of fractional sizes is
>> intended for convenience, but when a user specifies a fraction that is
>> not a clean translation to binary, truncating/rounding behind their
>> backs can cause confusion.  Better is to deprecate inexact values,
>> which still leaves '1.5k' as valid, but alerts the user to spell out
>> their values as a precise byte number in cases where they are
>> currently being rounded.
>>
>> Note that values like '0.1G' in the testsuite need adjustment as a
>> result.
>>
>> Since qemu_strtosz() does not have an Err** parameter, and plumbing
>> that in would be a much larger task, we instead go with just directly
>> emitting the deprecation warning to stderr.
>>
>> Signed-off-by: Eric Blake 
>>
>> ---
>>
>> I'm not a fan of this patch, but am proposing it for discussion purposes.
> 
> Likewise. I'm *not* in favour of this patch.

Glad we're in agreement.  Consider this one dropped, and I will queue
1-3 through my NBD tree.

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




[PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add

2021-02-24 Thread Kevin Wolf
This series adds a QAPI type for the properties of all user creatable
QOM types and finally makes the --object command line option (in all
binaries) and the object-add monitor commands (in QMP and HMP) use the
new ObjectOptions union.

This change improves things in more than just one way:

1. Documentation for QOM object types has always been lacking. Adding
   the schema, we get documentation for every property.

2. It prevents bugs by performing parts of the input validation (e.g.
   checking presence of mandatory properties) already in QAPI instead of
   relying on separate manual implementations in each class.

3. It provides QAPI introspection for user creatable objects.

4. Non-scalar properties are now supported everywhere because the
   command line parsers (including HMP) use the keyval parser now.


If you are in the CC list and didn't expect this series, it's probably
because you're the maintainer of one of the objects for which I'm adding
a QAPI schema description. Please just have a look at the specific patch
for your object and check whether the schema and its documentation make
sense to you. You can ignore all other patches.


In a next step after this series, we can add make use of the QAPI
structs in the implementation of the object and separate their
configuration from the runtime state. Specifically, the plan is to
add a .configure() callback to ObjectClass that allows configuring the
object in one place at creation time and keeping QOM property setters
only for properties that can actually be changed at runtime. Paolo made
an example of what the state could look like after this:

https://wiki.qemu.org/Features/QOM-QAPI_integration

Finally, the intention is to extend the QAPI schema to have separate
'object' entities and generate some of the code that was written
manually in the intermediate state before.


This series is available as a git tag at:

https://repo.or.cz/qemu/kevin.git qapi-object-v2


v2:
- Convert not only object-add, but all external interfaces so that the
  schema will always be enforced and mismatch between implementation and
  schema can't go unnoticed.
- Rebased, covering properties and object types added since v1 (yes,
  things do become outdated rather quickly when you touch all user
  creatable objects)
- Changed the "Since:" version number in the schema documentation to
  refer to the version when the object was introduced rather than 6.0
  where the schema will (hopefully) be added
- Probably some other minor changes

Kevin Wolf (31):
  tests: Drop 'props' from object-add calls
  qapi/qom: Drop deprecated 'props' from object-add
  qapi/qom: Add ObjectOptions for iothread
  qapi/qom: Add ObjectOptions for authz-*
  qapi/qom: Add ObjectOptions for cryptodev-*
  qapi/qom: Add ObjectOptions for dbus-vmstate
  qapi/qom: Add ObjectOptions for memory-backend-*
  qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'
  qapi/qom: Add ObjectOptions for throttle-group
  qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
  qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
  qapi/qom: Add ObjectOptions for can-*
  qapi/qom: Add ObjectOptions for colo-compare
  qapi/qom: Add ObjectOptions for filter-*
  qapi/qom: Add ObjectOptions for pr-manager-helper
  qapi/qom: Add ObjectOptions for confidential-guest-support
  qapi/qom: Add ObjectOptions for input-*
  qapi/qom: Add ObjectOptions for x-remote-object
  qapi/qom: QAPIfy object-add
  qom: Make "object" QemuOptsList optional
  qemu-storage-daemon: Implement --object with qmp_object_add()
  qom: Remove user_creatable_add_dict()
  qom: Factor out user_creatable_process_cmdline()
  qemu-io: Use user_creatable_process_cmdline() for --object
  qemu-img: Use user_creatable_process_cmdline() for --object
  qemu-nbd: Use user_creatable_process_cmdline() for --object
  qom: Add user_creatable_add_from_str()
  hmp: QAPIfy object_add
  qom: Add user_creatable_parse_str()
  vl: QAPIfy -object
  qom: Drop QemuOpts based interfaces

 qapi/authz.json  |  62 +++
 qapi/block-core.json |  27 ++
 qapi/common.json |  52 +++
 qapi/crypto.json | 159 +++
 qapi/machine.json|  22 +-
 qapi/net.json|  20 -
 qapi/qom.json| 639 ++-
 qapi/ui.json |  13 +-
 docs/system/deprecated.rst   |  25 +-
 docs/system/removed-features.rst |   5 +
 include/qom/object_interfaces.h  | 106 ++---
 hw/block/xen-block.c |  16 +-
 monitor/hmp-cmds.c   |  17 +-
 monitor/misc.c   |   2 -
 qemu-img.c   | 239 ++
 qemu-io.c|  33 +-
 qemu-nbd.c   |  34 +-
 qom/object_interfaces.c  | 168 +++
 qom/qom-qmp-cmds.c   |  28 +-
 softmmu/vl.c | 109 +++--
 storage-

[PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate

2021-02-24 Thread Kevin Wolf
This adds a QAPI schema for the properties of the dbus-vmstate object.

A list represented as a comma separated string is clearly not very
QAPI-like, but for now just describe the existing interface.

Signed-off-by: Kevin Wolf 
---
 qapi/qom.json | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 1dbc95fb53..a6a5049707 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -232,6 +232,22 @@
   'base': 'CryptodevBackendProperties',
   'data': { 'chardev': 'str' } }
 
+##
+# @DBusVMStateProperties:
+#
+# Properties for dbus-vmstate objects.
+#
+# @addr: the name of the DBus bus to connect to
+#
+# @id-list: a comma separated list of DBus IDs of helpers whose data should be
+#   included in the VM state on migration
+#
+# Since: 5.0
+##
+{ 'struct': 'DBusVMStateProperties',
+  'data': { 'addr': 'str' ,
+'*id-list': 'str' } }
+
 ##
 # @IothreadProperties:
 #
@@ -270,6 +286,7 @@
 'cryptodev-backend',
 'cryptodev-backend-builtin',
 'cryptodev-vhost-user',
+'dbus-vmstate',
 'iothread'
   ] }
 
@@ -296,6 +313,7 @@
   'cryptodev-backend':  'CryptodevBackendProperties',
   'cryptodev-backend-builtin':  'CryptodevBackendProperties',
   'cryptodev-vhost-user':   'CryptodevVhostUserProperties',
+  'dbus-vmstate':   'DBusVMStateProperties',
   'iothread':   'IothreadProperties'
   } }
 
-- 
2.29.2




Re: [PATCH 04/14] softmmu: remove '-usbdevice' command line option

2021-02-24 Thread Daniel P . Berrangé
On Wed, Feb 24, 2021 at 02:25:46PM +0100, Paolo Bonzini wrote:
> On 24/02/21 14:11, Daniel P. Berrangé wrote:
> > This was replaced by the '-device usb-DEV' option.
> > 
> > Signed-off-by: Daniel P. Berrangé 
> 
> This is probably used in many tutorial as "-usbdevice tablet" (for example
> https://wiki.gentoo.org/wiki/QEMU/Options).

It has been deprecated, printing a warning message, for almost 4 years
now, and had your ack originally :-)

  commit a358a3af4558a24398a541951cad7a6c458df72b
  Author: Thomas Huth 
  Date:   Fri May 19 08:35:16 2017 +0200

usb: Deprecate the legacy -usbdevice option

The '-usbdevice' option is considered as deprecated nowadays and
we might want to remove these options in a future version of QEMU.
So mark this options as deprecated in the documenation and print out
a warning if it is used to tell the user what to use instead.
While we're at it, improve also some other minor USB-related spots
in qemu-options.hx that were not up to date anymore.

Signed-off-by: Thomas Huth 
Reviewed-by: Paolo Bonzini 
Message-id: 1495175716-12735-1-git-send-email-th...@redhat.com
Signed-off-by: Gerd Hoffmann 


There's some tradeoff to be had.  The 3rd party docs will be unlikely
to be updated to the new syntax as long as the old syntax still works.
So we get ourselves into a chicken & egg scenario.

Overall the -usbdevice doesn't add significant syntax sugar benefits
over -device, as compared benefits of other syntax sugar args we
have.

> > ---
> >   docs/system/deprecated.rst   |  9 ---
> >   docs/system/removed-features.rst |  9 +++
> >   softmmu/vl.c | 42 
> >   3 files changed, 9 insertions(+), 51 deletions(-)

It seems this is incomplete though, I missed qemu-options.hx,
docs/qdev-device-use.txt and hw/usb/bus.c updates to remove
associated cruft.


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 :|




Re: [PATCH 03/14] monitor: remove 'query-events' QMP command

2021-02-24 Thread Thomas Huth

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

The code comment suggests removing QAPIEvent_(str|lookup) symbols too,
however, these are both auto-generated as standard for any enum in
QAPI. As such it they'll exist whether we use them or not.

Signed-off-by: Daniel P. Berrangé 
---
  docs/system/deprecated.rst   |  6 -
  docs/system/removed-features.rst |  6 +
  monitor/qmp-cmds-control.c   | 24 -
  qapi/control.json| 45 
  4 files changed, 6 insertions(+), 75 deletions(-)


Reviewed-by: Thomas Huth 




Re: [PATCH 01/14] ui, monitor: remove deprecated VNC ACL option and HMP commands

2021-02-24 Thread Daniel P . Berrangé
On Wed, Feb 24, 2021 at 02:36:46PM +0100, Thomas Huth wrote:
> On 24/02/2021 14.11, Daniel P. Berrangé wrote:
> > The VNC ACL concept has been replaced by the pluggable "authz" framework
> > which does not use monitor commands.
> > 
> > Reviewed-by: Dr. David Alan Gilbert 
> > Signed-off-by: Daniel P. Berrangé 
> > ---
> >   docs/system/deprecated.rst   |  16 ---
> >   docs/system/removed-features.rst |  13 +++
> >   hmp-commands.hx  |  76 -
> >   monitor/misc.c   | 187 ---
> >   ui/vnc.c |  38 ---
> >   5 files changed, 13 insertions(+), 317 deletions(-)
> 
> If I run:
> 
>  grep -r vnc.*acl *
> 
> I also see some lines in tests/check-block-qdict.c ... are they related and
> should be removed, too?

Yes & no.  This test is using the vnc ACL syntax as example input for
validating the qdict parsing, but isn't functionally connected to the
actual VNC ACL impl.

> Apart from that, patch looks fine to me:
> Reviewed-by: Thomas Huth 

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 :|




Re: [PATCH 00/14] deprecations: remove many old deprecations

2021-02-24 Thread Peter Maydell
On Wed, 24 Feb 2021 at 13:21, Daniel P. Berrangé  wrote:
>
> The following features have been deprecated for well over the 2
> release cycle we promise
>
>   ``-usbdevice`` (since 2.10.0)
>   ``-drive file=3Djson:{...{'driver':'file'}}`` (since 3.0)
>   ``-vnc acl`` (since 4.0.0)
>   ``-mon ...,control=3Dreadline,pretty=3Don|off`` (since 4.1)

Are the literal '=3D' here intended ?


thanks
-- PMM



Re: [PATCH 01/14] ui, monitor: remove deprecated VNC ACL option and HMP commands

2021-02-24 Thread Thomas Huth

On 24/02/2021 14.11, Daniel P. Berrangé wrote:

The VNC ACL concept has been replaced by the pluggable "authz" framework
which does not use monitor commands.

Reviewed-by: Dr. David Alan Gilbert 
Signed-off-by: Daniel P. Berrangé 
---
  docs/system/deprecated.rst   |  16 ---
  docs/system/removed-features.rst |  13 +++
  hmp-commands.hx  |  76 -
  monitor/misc.c   | 187 ---
  ui/vnc.c |  38 ---
  5 files changed, 13 insertions(+), 317 deletions(-)


If I run:

 grep -r vnc.*acl *

I also see some lines in tests/check-block-qdict.c ... are they related and 
should be removed, too?


Apart from that, patch looks fine to me:
Reviewed-by: Thomas Huth 




Re: [PATCH v2 01/22] block: add eMMC block device type

2021-02-24 Thread Cédric Le Goater
On 2/24/21 12:40 PM, Stefan Hajnoczi wrote:
> On Tue, Feb 23, 2021 at 05:35:20PM +, Sai Pavan Boddu wrote:
>> Hi Philippe,
>>
>>> -Original Message-
>>> From: Philippe Mathieu-Daudé 
>>> Sent: Monday, February 22, 2021 5:34 PM
>>> To: Sai Pavan Boddu ; Markus Armbruster
>>> ; Kevin Wolf ; Max Reitz
>>> ; Vladimir Sementsov-Ogievskiy
>>> ; Eric Blake ; Joel Stanley
>>> ; Cédric Le Goater ; Vincent Palatin
>>> ; Dr. David Alan Gilbert ;
>>> Thomas Huth ; Stefan Hajnoczi ;
>>> Peter Maydell ; Alistair Francis
>>> ; Edgar Iglesias ; Luc Michel
>>> ; Paolo Bonzini 
>>> Cc: Sai Pavan Boddu ; qemu-de...@nongnu.org; qemu-
>>> bl...@nongnu.org
>>> Subject: Re: [PATCH v2 01/22] block: add eMMC block device type
>>>
>>> On 2/22/21 9:20 AM, Sai Pavan Boddu wrote:
 From: Vincent Palatin 

 Add new block device type.

 Signed-off-by: Vincent Palatin 
 [SPB: Rebased over 5.1 version]
 Signed-off-by: Sai Pavan Boddu 
 Signed-off-by: Joel Stanley 
 Signed-off-by: Cédric Le Goater 
 Reviewed-by: Alistair Francis 
 ---
  include/sysemu/blockdev.h | 1 +
  blockdev.c| 1 +
  2 files changed, 2 insertions(+)

 diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
 index 3b5fcda..eefae9f 100644
 --- a/include/sysemu/blockdev.h
 +++ b/include/sysemu/blockdev.h
 @@ -24,6 +24,7 @@ typedef enum {
   */
  IF_NONE = 0,
  IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO,
 IF_XEN,
 +IF_EMMC,
  IF_COUNT
  } BlockInterfaceType;

 diff --git a/blockdev.c b/blockdev.c
 index cd438e6..390d43c 100644
 --- a/blockdev.c
 +++ b/blockdev.c
 @@ -83,6 +83,7 @@ static const char *const if_name[IF_COUNT] = {
  [IF_SD] = "sd",
  [IF_VIRTIO] = "virtio",
  [IF_XEN] = "xen",
 +[IF_EMMC] = "emmc",
  };
>>>
>>> We don't need to introduce support for the legacy -drive magic.
>>>
>>> -device should be enough for this device, right?
>> [Sai Pavan Boddu] I was seeing to use -device for emmc. But I see we anyway 
>> need blockdev support for this, which would require us the use -drive.
>>
>> Can you give some pointers, how to approach this ?
> 
> It is probably not necessary to add a new IF_ constant. Would this work:
> 
>   -drive if=none,id=emmc0,file=test.img,format=raw
>   -device emmc,...,drive=emmc0
> 
> Or the more modern:
> 
>   -blockdev node-name=emmc0,driver=file,filename=test.img
>   -device emmc,...,drive=emmc0
> 
> ?
> 
> (The syntax might need small tweaks but is shows the general idea.)

Yes. This is better. 

We could have an "emmc" device inheriting from "sd-card". The "emmc" 
property would not be necessary anymore and may be, we could cleanup 
up some parts doing : 

if (sd->emmc) { /* eMMC */
...
} else {

}

with SDCardClass handlers. the SWITCH_FUNCTION command is a good 
candidate, CMD8 also.

C.



Re: [PATCH 00/14] deprecations: remove many old deprecations

2021-02-24 Thread Paolo Bonzini

On 24/02/21 14:11, Daniel P. Berrangé wrote:

The following features have been deprecated for well over the 2
release cycle we promise

   ``-usbdevice`` (since 2.10.0)
   ``-drive file=3Djson:{...{'driver':'file'}}`` (since 3.0)
   ``-vnc acl`` (since 4.0.0)
   ``-mon ...,control=3Dreadline,pretty=3Don|off`` (since 4.1)
   ``migrate_set_downtime`` and ``migrate_set_speed`` (since 2.8.0)
   ``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)
   ``query-block`` result ``inserted.encryption_key_missing`` (since 2.10.0)
   ``migrate-set-cache-size`` and ``query-migrate-cache-size`` (since 2.11.0)
   ``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].sta=
tus (ince 4.0)
   ``query-cpus`` (since 2.12.0)
   ``query-cpus-fast`` ``arch`` output member (since 3.0.0)
   ``query-events`` (since 4.0)
   chardev client socket with ``wait`` option (since 4.0)
   ``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` (s=
ince 4.0.0)
   ``ide-drive`` (since 4.2)
   ``scsi-disk`` (since 4.2)

AFAICT, libvirt has ceased to use all of these too.


No objections except possibly for -usbdevice.

Paolo




Re: [PATCH 04/14] softmmu: remove '-usbdevice' command line option

2021-02-24 Thread Paolo Bonzini

On 24/02/21 14:11, Daniel P. Berrangé wrote:

This was replaced by the '-device usb-DEV' option.

Signed-off-by: Daniel P. Berrangé 


This is probably used in many tutorial as "-usbdevice tablet" (for 
example https://wiki.gentoo.org/wiki/QEMU/Options).


Paolo


---
  docs/system/deprecated.rst   |  9 ---
  docs/system/removed-features.rst |  9 +++
  softmmu/vl.c | 42 
  3 files changed, 9 insertions(+), 51 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 611adf60f7..c577cc97c4 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -21,15 +21,6 @@ deprecated.
  System emulator command line arguments
  --
  
-``-usbdevice`` (since 2.10.0)

-'
-
-The ``-usbdevice DEV`` argument is now a synonym for setting
-the ``-device usb-DEV`` argument instead. The deprecated syntax
-would automatically enable USB support on the machine type.
-If using the new syntax, USB support must be explicitly
-enabled via the ``-machine usb=on`` argument.
-
  ``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
  '''
  
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst

index dc63581fe5..74d022babf 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -50,6 +50,15 @@ by the ``tls-authz`` and ``sasl-authz`` options.
  The ``pretty=on|off`` switch has no effect for HMP monitors and
  its use is rejected.
  
+``-usbdevice`` (removed in 6.0)

+'''
+
+The ``-usbdevice DEV`` argument was now a synonym for setting
+the ``-device usb-DEV`` argument instead. The removed syntax
+would automatically enable USB support on the machine type.
+When using the new syntax, USB support must be explicitly
+enabled via the ``-machine usb=on`` argument.
+
  QEMU Machine Protocol (QMP) commands
  
  
diff --git a/softmmu/vl.c b/softmmu/vl.c

index b219ce1f35..c31061cc09 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -743,34 +743,6 @@ static void configure_msg(QemuOpts *opts)
  }
  
  
-/***/

-/* USB devices */
-
-static int usb_device_add(const char *devname)
-{
-USBDevice *dev = NULL;
-
-if (!machine_usb(current_machine)) {
-return -1;
-}
-
-dev = usbdevice_create(devname);
-if (!dev)
-return -1;
-
-return 0;
-}
-
-static int usb_parse(const char *cmdline)
-{
-int r;
-r = usb_device_add(cmdline);
-if (r < 0) {
-error_report("could not add USB device '%s'", cmdline);
-}
-return r;
-}
-
  /***/
  /* machine registration */
  
@@ -1267,7 +1239,6 @@ static void monitor_parse(const char *optarg, const char *mode, bool pretty)
  
  struct device_config {

  enum {
-DEV_USB,   /* -usbdevice */
  DEV_SERIAL,/* -serial*/
  DEV_PARALLEL,  /* -parallel  */
  DEV_DEBUGCON,  /* -debugcon */
@@ -2484,12 +2455,6 @@ static void qemu_create_cli_devices(void)
  qemu_opts_foreach(qemu_find_opts("fw_cfg"),
parse_fw_cfg, fw_cfg_find(), &error_fatal);
  
-/* init USB devices */

-if (machine_usb(current_machine)) {
-if (foreach_device_config(DEV_USB, usb_parse) < 0)
-exit(1);
-}
-
  /* init generic devices */
  rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
  qemu_opts_foreach(qemu_find_opts("device"),
@@ -3182,13 +3147,6 @@ void qemu_init(int argc, char **argv, char **envp)
  olist = qemu_find_opts("machine");
  qemu_opts_parse_noisily(olist, "usb=on", false);
  break;
-case QEMU_OPTION_usbdevice:
-error_report("'-usbdevice' is deprecated, please use "
- "'-device usb-...' instead");
-olist = qemu_find_opts("machine");
-qemu_opts_parse_noisily(olist, "usb=on", false);
-add_device_config(DEV_USB, optarg);
-break;
  case QEMU_OPTION_device:
  if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
   optarg, true)) {






Re: [PATCH 02/14] monitor: raise error when 'pretty' option is used with HMP

2021-02-24 Thread Dr. David Alan Gilbert
* Daniel P. Berrangé (berra...@redhat.com) wrote:
> This is only semantically useful for QMP.
> 
> Signed-off-by: Daniel P. Berrangé 

Reviewed-by: Dr. David Alan Gilbert 

> ---
>  docs/system/deprecated.rst   | 7 ---
>  docs/system/removed-features.rst | 6 ++
>  monitor/monitor.c| 4 ++--
>  qemu-options.hx  | 5 +++--
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index 786b997fe7..dfd8a8c497 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -62,13 +62,6 @@ needs two devices (``-device intel-hda -device 
> hda-duplex``) and
>  ``pcspk`` which can be activated using ``-machine
>  pcspk-audiodev=``.
>  
> -``-mon ...,control=readline,pretty=on|off`` (since 4.1)
> -'''
> -
> -The ``pretty=on|off`` switch has no effect for HMP monitors, but is
> -silently ignored. Using the switch with HMP monitors will become an
> -error in the future.
> -
>  RISC-V ``-bios`` (since 5.1)
>  
>  
> diff --git a/docs/system/removed-features.rst 
> b/docs/system/removed-features.rst
> index 0424b9a89d..3ca13d2844 100644
> --- a/docs/system/removed-features.rst
> +++ b/docs/system/removed-features.rst
> @@ -44,6 +44,12 @@ block cache, ``-accel tcg,tb-size=``.
>  The ``acl`` option to the ``-vnc`` argument has been replaced
>  by the ``tls-authz`` and ``sasl-authz`` options.
>  
> +``-mon ...,control=readline,pretty=on|off`` (removed in 6.0)
> +
> +
> +The ``pretty=on|off`` switch has no effect for HMP monitors and
> +its use is rejected.
> +
>  QEMU Machine Protocol (QMP) commands
>  
>  
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index e94f532cf5..515efb015e 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -720,8 +720,8 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, 
> Error **errp)
>  return -1;
>  }
>  if (opts->pretty) {
> -warn_report("'pretty' is deprecated for HMP monitors, it has no "
> -"effect and will be removed in future versions");
> +error_setg(errp, "'pretty' is not compatible with HMP monitors");
> +return -1;
>  }
>  monitor_init_hmp(chr, true, &local_err);
>  break;
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 6c34c7050f..a934d5c787 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3702,8 +3702,9 @@ DEF("mon", HAS_ARG, QEMU_OPTION_mon, \
>  "-mon [chardev=]name[,mode=readline|control][,pretty[=on|off]]\n", 
> QEMU_ARCH_ALL)
>  SRST
>  ``-mon [chardev=]name[,mode=readline|control][,pretty[=on|off]]``
> -Setup monitor on chardev name. ``pretty`` turns on JSON pretty
> -printing easing human reading and debugging.
> +Setup monitor on chardev name. ``pretty`` is only valid when
> +``mode=control``, turning on JSON pretty printing to ease
> +human reading and debugging.
>  ERST
>  
>  DEF("debugcon", HAS_ARG, QEMU_OPTION_debugcon, \
> -- 
> 2.29.2
> 
-- 
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK




[PATCH 14/14] block: remove support for using "file" driver with block/char devices

2021-02-24 Thread Daniel P . Berrangé
The 'host_device' and 'host_cdrom' drivers must be used instead.

Signed-off-by: Daniel P. Berrangé 
---
 block/file-posix.c   | 17 ++---
 docs/system/deprecated.rst   |  7 ---
 docs/system/removed-features.rst |  7 +++
 tests/qemu-iotests/226.out   | 10 +-
 4 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 05079b40ca..20e14f8e96 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -719,15 +719,9 @@ static int raw_open_common(BlockDriverState *bs, QDict 
*options,
 }
 
 if (!device) {
-if (S_ISBLK(st.st_mode)) {
-warn_report("Opening a block device as a file using the '%s' "
-"driver is deprecated", bs->drv->format_name);
-} else if (S_ISCHR(st.st_mode)) {
-warn_report("Opening a character device as a file using the '%s' "
-"driver is deprecated", bs->drv->format_name);
-} else if (!S_ISREG(st.st_mode)) {
-error_setg(errp, "A regular file was expected by the '%s' driver, "
-   "but something else was given", bs->drv->format_name);
+if (!S_ISREG(st.st_mode)) {
+error_setg(errp, "'%s' driver requires '%s' to be a regular file",
+   bs->drv->format_name, bs->filename);
 ret = -EINVAL;
 goto fail;
 } else {
@@ -736,8 +730,9 @@ static int raw_open_common(BlockDriverState *bs, QDict 
*options,
 }
 } else {
 if (!(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
-error_setg(errp, "'%s' driver expects either "
-   "a character or block device", bs->drv->format_name);
+error_setg(errp, "'%s' driver requires '%s' to be either "
+   "a character or block device",
+   bs->drv->format_name, bs->filename);
 ret = -EINVAL;
 goto fail;
 }
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index dc76584e02..3a86deb450 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -21,13 +21,6 @@ deprecated.
 System emulator command line arguments
 --
 
-``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
-'''
-
-The 'file' driver for drives is no longer appropriate for character or host
-devices and will only accept regular files (S_IFREG). The correct driver
-for these file types is 'host_cdrom' or 'host_device' as appropriate.
-
 ``QEMU_AUDIO_`` environment variables and ``-audio-help`` (since 4.0)
 '
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 990bf7e015..1c9e384cb0 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -59,6 +59,13 @@ would automatically enable USB support on the machine type.
 When using the new syntax, USB support must be explicitly
 enabled via the ``-machine usb=on`` argument.
 
+``-drive file=json:{...{'driver':'file'}}`` (removed 6.0)
+'
+
+The 'file' driver for drives is no longer appropriate for character or host
+devices and will only accept regular files (S_IFREG). The correct driver
+for these file types is 'host_cdrom' or 'host_device' as appropriate.
+
 QEMU Machine Protocol (QMP) commands
 
 
diff --git a/tests/qemu-iotests/226.out b/tests/qemu-iotests/226.out
index 42be973ff2..55504d29c4 100644
--- a/tests/qemu-iotests/226.out
+++ b/tests/qemu-iotests/226.out
@@ -3,23 +3,23 @@ QA output created by 226
 === Testing with driver:file ===
 
 == Testing RO ==
-qemu-io: can't open: A regular file was expected by the 'file' driver, but 
something else was given
-qemu-io: warning: Opening a character device as a file using the 'file' driver 
is deprecated
+qemu-io: can't open: 'file' driver requires 'TEST_DIR/t.IMGFMT' to be a 
regular file
+qemu-io: can't open: 'file' driver requires '/dev/null' to be a regular file
 == Testing RW ==
 qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
-qemu-io: warning: Opening a character device as a file using the 'file' driver 
is deprecated
+qemu-io: can't open: 'file' driver requires '/dev/null' to be a regular file
 
 === Testing with driver:host_device ===
 
 == Testing RO ==
-qemu-io: can't open: 'host_device' driver expects either a character or block 
device
+qemu-io: can't open: 'host_device' driver requires 'TEST_DIR/t.IMGFMT' to be 
either a character or block device
 == Testing RW ==
 qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
 
 === Testing with driver:host_cdrom ===
 
 == Testing RO ==
-qemu-io: can't open: 'host_cdrom' driver expects either a character or block 
device
+qemu-io: can't open: '

Re: [PATCH 08/14] chardev: reject use of 'wait' flag for socket client chardevs

2021-02-24 Thread Marc-André Lureau
On Wed, Feb 24, 2021 at 5:15 PM Daniel P. Berrangé 
wrote:

> This only makes sense conceptually when used with listener chardevs.
>
> Signed-off-by: Daniel P. Berrangé 
>

Reviewed-by: Marc-André Lureau 

---
>  chardev/char-socket.c| 12 
>  docs/system/deprecated.rst   |  6 --
>  docs/system/removed-features.rst |  6 ++
>  3 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 9061981f6d..b24618b581 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -1336,14 +1336,10 @@ static bool
> qmp_chardev_validate_socket(ChardevSocket *sock,
>  return false;
>  }
>  if (sock->has_wait) {
> -warn_report("'wait' option is deprecated with "
> -"socket in client connect mode");
> -if (sock->wait) {
> -error_setg(errp, "%s",
> -   "'wait' option is incompatible with "
> -   "socket in client connect mode");
> -return false;
> -}
> +error_setg(errp, "%s",
> +   "'wait' option is incompatible with "
> +   "socket in client connect mode");
> +return false;
>  }
>  }
>
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index 78474f0845..c69887dca8 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -192,12 +192,6 @@ Since the ``dirty-bitmaps`` field is optionally
> present in both the old and
>  new locations, clients must use introspection to learn where to anticipate
>  the field if/when it does appear in command output.
>
> -chardev client socket with ``wait`` option (since 4.0)
> -''
> -
> -Character devices creating sockets in client mode should not specify
> -the 'wait' field, which is only applicable to sockets in server mode
> -
>  ``nbd-server-add`` and ``nbd-server-remove`` (since 5.2)
>  
>
> diff --git a/docs/system/removed-features.rst
> b/docs/system/removed-features.rst
> index 7942c2e513..870a222062 100644
> --- a/docs/system/removed-features.rst
> +++ b/docs/system/removed-features.rst
> @@ -106,6 +106,12 @@ The ``query-cpus`` command is replaced by the
> ``query-cpus-fast`` command.
>  The ``arch`` output member of the ``query-cpus-fast`` command is
>  replaced by the ``target`` output member.
>
> +chardev client socket with ``wait`` option (removed in 6.0)
> +'''
> +
> +Character devices creating sockets in client mode should not specify
> +the 'wait' field, which is only applicable to sockets in server mode
> +
>  Human Monitor Protocol (HMP) commands
>  -
>
> --
> 2.29.2
>
>


[PATCH 13/14] block: remove 'dirty-bitmaps' field from 'BlockInfo' struct

2021-02-24 Thread Daniel P . Berrangé
The same data is available in the 'BlockDeviceInfo' struct.

Signed-off-by: Daniel P. Berrangé 
---
 block/qapi.c |  5 -
 docs/system/deprecated.rst   | 13 -
 docs/system/removed-features.rst | 13 +
 qapi/block-core.json | 11 +--
 tests/qemu-iotests/194   |  4 ++--
 tests/qemu-iotests/236   |  2 +-
 tests/qemu-iotests/246   |  3 ++-
 tests/qemu-iotests/254   |  2 +-
 tests/qemu-iotests/260   |  5 +++--
 9 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index 3acc118c44..943e7b15ad 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -383,11 +383,6 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo 
**p_info,
 info->io_status = blk_iostatus(blk);
 }
 
-if (bs && !QLIST_EMPTY(&bs->dirty_bitmaps)) {
-info->has_dirty_bitmaps = true;
-info->dirty_bitmaps = bdrv_query_dirty_bitmaps(bs);
-}
-
 if (bs && bs->drv) {
 info->has_inserted = true;
 info->inserted = bdrv_block_device_info(blk, bs, false, errp);
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index a8ac104c19..dc76584e02 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -162,19 +162,6 @@ Use arguments ``base-node`` and ``top-node`` instead.
 
 Specify the properties for the object as top-level arguments instead.
 
-``query-block`` result field ``dirty-bitmaps`` (Since 4.2)
-''
-
-The ``dirty-bitmaps`` field of the ``BlockInfo`` structure, returned by
-the query-block command is itself now deprecated. The ``dirty-bitmaps``
-field of the ``BlockDeviceInfo`` struct should be used instead, which is the
-type of the ``inserted`` field in query-block replies, as well as the
-type of array items in query-named-block-nodes.
-
-Since the ``dirty-bitmaps`` field is optionally present in both the old and
-new locations, clients must use introspection to learn where to anticipate
-the field if/when it does appear in command output.
-
 ``nbd-server-add`` and ``nbd-server-remove`` (since 5.2)
 
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 725a316a4e..990bf7e015 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -129,6 +129,19 @@ The ``status`` field of the ``BlockDirtyInfo`` structure, 
returned by
 these commands is deprecated. Two new boolean fields, ``recording`` and
 ``busy`` effectively replace it.
 
+``query-block`` result field ``dirty-bitmaps`` (removed in 6.0)
+'''
+
+The ``dirty-bitmaps`` field of the ``BlockInfo`` structure, returned by
+the query-block command is itself now deprecated. The ``dirty-bitmaps``
+field of the ``BlockDeviceInfo`` struct should be used instead, which is the
+type of the ``inserted`` field in query-block replies, as well as the
+type of array items in query-named-block-nodes.
+
+Since the ``dirty-bitmaps`` field is optionally present in both the old and
+new locations, clients must use introspection to learn where to anticipate
+the field if/when it does appear in command output.
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 2a0c345c2c..0399449e13 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -539,9 +539,6 @@
 # @tray_open: True if the device's tray is open
 # (only present if it has a tray)
 #
-# @dirty-bitmaps: dirty bitmaps information (only present if the
-# driver has one or more dirty bitmaps) (Since 2.0)
-#
 # @io-status: @BlockDeviceIoStatus. Only present if the device
 # supports it and the VM is configured to stop on errors
 # (supported device models: virtio-blk, IDE, SCSI except
@@ -550,18 +547,12 @@
 # @inserted: @BlockDeviceInfo describing the device if media is
 #present
 #
-# Features:
-# @deprecated: Member @dirty-bitmaps is deprecated.  Use @inserted
-#  member @dirty-bitmaps instead.
-#
 # Since:  0.14
 ##
 { 'struct': 'BlockInfo',
   'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool',
'locked': 'bool', '*inserted': 'BlockDeviceInfo',
-   '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
-   '*dirty-bitmaps': { 'type': ['BlockDirtyInfo'],
-   'features': [ 'deprecated' ] } } }
+   '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus' } }
 
 ##
 # @BlockMeasureInfo:
diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194
index 3889266afa..e44b8df728 100755
--- a/tests/qemu-iotests/194
+++ b/tests/qemu-iotests/194
@@ -95,7 +95,7 @@ with iotests.FilePath('source.img') as source_img_path, \
 iotests.log(event, f

[PATCH 08/14] chardev: reject use of 'wait' flag for socket client chardevs

2021-02-24 Thread Daniel P . Berrangé
This only makes sense conceptually when used with listener chardevs.

Signed-off-by: Daniel P. Berrangé 
---
 chardev/char-socket.c| 12 
 docs/system/deprecated.rst   |  6 --
 docs/system/removed-features.rst |  6 ++
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 9061981f6d..b24618b581 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1336,14 +1336,10 @@ static bool qmp_chardev_validate_socket(ChardevSocket 
*sock,
 return false;
 }
 if (sock->has_wait) {
-warn_report("'wait' option is deprecated with "
-"socket in client connect mode");
-if (sock->wait) {
-error_setg(errp, "%s",
-   "'wait' option is incompatible with "
-   "socket in client connect mode");
-return false;
-}
+error_setg(errp, "%s",
+   "'wait' option is incompatible with "
+   "socket in client connect mode");
+return false;
 }
 }
 
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 78474f0845..c69887dca8 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -192,12 +192,6 @@ Since the ``dirty-bitmaps`` field is optionally present in 
both the old and
 new locations, clients must use introspection to learn where to anticipate
 the field if/when it does appear in command output.
 
-chardev client socket with ``wait`` option (since 4.0)
-''
-
-Character devices creating sockets in client mode should not specify
-the 'wait' field, which is only applicable to sockets in server mode
-
 ``nbd-server-add`` and ``nbd-server-remove`` (since 5.2)
 
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 7942c2e513..870a222062 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -106,6 +106,12 @@ The ``query-cpus`` command is replaced by the 
``query-cpus-fast`` command.
 The ``arch`` output member of the ``query-cpus-fast`` command is
 replaced by the ``target`` output member.
 
+chardev client socket with ``wait`` option (removed in 6.0)
+'''
+
+Character devices creating sockets in client mode should not specify
+the 'wait' field, which is only applicable to sockets in server mode
+
 Human Monitor Protocol (HMP) commands
 -
 
-- 
2.29.2




[PATCH 09/14] hw/ide: remove 'ide-drive' device

2021-02-24 Thread Daniel P . Berrangé
The 'ide-hd' and 'ide-cd' devices provide suitable alternatives.

Signed-off-by: Daniel P. Berrangé 
---
 docs/qdev-device-use.txt |  2 +-
 docs/system/deprecated.rst   |  6 -
 docs/system/removed-features.rst |  9 
 hw/i386/pc.c |  1 -
 hw/ide/qdev.c| 38 
 hw/ppc/mac_newworld.c| 13 ---
 hw/ppc/mac_oldworld.c| 13 ---
 hw/sparc64/sun4u.c   | 14 
 scripts/device-crash-test|  1 -
 softmmu/vl.c |  1 -
 tests/qemu-iotests/051   |  2 --
 tests/qemu-iotests/051.pc.out| 10 -
 12 files changed, 10 insertions(+), 100 deletions(-)

diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
index 245cdf29c7..2408889334 100644
--- a/docs/qdev-device-use.txt
+++ b/docs/qdev-device-use.txt
@@ -388,7 +388,7 @@ type.
 some DEVNAMEs:
 
 default device  suppressing DEVNAMEs
-CD-ROM  ide-cd, ide-drive, ide-hd, scsi-cd, scsi-hd
+CD-ROM  ide-cd, ide-hd, scsi-cd, scsi-hd
 floppy  floppy, isa-fdc
 parallelisa-parallel
 serial  isa-serial
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index c69887dca8..f5c82a46dc 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -242,12 +242,6 @@ this CPU is also deprecated.
 System emulator devices
 ---
 
-``ide-drive`` (since 4.2)
-'
-
-The 'ide-drive' device is deprecated. Users should use 'ide-hd' or
-'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed.
-
 ``scsi-disk`` (since 4.2)
 '
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 870a222062..8fd3fafb32 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -213,6 +213,15 @@ This machine has been renamed ``fuloong2e``.
 These machine types were very old and likely could not be used for live
 migration from old QEMU versions anymore. Use a newer machine type instead.
 
+System emulator devices
+---
+
+``ide-drive`` (removed in 6.0)
+''
+
+The 'ide-drive' device has been removed. Users should use 'ide-hd' or
+'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed.
+
 Related binaries
 
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 8aa85dec54..828122e21e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -342,7 +342,6 @@ GlobalProperty pc_compat_1_4[] = {
 { "scsi-disk", "discard_granularity", "0" },
 { "ide-hd", "discard_granularity", "0" },
 { "ide-cd", "discard_granularity", "0" },
-{ "ide-drive", "discard_granularity", "0" },
 { "virtio-blk-pci", "discard_granularity", "0" },
 /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string: */
 { "virtio-serial-pci", "vectors", "0x" },
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 8cd19fa5e9..e70ebc83a0 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -283,20 +283,6 @@ static void ide_cd_realize(IDEDevice *dev, Error **errp)
 ide_dev_initfn(dev, IDE_CD, errp);
 }
 
-static void ide_drive_realize(IDEDevice *dev, Error **errp)
-{
-DriveInfo *dinfo = NULL;
-
-warn_report("'ide-drive' is deprecated, "
-"please use 'ide-hd' or 'ide-cd' instead");
-
-if (dev->conf.blk) {
-dinfo = blk_legacy_dinfo(dev->conf.blk);
-}
-
-ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD, errp);
-}
-
 #define DEFINE_IDE_DEV_PROPERTIES() \
 DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),\
 DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf),  \
@@ -355,29 +341,6 @@ static const TypeInfo ide_cd_info = {
 .class_init= ide_cd_class_init,
 };
 
-static Property ide_drive_properties[] = {
-DEFINE_IDE_DEV_PROPERTIES(),
-DEFINE_PROP_END_OF_LIST(),
-};
-
-static void ide_drive_class_init(ObjectClass *klass, void *data)
-{
-DeviceClass *dc = DEVICE_CLASS(klass);
-IDEDeviceClass *k = IDE_DEVICE_CLASS(klass);
-
-k->realize  = ide_drive_realize;
-dc->fw_name = "drive";
-dc->desc= "virtual IDE disk or CD-ROM (legacy)";
-device_class_set_props(dc, ide_drive_properties);
-}
-
-static const TypeInfo ide_drive_info = {
-.name  = "ide-drive",
-.parent= TYPE_IDE_DEVICE,
-.instance_size = sizeof(IDEDrive),
-.class_init= ide_drive_class_init,
-};
-
 static void ide_device_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *k = DEVICE_CLASS(klass);
@@ -402,7 +365,6 @@ static void ide_register_types(void)
 type_register_static(&ide_bus_info);
 type_register_static(&ide_hd_info);
 type_register_static(&ide_cd_info);
-type_register_static(&ide_drive_info);
 type_register_static(&ide_device_type_info);
 }
 
diff --git a/hw/ppc/mac_newworld.c b/hw

[PATCH 06/14] machine: remove 'query-cpus' QMP command

2021-02-24 Thread Daniel P . Berrangé
The newer 'query-cpus-fast' command avoids side effects on the guest
execution. Note that some of the field names are different in the
'query-cpus-fast' command.

Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst |   5 -
 docs/system/removed-features.rst   |   5 +
 hw/core/machine-hmp-cmds.c |   8 +-
 hw/core/machine-qmp-cmds.c |  79 --
 qapi/machine.json  | 161 +
 tests/acceptance/pc_cpu_hotplug_props.py   |   2 +-
 tests/acceptance/x86_cpu_model_versions.py |   2 +-
 tests/migration/guestperf/engine.py|   2 +-
 tests/qtest/numa-test.c|   6 +-
 tests/qtest/qmp-test.c |   6 +-
 tests/qtest/test-x86-cpuid-compat.c|   4 +-
 11 files changed, 22 insertions(+), 258 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index e214f0a9cf..484f017119 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -192,11 +192,6 @@ Since the ``dirty-bitmaps`` field is optionally present in 
both the old and
 new locations, clients must use introspection to learn where to anticipate
 the field if/when it does appear in command output.
 
-``query-cpus`` (since 2.12.0)
-'
-
-The ``query-cpus`` command is replaced by the ``query-cpus-fast`` command.
-
 ``query-cpus-fast`` ``arch`` output member (since 3.0.0)
 
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 2c5513dcc7..ad146daf9b 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -95,6 +95,11 @@ Use ``migrate_set_parameter`` and ``info 
migrate_parameters`` instead.
 
 Use ``migrate_set_parameter`` instead.
 
+``query-cpus`` (removed in 6.0)
+'''
+
+The ``query-cpus`` command is replaced by the ``query-cpus-fast`` command.
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 6357be9c6b..58248cffa3 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -130,7 +130,7 @@ void hmp_info_numa(Monitor *mon, const QDict *qdict)
 {
 int i, nb_numa_nodes;
 NumaNodeMem *node_mem;
-CpuInfoList *cpu_list, *cpu;
+CpuInfoFastList *cpu_list, *cpu;
 MachineState *ms = MACHINE(qdev_get_machine());
 
 nb_numa_nodes = ms->numa_state ? ms->numa_state->num_nodes : 0;
@@ -139,7 +139,7 @@ void hmp_info_numa(Monitor *mon, const QDict *qdict)
 return;
 }
 
-cpu_list = qmp_query_cpus(&error_abort);
+cpu_list = qmp_query_cpus_fast(&error_abort);
 node_mem = g_new0(NumaNodeMem, nb_numa_nodes);
 
 query_numa_node_mem(node_mem, ms);
@@ -148,7 +148,7 @@ void hmp_info_numa(Monitor *mon, const QDict *qdict)
 for (cpu = cpu_list; cpu; cpu = cpu->next) {
 if (cpu->value->has_props && cpu->value->props->has_node_id &&
 cpu->value->props->node_id == i) {
-monitor_printf(mon, " %" PRIi64, cpu->value->CPU);
+monitor_printf(mon, " %" PRIi64, cpu->value->cpu_index);
 }
 }
 monitor_printf(mon, "\n");
@@ -157,6 +157,6 @@ void hmp_info_numa(Monitor *mon, const QDict *qdict)
 monitor_printf(mon, "node %d plugged: %" PRId64 " MB\n", i,
node_mem[i].node_plugged_mem >> 20);
 }
-qapi_free_CpuInfoList(cpu_list);
+qapi_free_CpuInfoFastList(cpu_list);
 g_free(node_mem);
 }
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 44e979e503..af60cd969d 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -24,85 +24,6 @@
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
 
-CpuInfoList *qmp_query_cpus(Error **errp)
-{
-MachineState *ms = MACHINE(qdev_get_machine());
-MachineClass *mc = MACHINE_GET_CLASS(ms);
-CpuInfoList *head = NULL, **tail = &head;
-CPUState *cpu;
-
-CPU_FOREACH(cpu) {
-CpuInfo *value;
-#if defined(TARGET_I386)
-X86CPU *x86_cpu = X86_CPU(cpu);
-CPUX86State *env = &x86_cpu->env;
-#elif defined(TARGET_PPC)
-PowerPCCPU *ppc_cpu = POWERPC_CPU(cpu);
-CPUPPCState *env = &ppc_cpu->env;
-#elif defined(TARGET_SPARC)
-SPARCCPU *sparc_cpu = SPARC_CPU(cpu);
-CPUSPARCState *env = &sparc_cpu->env;
-#elif defined(TARGET_RISCV)
-RISCVCPU *riscv_cpu = RISCV_CPU(cpu);
-CPURISCVState *env = &riscv_cpu->env;
-#elif defined(TARGET_MIPS)
-MIPSCPU *mips_cpu = MIPS_CPU(cpu);
-CPUMIPSState *env = &mips_cpu->env;
-#elif defined(TARGET_TRICORE)
-TriCoreCPU *tricore_cpu = TRICORE_CPU(cpu);
-CPUTriCoreState *env = &tricore_cpu->env;
-#elif defined(TARGET_S390X)
-S390CPU *s390_cpu = S390_CPU(cpu);
-CPUS390XState *env = &s390_cpu->

[PATCH 07/14] machine: remove 'arch' field from 'query-cpus-fast' QMP command

2021-02-24 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst   |  6 -
 docs/system/removed-features.rst |  6 +
 hw/core/machine-qmp-cmds.c   | 41 
 qapi/machine.json| 22 -
 4 files changed, 6 insertions(+), 69 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 484f017119..78474f0845 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -192,12 +192,6 @@ Since the ``dirty-bitmaps`` field is optionally present in 
both the old and
 new locations, clients must use introspection to learn where to anticipate
 the field if/when it does appear in command output.
 
-``query-cpus-fast`` ``arch`` output member (since 3.0.0)
-
-
-The ``arch`` output member of the ``query-cpus-fast`` command is
-replaced by the ``target`` output member.
-
 chardev client socket with ``wait`` option (since 4.0)
 ''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index ad146daf9b..7942c2e513 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -100,6 +100,12 @@ Use ``migrate_set_parameter`` instead.
 
 The ``query-cpus`` command is replaced by the ``query-cpus-fast`` command.
 
+``query-cpus-fast`` ``arch`` output member (removed in 6.0)
+'''
+
+The ``arch`` output member of the ``query-cpus-fast`` command is
+replaced by the ``target`` output member.
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index af60cd969d..68a942595a 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -24,46 +24,6 @@
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
 
-static CpuInfoArch sysemu_target_to_cpuinfo_arch(SysEmuTarget target)
-{
-/*
- * The @SysEmuTarget -> @CpuInfoArch mapping below is based on the
- * TARGET_ARCH -> TARGET_BASE_ARCH mapping in the "configure" script.
- */
-switch (target) {
-case SYS_EMU_TARGET_I386:
-case SYS_EMU_TARGET_X86_64:
-return CPU_INFO_ARCH_X86;
-
-case SYS_EMU_TARGET_PPC:
-case SYS_EMU_TARGET_PPC64:
-return CPU_INFO_ARCH_PPC;
-
-case SYS_EMU_TARGET_SPARC:
-case SYS_EMU_TARGET_SPARC64:
-return CPU_INFO_ARCH_SPARC;
-
-case SYS_EMU_TARGET_MIPS:
-case SYS_EMU_TARGET_MIPSEL:
-case SYS_EMU_TARGET_MIPS64:
-case SYS_EMU_TARGET_MIPS64EL:
-return CPU_INFO_ARCH_MIPS;
-
-case SYS_EMU_TARGET_TRICORE:
-return CPU_INFO_ARCH_TRICORE;
-
-case SYS_EMU_TARGET_S390X:
-return CPU_INFO_ARCH_S390;
-
-case SYS_EMU_TARGET_RISCV32:
-case SYS_EMU_TARGET_RISCV64:
-return CPU_INFO_ARCH_RISCV;
-
-default:
-return CPU_INFO_ARCH_OTHER;
-}
-}
-
 static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cpu)
 {
 #ifdef TARGET_S390X
@@ -104,7 +64,6 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
 value->props = props;
 }
 
-value->arch = sysemu_target_to_cpuinfo_arch(target);
 value->target = target;
 if (target == SYS_EMU_TARGET_S390X) {
 cpustate_to_cpuinfo_s390(&value->u.s390x, cpu);
diff --git a/qapi/machine.json b/qapi/machine.json
index 9811927504..c0c52aef10 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -34,21 +34,6 @@
  'sh4eb', 'sparc', 'sparc64', 'tricore', 'unicore32',
  'x86_64', 'xtensa', 'xtensaeb' ] }
 
-##
-# @CpuInfoArch:
-#
-# An enumeration of cpu types that enable additional information during
-# @query-cpus-fast.
-#
-# @s390: since 2.12
-#
-# @riscv: since 2.12
-#
-# Since: 2.6
-##
-{ 'enum': 'CpuInfoArch',
-  'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 's390', 'riscv', 'other' 
] }
-
 ##
 # @CpuS390State:
 #
@@ -86,14 +71,9 @@
 # @props: properties describing to which node/socket/core/thread
 # virtual CPU belongs to, provided if supported by board
 #
-# @arch: base architecture of the cpu
-#
 # @target: the QEMU system emulation target, which determines which
 #  additional fields will be listed (since 3.0)
 #
-# Features:
-# @deprecated: Member @arch is deprecated.  Use @target instead.
-#
 # Since: 2.12
 #
 ##
@@ -102,8 +82,6 @@
   'qom-path' : 'str',
   'thread-id': 'int',
   '*props'   : 'CpuInstanceProperties',
-  'arch' : { 'type': 'CpuInfoArch',
- 'features': [ 'deprecated' ] },
   'target'   : 'SysEmuTarget' },
   'discriminator' : 'target',
   'data'  : { 's390x': 'CpuInfoS390' } }
-- 
2.29.2




[PATCH 12/14] block: remove dirty bitmaps 'status' field

2021-02-24 Thread Daniel P . Berrangé
The same information is available via the 'recording' and 'busy' fields.

Signed-off-by: Daniel P. Berrangé 
---
 block/dirty-bitmap.c |  38 
 docs/system/deprecated.rst   |   7 -
 docs/system/removed-features.rst |   7 +
 include/block/dirty-bitmap.h |   1 -
 qapi/block-core.json |  45 
 tests/qemu-iotests/124   |   4 -
 tests/qemu-iotests/194.out   |   4 +-
 tests/qemu-iotests/236.out   |  42 ++--
 tests/qemu-iotests/246.out   |  66 ++
 tests/qemu-iotests/254.out   |   9 +-
 tests/qemu-iotests/257.out   | 378 +++
 11 files changed, 174 insertions(+), 427 deletions(-)

diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 9b9cd71238..085aa343e1 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -166,43 +166,6 @@ bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap)
 return !bitmap->disabled;
 }
 
-/**
- * bdrv_dirty_bitmap_status: This API is now deprecated.
- * Called with BQL taken.
- *
- * A BdrvDirtyBitmap can be in four possible user-visible states:
- * (1) Active:   successor is NULL, and disabled is false: full r/w mode
- * (2) Disabled: successor is NULL, and disabled is true: qualified r/w mode,
- *   guest writes are dropped, but monitor writes are possible,
- *   through commands like merge and clear.
- * (3) Frozen:   successor is not NULL.
- *   A frozen bitmap cannot be renamed, deleted, cleared, set,
- *   enabled, merged to, etc. A frozen bitmap can only abdicate()
- *   or reclaim().
- *   In this state, the anonymous successor bitmap may be either
- *   Active and recording writes from the guest (e.g. backup jobs),
- *   or it can be Disabled and not recording writes.
- * (4) Locked:   Whether Active or Disabled, the user cannot modify this bitmap
- *   in any way from the monitor.
- * (5) Inconsistent: This is a persistent bitmap whose "in use" bit is set, and
- *   is unusable by QEMU. It can be deleted to remove it from
- *   the qcow2.
- */
-DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap)
-{
-if (bdrv_dirty_bitmap_inconsistent(bitmap)) {
-return DIRTY_BITMAP_STATUS_INCONSISTENT;
-} else if (bdrv_dirty_bitmap_has_successor(bitmap)) {
-return DIRTY_BITMAP_STATUS_FROZEN;
-} else if (bdrv_dirty_bitmap_busy(bitmap)) {
-return DIRTY_BITMAP_STATUS_LOCKED;
-} else if (!bdrv_dirty_bitmap_enabled(bitmap)) {
-return DIRTY_BITMAP_STATUS_DISABLED;
-} else {
-return DIRTY_BITMAP_STATUS_ACTIVE;
-}
-}
-
 /* Called with BQL taken.  */
 static bool bdrv_dirty_bitmap_recording(BdrvDirtyBitmap *bitmap)
 {
@@ -582,7 +545,6 @@ BlockDirtyInfoList 
*bdrv_query_dirty_bitmaps(BlockDriverState *bs)
 info->granularity = bdrv_dirty_bitmap_granularity(bm);
 info->has_name = !!bm->name;
 info->name = g_strdup(bm->name);
-info->status = bdrv_dirty_bitmap_status(bm);
 info->recording = bdrv_dirty_bitmap_recording(bm);
 info->busy = bdrv_dirty_bitmap_busy(bm);
 info->persistent = bm->persistent;
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index e746a63edf..a8ac104c19 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -162,13 +162,6 @@ Use arguments ``base-node`` and ``top-node`` instead.
 
 Specify the properties for the object as top-level arguments instead.
 
-``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].status 
(since 4.0)
-''
-
-The ``status`` field of the ``BlockDirtyInfo`` structure, returned by
-these commands is deprecated. Two new boolean fields, ``recording`` and
-``busy`` effectively replace it.
-
 ``query-block`` result field ``dirty-bitmaps`` (Since 4.2)
 ''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 583f14f02e..725a316a4e 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -122,6 +122,13 @@ Always false.
 
 Removed with no replacement
 
+``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].status 
(removed in 6.0)
+'''
+
+The ``status`` field of the ``BlockDirtyInfo`` structure, returned by
+these commands is deprecated. Two new boolean fields, ``recording`` and
+``busy`` effectively replace it.
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 36e8da4fc2..71374fba95 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -46,7 +46,6 @@ bool bdrv_dirty_bitmap_enabl

[PATCH 11/14] block: remove 'encryption_key_missing' flag from QAPI

2021-02-24 Thread Daniel P . Berrangé
This has been hardcoded to "false" since 2.10.0, since secrets required
to unlock block devices are now always provided upfront instead of using
interactive prompts.

Signed-off-by: Daniel P. Berrangé 
---
 block/qapi.c |  1 -
 docs/system/deprecated.rst   | 10 ---
 docs/system/removed-features.rst | 10 +++
 qapi/block-core.json |  8 --
 tests/qemu-iotests/184.out   |  6 ++--
 tests/qemu-iotests/191.out   | 48 +++-
 tests/qemu-iotests/273.out   | 15 --
 7 files changed, 33 insertions(+), 65 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index 84a0aadc09..3acc118c44 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -62,7 +62,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
 info->ro = bs->read_only;
 info->drv= g_strdup(bs->drv->format_name);
 info->encrypted  = bs->encrypted;
-info->encryption_key_missing = false;
 
 info->cache = g_new(BlockdevCacheInfo, 1);
 *info->cache = (BlockdevCacheInfo) {
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index cb88fea94f..e746a63edf 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -147,16 +147,6 @@ Use argument ``id`` instead.
 
 Use argument ``id`` instead.
 
-``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)
-
-
-Always false.
-
-``query-block`` result ``inserted.encryption_key_missing`` (since 2.10.0)
-'
-
-Always false.
-
 ``blockdev-add`` empty string argument ``backing`` (since 2.10.0)
 '
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index bb6bc8dfc8..583f14f02e 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -112,6 +112,16 @@ chardev client socket with ``wait`` option (removed in 6.0)
 Character devices creating sockets in client mode should not specify
 the 'wait' field, which is only applicable to sockets in server mode
 
+``query-named-block-nodes`` result ``encryption_key_missing`` (removed in 6.0)
+''
+
+Always false.
+
+``query-block`` result ``inserted.encryption_key_missing`` (removed in 6.0)
+'''
+
+Removed with no replacement
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9f555d5c1d..d256b7b776 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -319,8 +319,6 @@
 #
 # @encrypted: true if the backing device is encrypted
 #
-# @encryption_key_missing: always false
-#
 # @detect_zeroes: detect and optimize zero writes (Since 2.1)
 #
 # @bps: total throughput limit in bytes per second is specified
@@ -385,10 +383,6 @@
 # @dirty-bitmaps: dirty bitmaps information (only present if node
 # has one or more dirty bitmaps) (Since 4.2)
 #
-# Features:
-# @deprecated: Member @encryption_key_missing is deprecated.  It is
-#  always false.
-#
 # Since: 0.14
 #
 ##
@@ -396,8 +390,6 @@
   'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
 '*backing_file': 'str', 'backing_file_depth': 'int',
 'encrypted': 'bool',
-'encryption_key_missing': { 'type': 'bool',
-'features': [ 'deprecated' ] },
 'detect_zeroes': 'BlockdevDetectZeroesOptions',
 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
index 87c73070e3..77e5489d65 100644
--- a/tests/qemu-iotests/184.out
+++ b/tests/qemu-iotests/184.out
@@ -54,8 +54,7 @@ Testing:
 "direct": false,
 "writeback": true
 },
-"file": "json:{\"throttle-group\": \"group0\", \"driver\": 
\"throttle\", \"file\": {\"driver\": \"null-co\"}}",
-"encryption_key_missing": false
+"file": "json:{\"throttle-group\": \"group0\", \"driver\": 
\"throttle\", \"file\": {\"driver\": \"null-co\"}}"
 },
 {
 "iops_rd": 0,
@@ -82,8 +81,7 @@ Testing:
 "direct": false,
 "writeback": true
 },
-"file": "null-co://",
-"encryption_key_missing": false
+"file": "null-co://"
 }
 ]
 }
diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out
index 022021efab..ea88777374 100644
--- a/tests/qemu-iotests/191.out
+++ b/tests/qemu-iotests/191.out
@@ -150,8 +150,7 @@ wrote 65536/65536 bytes 

[PATCH 04/14] softmmu: remove '-usbdevice' command line option

2021-02-24 Thread Daniel P . Berrangé
This was replaced by the '-device usb-DEV' option.

Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst   |  9 ---
 docs/system/removed-features.rst |  9 +++
 softmmu/vl.c | 42 
 3 files changed, 9 insertions(+), 51 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 611adf60f7..c577cc97c4 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -21,15 +21,6 @@ deprecated.
 System emulator command line arguments
 --
 
-``-usbdevice`` (since 2.10.0)
-'
-
-The ``-usbdevice DEV`` argument is now a synonym for setting
-the ``-device usb-DEV`` argument instead. The deprecated syntax
-would automatically enable USB support on the machine type.
-If using the new syntax, USB support must be explicitly
-enabled via the ``-machine usb=on`` argument.
-
 ``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
 '''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index dc63581fe5..74d022babf 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -50,6 +50,15 @@ by the ``tls-authz`` and ``sasl-authz`` options.
 The ``pretty=on|off`` switch has no effect for HMP monitors and
 its use is rejected.
 
+``-usbdevice`` (removed in 6.0)
+'''
+
+The ``-usbdevice DEV`` argument was now a synonym for setting
+the ``-device usb-DEV`` argument instead. The removed syntax
+would automatically enable USB support on the machine type.
+When using the new syntax, USB support must be explicitly
+enabled via the ``-machine usb=on`` argument.
+
 QEMU Machine Protocol (QMP) commands
 
 
diff --git a/softmmu/vl.c b/softmmu/vl.c
index b219ce1f35..c31061cc09 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -743,34 +743,6 @@ static void configure_msg(QemuOpts *opts)
 }
 
 
-/***/
-/* USB devices */
-
-static int usb_device_add(const char *devname)
-{
-USBDevice *dev = NULL;
-
-if (!machine_usb(current_machine)) {
-return -1;
-}
-
-dev = usbdevice_create(devname);
-if (!dev)
-return -1;
-
-return 0;
-}
-
-static int usb_parse(const char *cmdline)
-{
-int r;
-r = usb_device_add(cmdline);
-if (r < 0) {
-error_report("could not add USB device '%s'", cmdline);
-}
-return r;
-}
-
 /***/
 /* machine registration */
 
@@ -1267,7 +1239,6 @@ static void monitor_parse(const char *optarg, const char 
*mode, bool pretty)
 
 struct device_config {
 enum {
-DEV_USB,   /* -usbdevice */
 DEV_SERIAL,/* -serial*/
 DEV_PARALLEL,  /* -parallel  */
 DEV_DEBUGCON,  /* -debugcon */
@@ -2484,12 +2455,6 @@ static void qemu_create_cli_devices(void)
 qemu_opts_foreach(qemu_find_opts("fw_cfg"),
   parse_fw_cfg, fw_cfg_find(), &error_fatal);
 
-/* init USB devices */
-if (machine_usb(current_machine)) {
-if (foreach_device_config(DEV_USB, usb_parse) < 0)
-exit(1);
-}
-
 /* init generic devices */
 rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
 qemu_opts_foreach(qemu_find_opts("device"),
@@ -3182,13 +3147,6 @@ void qemu_init(int argc, char **argv, char **envp)
 olist = qemu_find_opts("machine");
 qemu_opts_parse_noisily(olist, "usb=on", false);
 break;
-case QEMU_OPTION_usbdevice:
-error_report("'-usbdevice' is deprecated, please use "
- "'-device usb-...' instead");
-olist = qemu_find_opts("machine");
-qemu_opts_parse_noisily(olist, "usb=on", false);
-add_device_config(DEV_USB, optarg);
-break;
 case QEMU_OPTION_device:
 if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
  optarg, true)) {
-- 
2.29.2




[PATCH 03/14] monitor: remove 'query-events' QMP command

2021-02-24 Thread Daniel P . Berrangé
The code comment suggests removing QAPIEvent_(str|lookup) symbols too,
however, these are both auto-generated as standard for any enum in
QAPI. As such it they'll exist whether we use them or not.

Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst   |  6 -
 docs/system/removed-features.rst |  6 +
 monitor/qmp-cmds-control.c   | 24 -
 qapi/control.json| 45 
 4 files changed, 6 insertions(+), 75 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index dfd8a8c497..611adf60f7 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -222,12 +222,6 @@ The ``query-cpus`` command is replaced by the 
``query-cpus-fast`` command.
 The ``arch`` output member of the ``query-cpus-fast`` command is
 replaced by the ``target`` output member.
 
-``query-events`` (since 4.0)
-
-
-The ``query-events`` command has been superseded by the more powerful
-and accurate ``query-qmp-schema`` command.
-
 chardev client socket with ``wait`` option (since 4.0)
 ''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 3ca13d2844..dc63581fe5 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -70,6 +70,12 @@ documentation of ``query-hotpluggable-cpus`` for additional 
details.
 
 Use ``blockdev-change-medium`` or ``change-vnc-password`` instead.
 
+``query-events`` (removed in 6.0)
+'
+
+The ``query-events`` command has been superseded by the more powerful
+and accurate ``query-qmp-schema`` command.
+
 Human Monitor Protocol (HMP) commands
 -
 
diff --git a/monitor/qmp-cmds-control.c b/monitor/qmp-cmds-control.c
index 509ae870bd..513b547233 100644
--- a/monitor/qmp-cmds-control.c
+++ b/monitor/qmp-cmds-control.c
@@ -130,30 +130,6 @@ CommandInfoList *qmp_query_commands(Error **errp)
 return list;
 }
 
-EventInfoList *qmp_query_events(Error **errp)
-{
-/*
- * TODO This deprecated command is the only user of
- * QAPIEvent_str() and QAPIEvent_lookup[].  When the command goes,
- * they should go, too.
- */
-EventInfoList *ev_list = NULL;
-QAPIEvent e;
-
-for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
-const char *event_name = QAPIEvent_str(e);
-EventInfo *info;
-
-assert(event_name != NULL);
-info = g_malloc0(sizeof(*info));
-info->name = g_strdup(event_name);
-
-QAPI_LIST_PREPEND(ev_list, info);
-}
-
-return ev_list;
-}
-
 /*
  * Minor hack: generated marshalling suppressed for this command
  * ('gen': false in the schema) so we can parse the JSON string
diff --git a/qapi/control.json b/qapi/control.json
index 2615d5170b..71a838d49e 100644
--- a/qapi/control.json
+++ b/qapi/control.json
@@ -159,51 +159,6 @@
 { 'command': 'query-commands', 'returns': ['CommandInfo'],
   'allow-preconfig': true }
 
-##
-# @EventInfo:
-#
-# Information about a QMP event
-#
-# @name: The event name
-#
-# Since: 1.2
-##
-{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
-
-##
-# @query-events:
-#
-# Return information on QMP events.
-#
-# Features:
-# @deprecated: This command is deprecated, because its output doesn't
-#  reflect compile-time configuration.  Use 'query-qmp-schema'
-#  instead.
-#
-# Returns: A list of @EventInfo.
-#
-# Since: 1.2
-#
-# Example:
-#
-# -> { "execute": "query-events" }
-# <- {
-#  "return": [
-#  {
-# "name":"SHUTDOWN"
-#  },
-#  {
-# "name":"RESET"
-#  }
-#   ]
-#}
-#
-# Note: This example has been shortened as the real response is too long.
-#
-##
-{ 'command': 'query-events', 'returns': ['EventInfo'],
-  'features': [ 'deprecated' ] }
-
 ##
 # @quit:
 #
-- 
2.29.2




[PATCH 02/14] monitor: raise error when 'pretty' option is used with HMP

2021-02-24 Thread Daniel P . Berrangé
This is only semantically useful for QMP.

Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst   | 7 ---
 docs/system/removed-features.rst | 6 ++
 monitor/monitor.c| 4 ++--
 qemu-options.hx  | 5 +++--
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 786b997fe7..dfd8a8c497 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -62,13 +62,6 @@ needs two devices (``-device intel-hda -device hda-duplex``) 
and
 ``pcspk`` which can be activated using ``-machine
 pcspk-audiodev=``.
 
-``-mon ...,control=readline,pretty=on|off`` (since 4.1)
-'''
-
-The ``pretty=on|off`` switch has no effect for HMP monitors, but is
-silently ignored. Using the switch with HMP monitors will become an
-error in the future.
-
 RISC-V ``-bios`` (since 5.1)
 
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 0424b9a89d..3ca13d2844 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -44,6 +44,12 @@ block cache, ``-accel tcg,tb-size=``.
 The ``acl`` option to the ``-vnc`` argument has been replaced
 by the ``tls-authz`` and ``sasl-authz`` options.
 
+``-mon ...,control=readline,pretty=on|off`` (removed in 6.0)
+
+
+The ``pretty=on|off`` switch has no effect for HMP monitors and
+its use is rejected.
+
 QEMU Machine Protocol (QMP) commands
 
 
diff --git a/monitor/monitor.c b/monitor/monitor.c
index e94f532cf5..515efb015e 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -720,8 +720,8 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, 
Error **errp)
 return -1;
 }
 if (opts->pretty) {
-warn_report("'pretty' is deprecated for HMP monitors, it has no "
-"effect and will be removed in future versions");
+error_setg(errp, "'pretty' is not compatible with HMP monitors");
+return -1;
 }
 monitor_init_hmp(chr, true, &local_err);
 break;
diff --git a/qemu-options.hx b/qemu-options.hx
index 6c34c7050f..a934d5c787 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3702,8 +3702,9 @@ DEF("mon", HAS_ARG, QEMU_OPTION_mon, \
 "-mon [chardev=]name[,mode=readline|control][,pretty[=on|off]]\n", 
QEMU_ARCH_ALL)
 SRST
 ``-mon [chardev=]name[,mode=readline|control][,pretty[=on|off]]``
-Setup monitor on chardev name. ``pretty`` turns on JSON pretty
-printing easing human reading and debugging.
+Setup monitor on chardev name. ``pretty`` is only valid when
+``mode=control``, turning on JSON pretty printing to ease
+human reading and debugging.
 ERST
 
 DEF("debugcon", HAS_ARG, QEMU_OPTION_debugcon, \
-- 
2.29.2




[PATCH 10/14] hw/scsi: remove 'scsi-disk' device

2021-02-24 Thread Daniel P . Berrangé
The 'scsi-hd' and 'scsi-cd' devices provide suitable alternatives.

Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst   |  9 -
 docs/system/removed-features.rst |  6 
 hw/i386/pc.c |  1 -
 hw/scsi/scsi-disk.c  | 62 
 hw/sparc64/sun4u.c   |  1 -
 scripts/device-crash-test|  1 -
 tests/qemu-iotests/051   |  2 --
 tests/qemu-iotests/051.pc.out| 10 --
 8 files changed, 6 insertions(+), 86 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index f5c82a46dc..cb88fea94f 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -239,15 +239,6 @@ The ``I7200`` guest CPU relies on the nanoMIPS ISA, which 
is deprecated
 (the ISA has never been upstreamed to a compiler toolchain). Therefore
 this CPU is also deprecated.
 
-System emulator devices

-
-``scsi-disk`` (since 4.2)
-'
-
-The 'scsi-disk' device is deprecated. Users should use 'scsi-hd' or
-'scsi-cd' as appropriate to get a SCSI hard disk or CD-ROM as needed.
-
 System emulator machines
 
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 8fd3fafb32..bb6bc8dfc8 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -222,6 +222,12 @@ System emulator devices
 The 'ide-drive' device has been removed. Users should use 'ide-hd' or
 'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed.
 
+``scsi-disk`` (removed in 6.0)
+''
+
+The 'scsi-disk' device is deprecated. Users should use 'scsi-hd' or
+'scsi-cd' as appropriate to get a SCSI hard disk or CD-ROM as needed.
+
 Related binaries
 
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 828122e21e..28a77df0d0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -339,7 +339,6 @@ GlobalProperty pc_compat_1_4[] = {
 PC_CPU_MODEL_IDS("1.4.0")
 { "scsi-hd", "discard_granularity", "0" },
 { "scsi-cd", "discard_granularity", "0" },
-{ "scsi-disk", "discard_granularity", "0" },
 { "ide-hd", "discard_granularity", "0" },
 { "ide-cd", "discard_granularity", "0" },
 { "virtio-blk-pci", "discard_granularity", "0" },
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index ed52fcd49f..2c8f68d3f0 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2490,28 +2490,6 @@ static void scsi_cd_realize(SCSIDevice *dev, Error 
**errp)
 aio_context_release(ctx);
 }
 
-static void scsi_disk_realize(SCSIDevice *dev, Error **errp)
-{
-DriveInfo *dinfo;
-Error *local_err = NULL;
-
-warn_report("'scsi-disk' is deprecated, "
-"please use 'scsi-hd' or 'scsi-cd' instead");
-
-if (!dev->conf.blk) {
-scsi_realize(dev, &local_err);
-assert(local_err);
-error_propagate(errp, local_err);
-return;
-}
-
-dinfo = blk_legacy_dinfo(dev->conf.blk);
-if (dinfo && dinfo->media_cd) {
-scsi_cd_realize(dev, errp);
-} else {
-scsi_hd_realize(dev, errp);
-}
-}
 
 static const SCSIReqOps scsi_disk_emulate_reqops = {
 .size = sizeof(SCSIDiskReq),
@@ -3131,45 +3109,6 @@ static const TypeInfo scsi_block_info = {
 };
 #endif
 
-static Property scsi_disk_properties[] = {
-DEFINE_SCSI_DISK_PROPERTIES(),
-DEFINE_PROP_BIT("removable", SCSIDiskState, features,
-SCSI_DISK_F_REMOVABLE, false),
-DEFINE_PROP_BIT("dpofua", SCSIDiskState, features,
-SCSI_DISK_F_DPOFUA, false),
-DEFINE_PROP_UINT64("wwn", SCSIDiskState, qdev.wwn, 0),
-DEFINE_PROP_UINT64("port_wwn", SCSIDiskState, qdev.port_wwn, 0),
-DEFINE_PROP_UINT16("port_index", SCSIDiskState, port_index, 0),
-DEFINE_PROP_UINT64("max_unmap_size", SCSIDiskState, max_unmap_size,
-   DEFAULT_MAX_UNMAP_SIZE),
-DEFINE_PROP_UINT64("max_io_size", SCSIDiskState, max_io_size,
-   DEFAULT_MAX_IO_SIZE),
-DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_version,
-  5),
-DEFINE_PROP_END_OF_LIST(),
-};
-
-static void scsi_disk_class_initfn(ObjectClass *klass, void *data)
-{
-DeviceClass *dc = DEVICE_CLASS(klass);
-SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
-
-sc->realize  = scsi_disk_realize;
-sc->alloc_req= scsi_new_request;
-sc->unit_attention_reported = scsi_disk_unit_attention_reported;
-dc->fw_name = "disk";
-dc->desc = "virtual SCSI disk or CD-ROM (legacy)";
-dc->reset = scsi_disk_reset;
-device_class_set_props(dc, scsi_disk_properties);
-dc->vmsd  = &vmstate_scsi_disk_state;
-}
-
-static const TypeInfo scsi_disk_info = {
-.name  = "scsi-disk",
-.parent= TYPE_SCSI_DISK_BASE,
-.class_init= scsi_disk_class_initfn,
-};
-
 static void scsi_disk_register_types(void)
 {
 type_regi

[PATCH 05/14] migrate: remove QMP/HMP commands for speed, downtime and cache size

2021-02-24 Thread Daniel P . Berrangé
The generic 'migrate_set_parameters' command handle all types of param.

Only the QMP commands were documented in the deprecations page, but the
rationale for deprecating applies equally to HMP, and the replacements
exist. Furthermore the HMP commands are just shims to the QMP commands,
so removing the latter breaks the former unless they get re-implemented.

Signed-off-by: Daniel P. Berrangé 
---
 docs/devel/migration.rst|  2 +-
 docs/rdma.txt   |  2 +-
 docs/system/deprecated.rst  | 10 ---
 docs/system/removed-features.rst| 20 ++
 docs/xbzrle.txt |  5 --
 hmp-commands-info.hx| 13 
 hmp-commands.hx | 45 -
 include/monitor/hmp.h   |  4 --
 migration/migration.c   | 45 -
 migration/ram.c |  2 +-
 monitor/hmp-cmds.c  | 34 --
 qapi/migration.json | 98 -
 tests/migration/guestperf/engine.py | 16 ++---
 tests/qemu-iotests/181  |  2 +-
 tests/qtest/migration-test.c| 48 --
 tests/qtest/test-hmp.c  |  6 +-
 tests/qtest/vhost-user-test.c   |  8 +--
 17 files changed, 40 insertions(+), 320 deletions(-)

diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst
index ad381b89b2..19c3d4f3ea 100644
--- a/docs/devel/migration.rst
+++ b/docs/devel/migration.rst
@@ -641,7 +641,7 @@ time per vCPU.
 
 .. note::
   During the postcopy phase, the bandwidth limits set using
-  ``migrate_set_speed`` is ignored (to avoid delaying requested pages that
+  ``migrate_set_parameter`` is ignored (to avoid delaying requested pages that
   the destination is waiting for).
 
 Postcopy device transfer
diff --git a/docs/rdma.txt b/docs/rdma.txt
index 49dc9f8bca..2b4cdea1d8 100644
--- a/docs/rdma.txt
+++ b/docs/rdma.txt
@@ -89,7 +89,7 @@ RUNNING:
 First, set the migration speed to match your hardware's capabilities:
 
 QEMU Monitor Command:
-$ migrate_set_speed 40g # or whatever is the MAX of your RDMA device
+$ migrate_set_parameter max_bandwidth 40g # or whatever is the MAX of your 
RDMA device
 
 Next, on the destination machine, add the following to the QEMU command line:
 
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index c577cc97c4..e214f0a9cf 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -147,11 +147,6 @@ Use argument ``id`` instead.
 
 Use argument ``id`` instead.
 
-``migrate_set_downtime`` and ``migrate_set_speed`` (since 2.8.0)
-
-
-Use ``migrate-set-parameters`` instead.
-
 ``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)
 
 
@@ -167,11 +162,6 @@ Always false.
 
 Use argument value ``null`` instead.
 
-``migrate-set-cache-size`` and ``query-migrate-cache-size`` (since 2.11.0)
-''
-
-Use ``migrate-set-parameters`` and ``query-migrate-parameters`` instead.
-
 ``block-commit`` arguments ``base`` and ``top`` (since 3.1.0)
 '
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 74d022babf..2c5513dcc7 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -85,6 +85,16 @@ Use ``blockdev-change-medium`` or ``change-vnc-password`` 
instead.
 The ``query-events`` command has been superseded by the more powerful
 and accurate ``query-qmp-schema`` command.
 
+``migrate_set_cache_size`` and ``query-migrate-cache-size`` (removed in 6.0)
+
+
+Use ``migrate_set_parameter`` and ``info migrate_parameters`` instead.
+
+``migrate_set_downtime`` and ``migrate_set_speed`` (removed in 6.0)
+'''
+
+Use ``migrate_set_parameter`` instead.
+
 Human Monitor Protocol (HMP) commands
 -
 
@@ -113,6 +123,16 @@ The ``acl_show``, ``acl_reset``, ``acl_policy``, 
``acl_add``, and
 ``acl_remove`` commands were removed with no replacement. Authorization
 for VNC should be performed using the pluggable QAuthZ objects.
 
+``migrate-set-cache-size`` and ``info migrate-cache-size`` (removed in 6.0)
+'''
+
+Use ``migrate-set-parameters`` and ``info migrate-parameters`` instead.
+
+``migrate_set_downtime`` and ``migrate_set_speed`` (removed in 6.0)
+'''
+
+Use ``migrate-set-parameters`` instead.
+
 Guest Emulator ISAs
 ---
 
diff --git a/docs/xbzrle.txt b/docs/xbzrle.txt
index 6bd1828f34..bcb3f0c901 100644
--- a/docs/xbzrle.txt
+++ b/docs/xb

[PATCH 01/14] ui, monitor: remove deprecated VNC ACL option and HMP commands

2021-02-24 Thread Daniel P . Berrangé
The VNC ACL concept has been replaced by the pluggable "authz" framework
which does not use monitor commands.

Reviewed-by: Dr. David Alan Gilbert 
Signed-off-by: Daniel P. Berrangé 
---
 docs/system/deprecated.rst   |  16 ---
 docs/system/removed-features.rst |  13 +++
 hmp-commands.hx  |  76 -
 monitor/misc.c   | 187 ---
 ui/vnc.c |  38 ---
 5 files changed, 13 insertions(+), 317 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 2fcac7861e..786b997fe7 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -37,12 +37,6 @@ The 'file' driver for drives is no longer appropriate for 
character or host
 devices and will only accept regular files (S_IFREG). The correct driver
 for these file types is 'host_cdrom' or 'host_device' as appropriate.
 
-``-vnc acl`` (since 4.0.0)
-''
-
-The ``acl`` option to the ``-vnc`` argument has been replaced
-by the ``tls-authz`` and ``sasl-authz`` options.
-
 ``QEMU_AUDIO_`` environment variables and ``-audio-help`` (since 4.0)
 '
 
@@ -254,16 +248,6 @@ Use the more generic commands ``block-export-add`` and 
``block-export-del``
 instead.  As part of this deprecation, where ``nbd-server-add`` used a
 single ``bitmap``, the new ``block-export-add`` uses a list of ``bitmaps``.
 
-Human Monitor Protocol (HMP) commands
--
-
-``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` 
(since 4.0.0)
-''
-
-The ``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, and
-``acl_remove`` commands are deprecated with no replacement. Authorization
-for VNC should be performed using the pluggable QAuthZ objects.
-
 System emulator CPUS
 
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index c8481cafbd..0424b9a89d 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -38,6 +38,12 @@ or ``-display default,show-cursor=on`` instead.
 QEMU 5.0 introduced an alternative syntax to specify the size of the 
translation
 block cache, ``-accel tcg,tb-size=``.
 
+``-vnc acl`` (removed in 6.0)
+'
+
+The ``acl`` option to the ``-vnc`` argument has been replaced
+by the ``tls-authz`` and ``sasl-authz`` options.
+
 QEMU Machine Protocol (QMP) commands
 
 
@@ -79,6 +85,13 @@ documentation of ``query-hotpluggable-cpus`` for additional 
details.
 No replacement.  The ``change vnc password`` and ``change DEVICE MEDIUM``
 commands are not affected.
 
+``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` 
(removed in 6.0)
+'
+
+The ``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, and
+``acl_remove`` commands were removed with no replacement. Authorization
+for VNC should be performed using the pluggable QAuthZ objects.
+
 Guest Emulator ISAs
 ---
 
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d4001f9c5d..b500b8526d 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1433,82 +1433,6 @@ SRST
   Change watchdog action.
 ERST
 
-{
-.name   = "acl_show",
-.args_type  = "aclname:s",
-.params = "aclname",
-.help   = "list rules in the access control list",
-.cmd= hmp_acl_show,
-},
-
-SRST
-``acl_show`` *aclname*
-  List all the matching rules in the access control list, and the default
-  policy. There are currently two named access control lists,
-  *vnc.x509dname* and *vnc.username* matching on the x509 client
-  certificate distinguished name, and SASL username respectively.
-ERST
-
-{
-.name   = "acl_policy",
-.args_type  = "aclname:s,policy:s",
-.params = "aclname allow|deny",
-.help   = "set default access control list policy",
-.cmd= hmp_acl_policy,
-},
-
-SRST
-``acl_policy`` *aclname* ``allow|deny``
-  Set the default access control list policy, used in the event that
-  none of the explicit rules match. The default policy at startup is
-  always ``deny``.
-ERST
-
-{
-.name   = "acl_add",
-.args_type  = "aclname:s,match:s,policy:s,index:i?",
-.params = "aclname match allow|deny [index]",
-.help   = "add a match rule to the access control list",
-.cmd= hmp_acl_add,
-},
-
-SRST
-``acl_add`` *aclname* *match* ``allow|deny`` [*index*]
-  Add a match rule to the access control list, allowing or denying access.
-  The match will normally be an exact username or x509 distinguished name,
-  but can optionally include wildcard globs. eg ``*

[PATCH 00/14] deprecations: remove many old deprecations

2021-02-24 Thread Daniel P . Berrangé
The following features have been deprecated for well over the 2
release cycle we promise

  ``-usbdevice`` (since 2.10.0)
  ``-drive file=3Djson:{...{'driver':'file'}}`` (since 3.0)
  ``-vnc acl`` (since 4.0.0)
  ``-mon ...,control=3Dreadline,pretty=3Don|off`` (since 4.1)
  ``migrate_set_downtime`` and ``migrate_set_speed`` (since 2.8.0)
  ``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)
  ``query-block`` result ``inserted.encryption_key_missing`` (since 2.10.0)
  ``migrate-set-cache-size`` and ``query-migrate-cache-size`` (since 2.11.0)
  ``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].sta=
tus (ince 4.0)
  ``query-cpus`` (since 2.12.0)
  ``query-cpus-fast`` ``arch`` output member (since 3.0.0)
  ``query-events`` (since 4.0)
  chardev client socket with ``wait`` option (since 4.0)
  ``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` (s=
ince 4.0.0)
  ``ide-drive`` (since 4.2)
  ``scsi-disk`` (since 4.2)

AFAICT, libvirt has ceased to use all of these too.

There are many more similarly old deprecations not (yet) tackled.

Daniel P. Berrang=C3=A9 (14):
  ui, monitor: remove deprecated VNC ACL option and HMP commands
  monitor: raise error when 'pretty' option is used with HMP
  monitor: remove 'query-events' QMP command
  softmmu: remove '-usbdevice' command line option
  migrate: remove QMP/HMP commands for speed, downtime and cache size
  machine: remove 'query-cpus' QMP command
  machine: remove 'arch' field from 'query-cpus-fast' QMP command
  chardev: reject use of 'wait' flag for socket client chardevs
  hw/ide: remove 'ide-drive' device
  hw/scsi: remove 'scsi-disk' device
  block: remove 'encryption_key_missing' flag from QAPI
  block: remove dirty bitmaps 'status' field
  block: remove 'dirty-bitmaps' field from 'BlockInfo' struct
  block: remove support for using "file" driver with block/char devices

 block/dirty-bitmap.c   |  38 ---
 block/file-posix.c |  17 +-
 block/qapi.c   |   6 -
 chardev/char-socket.c  |  12 +-
 docs/devel/migration.rst   |   2 +-
 docs/qdev-device-use.txt   |   2 +-
 docs/rdma.txt  |   2 +-
 docs/system/deprecated.rst | 117 ---
 docs/system/removed-features.rst   | 123 +++
 docs/xbzrle.txt|   5 -
 hmp-commands-info.hx   |  13 -
 hmp-commands.hx| 121 ---
 hw/core/machine-hmp-cmds.c |   8 +-
 hw/core/machine-qmp-cmds.c | 120 ---
 hw/i386/pc.c   |   2 -
 hw/ide/qdev.c  |  38 ---
 hw/ppc/mac_newworld.c  |  13 -
 hw/ppc/mac_oldworld.c  |  13 -
 hw/scsi/scsi-disk.c|  62 
 hw/sparc64/sun4u.c |  15 -
 include/block/dirty-bitmap.h   |   1 -
 include/monitor/hmp.h  |   4 -
 migration/migration.c  |  45 ---
 migration/ram.c|   2 +-
 monitor/hmp-cmds.c |  34 --
 monitor/misc.c | 187 --
 monitor/monitor.c  |   4 +-
 monitor/qmp-cmds-control.c |  24 --
 qapi/block-core.json   |  64 +---
 qapi/control.json  |  45 ---
 qapi/machine.json  | 181 +-
 qapi/migration.json|  98 --
 qemu-options.hx|   5 +-
 scripts/device-crash-test  |   2 -
 softmmu/vl.c   |  43 ---
 tests/acceptance/pc_cpu_hotplug_props.py   |   2 +-
 tests/acceptance/x86_cpu_model_versions.py |   2 +-
 tests/migration/guestperf/engine.py|  18 +-
 tests/qemu-iotests/051 |   4 -
 tests/qemu-iotests/051.pc.out  |  20 --
 tests/qemu-iotests/124 |   4 -
 tests/qemu-iotests/181 |   2 +-
 tests/qemu-iotests/184.out |   6 +-
 tests/qemu-iotests/191.out |  48 +--
 tests/qemu-iotests/194 |   4 +-
 tests/qemu-iotests/194.out |   4 +-
 tests/qemu-iotests/226.out |  10 +-
 tests/qemu-iotests/236 |   2 +-
 tests/qemu-iotests/236.out |  42 +--
 tests/qemu-iotests/246 |   3 +-
 tests/qemu-iotests/246.out |  66 ++--
 tests/qemu-iotests/254 |   2 +-
 tests/qemu-iotests/254.out |   9 +-
 tests/qemu-iotests/257.out | 378 +++--
 tests/qemu-iotests/260 |   5 +-
 tests/qemu-iotests/273.out |  15 +-
 tests/qtest/migration-test.c   |  48 ---

Re: [RFC PATCH v2 3/4] block: Support multiple reopening with x-blockdev-reopen

2021-02-24 Thread Kevin Wolf
Am 09.02.2021 um 09:03 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 08.02.2021 21:44, Alberto Garcia wrote:
> > Signed-off-by: Alberto Garcia 
> > ---
> >   qapi/block-core.json   |  2 +-
> >   include/block/block.h  |  1 +
> >   block.c| 16 +--
> >   blockdev.c | 85 +-
> >   tests/qemu-iotests/155 |  9 ++--
> >   tests/qemu-iotests/165 |  4 +-
> >   tests/qemu-iotests/245 | 27 +++-
> >   tests/qemu-iotests/248 |  2 +-
> >   tests/qemu-iotests/248.out |  2 +-
> >   tests/qemu-iotests/298 |  4 +-
> >   10 files changed, 89 insertions(+), 63 deletions(-)
> > 
> > diff --git a/qapi/block-core.json b/qapi/block-core.json
> > index c0e7c23331..b9fcf20a81 100644
> > --- a/qapi/block-core.json
> > +++ b/qapi/block-core.json
> > @@ -4177,7 +4177,7 @@
> >   # Since: 4.0
> >   ##
> >   { 'command': 'x-blockdev-reopen',
> > -  'data': 'BlockdevOptions', 'boxed': true }
> > +  'data': { 'options': ['BlockdevOptions'] } }
> 
> Do we also want to drop x- prefix?

libvirt really wants to have a stable blockdev-reopen interface in 6.0
because enabling the incremental backup code depends on this (they just
toggle the readonly flag if I understand correctly, so most of the work
we're currently doing isn't even relevant at this moment for libvirt).

Given that the soft freeze is coming closer (March 16), I wonder if we
should just make this API change and declare the interface stable. We
can then make Vladimir's fixes and the file reopening on top of it - if
it's in time for 6.0, that would be good, but if not we could move it to
6.1 without impacting libvirt.

I think we're reasonable confident that the QAPI interfaces are right,
even if maybe not that all aspects of the implementation are right yet.

What do you think?

Kevin




Re: [PATCH v2 01/22] block: add eMMC block device type

2021-02-24 Thread Stefan Hajnoczi
On Tue, Feb 23, 2021 at 05:35:20PM +, Sai Pavan Boddu wrote:
> Hi Philippe,
> 
> > -Original Message-
> > From: Philippe Mathieu-Daudé 
> > Sent: Monday, February 22, 2021 5:34 PM
> > To: Sai Pavan Boddu ; Markus Armbruster
> > ; Kevin Wolf ; Max Reitz
> > ; Vladimir Sementsov-Ogievskiy
> > ; Eric Blake ; Joel Stanley
> > ; Cédric Le Goater ; Vincent Palatin
> > ; Dr. David Alan Gilbert ;
> > Thomas Huth ; Stefan Hajnoczi ;
> > Peter Maydell ; Alistair Francis
> > ; Edgar Iglesias ; Luc Michel
> > ; Paolo Bonzini 
> > Cc: Sai Pavan Boddu ; qemu-de...@nongnu.org; qemu-
> > bl...@nongnu.org
> > Subject: Re: [PATCH v2 01/22] block: add eMMC block device type
> > 
> > On 2/22/21 9:20 AM, Sai Pavan Boddu wrote:
> > > From: Vincent Palatin 
> > >
> > > Add new block device type.
> > >
> > > Signed-off-by: Vincent Palatin 
> > > [SPB: Rebased over 5.1 version]
> > > Signed-off-by: Sai Pavan Boddu 
> > > Signed-off-by: Joel Stanley 
> > > Signed-off-by: Cédric Le Goater 
> > > Reviewed-by: Alistair Francis 
> > > ---
> > >  include/sysemu/blockdev.h | 1 +
> > >  blockdev.c| 1 +
> > >  2 files changed, 2 insertions(+)
> > >
> > > diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
> > > index 3b5fcda..eefae9f 100644
> > > --- a/include/sysemu/blockdev.h
> > > +++ b/include/sysemu/blockdev.h
> > > @@ -24,6 +24,7 @@ typedef enum {
> > >   */
> > >  IF_NONE = 0,
> > >  IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO,
> > > IF_XEN,
> > > +IF_EMMC,
> > >  IF_COUNT
> > >  } BlockInterfaceType;
> > >
> > > diff --git a/blockdev.c b/blockdev.c
> > > index cd438e6..390d43c 100644
> > > --- a/blockdev.c
> > > +++ b/blockdev.c
> > > @@ -83,6 +83,7 @@ static const char *const if_name[IF_COUNT] = {
> > >  [IF_SD] = "sd",
> > >  [IF_VIRTIO] = "virtio",
> > >  [IF_XEN] = "xen",
> > > +[IF_EMMC] = "emmc",
> > >  };
> > 
> > We don't need to introduce support for the legacy -drive magic.
> > 
> > -device should be enough for this device, right?
> [Sai Pavan Boddu] I was seeing to use -device for emmc. But I see we anyway 
> need blockdev support for this, which would require us the use -drive.
> 
> Can you give some pointers, how to approach this ?

It is probably not necessary to add a new IF_ constant. Would this work:

  -drive if=none,id=emmc0,file=test.img,format=raw
  -device emmc,...,drive=emmc0

Or the more modern:

  -blockdev node-name=emmc0,driver=file,filename=test.img
  -device emmc,...,drive=emmc0

?

(The syntax might need small tweaks but is shows the general idea.)

Stefan


signature.asc
Description: PGP signature


Re: [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field

2021-02-24 Thread Denis V. Lunev
On 2/24/21 1:47 PM, Vladimir Sementsov-Ogievskiy wrote:
> We are going to use it in more places, calculating
> "s->tracks << BDRV_SECTOR_BITS" doesn't look good.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  block/parallels.h | 1 +
>  block/parallels.c | 8 
>  2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/block/parallels.h b/block/parallels.h
> index 5aa101cfc8..9a9209e320 100644
> --- a/block/parallels.h
> +++ b/block/parallels.h
> @@ -79,6 +79,7 @@ typedef struct BDRVParallelsState {
>  ParallelsPreallocMode prealloc_mode;
>  
>  unsigned int tracks;
> +unsigned int cluster_size;
>  
>  unsigned int off_multiplier;
>  Error *migration_blocker;
> diff --git a/block/parallels.c b/block/parallels.c
> index 3c22dfdc9d..9594d84978 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -421,7 +421,6 @@ static int coroutine_fn 
> parallels_co_check(BlockDriverState *bs,
>  int ret;
>  uint32_t i;
>  bool flush_bat = false;
> -int cluster_size = s->tracks << BDRV_SECTOR_BITS;
>  
>  size = bdrv_getlength(bs->file->bs);
>  if (size < 0) {
> @@ -472,7 +471,7 @@ static int coroutine_fn 
> parallels_co_check(BlockDriverState *bs,
>  high_off = off;
>  }
>  
> -if (prev_off != 0 && (prev_off + cluster_size) != off) {
> +if (prev_off != 0 && (prev_off + s->cluster_size) != off) {
>  res->bfi.fragmented_clusters++;
>  }
>  prev_off = off;
> @@ -487,10 +486,10 @@ static int coroutine_fn 
> parallels_co_check(BlockDriverState *bs,
>  }
>  }
>  
> -res->image_end_offset = high_off + cluster_size;
> +res->image_end_offset = high_off + s->cluster_size;
>  if (size > res->image_end_offset) {
>  int64_t count;
> -count = DIV_ROUND_UP(size - res->image_end_offset, cluster_size);
> +count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
>  fprintf(stderr, "%s space leaked at the end of the image %" PRId64 
> "\n",
>  fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR",
>  size - res->image_end_offset);
> @@ -771,6 +770,7 @@ static int parallels_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  ret = -EFBIG;
>  goto fail;
>  }
> +s->cluster_size = s->tracks << BDRV_SECTOR_BITS;
>  
>  s->bat_size = le32_to_cpu(ph.bat_entries);
>  if (s->bat_size > INT_MAX / sizeof(uint32_t)) {
Reviewed-by: Denis V. Lunev 



[PATCH v2 6/6] iotests: add parallels-read-bitmap test

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
Test support for reading bitmap from parallels image format.
parallels-with-bitmap.bz2 is generated on Virtuozzo by
parallels-with-bitmap.sh

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 .../sample_images/parallels-with-bitmap.bz2   | Bin 0 -> 203 bytes
 .../sample_images/parallels-with-bitmap.sh|  51 
 .../qemu-iotests/tests/parallels-read-bitmap  |  55 ++
 .../tests/parallels-read-bitmap.out   |   6 ++
 4 files changed, 112 insertions(+)
 create mode 100644 tests/qemu-iotests/sample_images/parallels-with-bitmap.bz2
 create mode 100755 tests/qemu-iotests/sample_images/parallels-with-bitmap.sh
 create mode 100755 tests/qemu-iotests/tests/parallels-read-bitmap
 create mode 100644 tests/qemu-iotests/tests/parallels-read-bitmap.out

diff --git a/tests/qemu-iotests/sample_images/parallels-with-bitmap.bz2 
b/tests/qemu-iotests/sample_images/parallels-with-bitmap.bz2
new file mode 100644
index 
..54892fd4d01bf743d395bd4f3d896494146ab5a9
GIT binary patch
literal 203
zcmV;+05tzXT4*^jL0KkKS@=;0bpT+Hf7|^?KmNPH-R
Fx`3oHQ9u9y

literal 0
HcmV?d1

diff --git a/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh 
b/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh
new file mode 100755
index 00..30615aa6bd
--- /dev/null
+++ b/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Test parallels load bitmap
+#
+# Copyright (c) 2021 Virtuozzo International GmbH.
+#
+# 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 .
+#
+
+CT=parallels-with-bitmap-ct
+DIR=$PWD/parallels-with-bitmap-dir
+IMG=$DIR/root.hds
+XML=$DIR/DiskDescriptor.xml
+TARGET=parallels-with-bitmap.bz2
+
+rm -rf $DIR
+
+prlctl create $CT --vmtype ct
+prlctl set $CT --device-add hdd --image $DIR --recreate --size 2G
+
+# cleanup the image
+qemu-img create -f parallels $IMG 64G
+
+# create bitmap
+prlctl backup $CT
+
+prlctl set $CT --device-del hdd1
+prlctl destroy $CT
+
+dev=$(ploop mount $XML | sed -n 's/^Adding delta 
dev=\(\/dev\/ploop[0-9]\+\).*/\1/p')
+dd if=/dev/zero of=$dev bs=64K seek=5 count=2 oflag=direct
+dd if=/dev/zero of=$dev bs=64K seek=30 count=1 oflag=direct
+dd if=/dev/zero of=$dev bs=64K seek=10 count=3 oflag=direct
+ploop umount $XML  # bitmap name will be in the output
+
+bzip2 -z $IMG
+
+mv $IMG.bz2 $TARGET
+
+rm -rf $DIR
diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap 
b/tests/qemu-iotests/tests/parallels-read-bitmap
new file mode 100755
index 00..af6b9c5db3
--- /dev/null
+++ b/tests/qemu-iotests/tests/parallels-read-bitmap
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+#
+# Test parallels load bitmap
+#
+# Copyright (c) 2021 Virtuozzo International GmbH.
+#
+# 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 json
+import iotests
+from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path
+
+iotests.script_initialize(supported_fmts=['parallels'])
+
+nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir)
+disk = iotests.file_path('disk')
+bitmap = 'e4f2eed0-37fe-4539-b50b-85d2e7fd235f'
+nbd_opts = f'driver=nbd,server.type=unix,server.path={nbd_sock}' \
+f',x-dirty-bitmap=qemu:dirty-bitmap:{bitmap}'
+
+
+iotests.unarchive_sample_image('parallels-with-bitmap', disk)
+
+
+with qemu_nbd_popen('--read-only', f'--socket={nbd_sock}',
+f'--bitmap={bitmap}', '-f', iotests.imgfmt, disk):
+out = qemu_img_pipe('map', '--output=json', '--image-opts', nbd_opts)
+chunks = json.loads(out)
+cluster = 64 * 1024
+
+log('dirty clusters (cluster size is 64K):')
+for c in chunks:
+assert c['start'] % cluster == 0
+assert c['length'] % cluster == 0
+if c['data']:
+continue
+
+a = c['start'] // cluster
+b = (c

Re: [PATCH v2 5/6] iotests.py: add unarchive_sample_image() helper

2021-02-24 Thread Denis V. Lunev
On 2/24/21 1:47 PM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  tests/qemu-iotests/iotests.py | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 4e758308f2..90d0b62523 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -17,6 +17,7 @@
>  #
>  
>  import atexit
> +import bz2
>  from collections import OrderedDict
>  import faulthandler
>  import io
> @@ -24,6 +25,7 @@
>  import logging
>  import os
>  import re
> +import shutil
>  import signal
>  import struct
>  import subprocess
> @@ -96,6 +98,14 @@
>   os.environ.get('IMGKEYSECRET', '')
>  luks_default_key_secret_opt = 'key-secret=keysec0'
>  
> +sample_img_dir = os.environ['SAMPLE_IMG_DIR']
> +
> +
> +def unarchive_sample_image(sample, fname):
> +sample_fname = os.path.join(sample_img_dir, sample + '.bz2')
> +with bz2.open(sample_fname) as f_in, open(fname, 'wb') as f_out:
> +shutil.copyfileobj(f_in, f_out)
> +
>  
>  def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
>connect_stderr: bool = True) -> Tuple[str, 
> int]:
Reviewed-by: Denis V. Lunev 



Re: [PATCH v2 2/6] parallels.txt: fix bitmap L1 table description

2021-02-24 Thread Denis V. Lunev
On 2/24/21 1:47 PM, Vladimir Sementsov-Ogievskiy wrote:
> Actually L1 table entry offset is in 512 bytes sectors. Fix the spec.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  docs/interop/parallels.txt | 27 +++
>  1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/docs/interop/parallels.txt b/docs/interop/parallels.txt
> index f15bf35bd1..73af9a2c4b 100644
> --- a/docs/interop/parallels.txt
> +++ b/docs/interop/parallels.txt
> @@ -208,21 +208,24 @@ of its data area are:
>28 - 31:l1_size
>The number of entries in the L1 table of the bitmap.
>  
> -  variable:   l1_table (8 * l1_size bytes)
> -  L1 offset table (in bytes)
> +  variable:   L1 offset table (l1_table), size: 8 * l1_size bytes
>  
> -A dirty bitmap is stored using a one-level structure for the mapping to host
> -clusters - an L1 table.
> +Dirty bitmap is stored in the array of clusters inside Parallels Image file.
> +Offsets of these clusters are saved in L1 offset table here. Each L1 table
> +entry is a 64bit integer described below:
>  
> -Given an offset in bytes into the bitmap data, the offset in bytes into the
> -image file can be obtained as follows:
> +Given an offset in bytes into the bitmap data, corresponding L1 entry is
>  
> -offset = l1_table[offset / cluster_size] + (offset % cluster_size)
> +l1_table[offset / cluster_size]
>  
> -If an L1 table entry is 0, the corresponding cluster of the bitmap is assumed
> -to be zero.
> +If L1 table entry is 0, all bits in the corresponding cluster of the bitmap
> +are assumed to be 0.
>  
> -If an L1 table entry is 1, the corresponding cluster of the bitmap is assumed
> -to have all bits set.
> +If L1 table entry is 1, all bits in the corresponding cluster of the bitmap
> +are assumed to be 1.
>  
> -If an L1 table entry is not 0 or 1, it allocates a cluster from the data 
> area.
> +If an L1 table entry is not 0 or 1, it contains corresponding cluster offset
> +(in 512b sectors). Given an offset in bytes into the bitmap data the offset 
> in
> +bytes into the image file can be obtained as follows:
> +
> +offset = l1_table[offset / cluster_size] * 512 + (offset % cluster_size)
Reviewed-by: Denis V. Lunev 



[PATCH v2 5/6] iotests.py: add unarchive_sample_image() helper

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/iotests.py | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 4e758308f2..90d0b62523 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -17,6 +17,7 @@
 #
 
 import atexit
+import bz2
 from collections import OrderedDict
 import faulthandler
 import io
@@ -24,6 +25,7 @@
 import logging
 import os
 import re
+import shutil
 import signal
 import struct
 import subprocess
@@ -96,6 +98,14 @@
  os.environ.get('IMGKEYSECRET', '')
 luks_default_key_secret_opt = 'key-secret=keysec0'
 
+sample_img_dir = os.environ['SAMPLE_IMG_DIR']
+
+
+def unarchive_sample_image(sample, fname):
+sample_fname = os.path.join(sample_img_dir, sample + '.bz2')
+with bz2.open(sample_fname) as f_in, open(fname, 'wb') as f_out:
+shutil.copyfileobj(f_in, f_out)
+
 
 def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
   connect_stderr: bool = True) -> Tuple[str, int]:
-- 
2.29.2




[PATCH v2 4/6] parallels: support bitmap extension for read-only mode

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 block/parallels.h |   6 +-
 block/parallels-ext.c | 300 ++
 block/parallels.c |  18 +++
 block/meson.build |   3 +-
 4 files changed, 325 insertions(+), 2 deletions(-)
 create mode 100644 block/parallels-ext.c

diff --git a/block/parallels.h b/block/parallels.h
index 9a9209e320..f22f43f988 100644
--- a/block/parallels.h
+++ b/block/parallels.h
@@ -48,7 +48,8 @@ typedef struct ParallelsHeader {
 uint64_t nb_sectors;
 uint32_t inuse;
 uint32_t data_off;
-char padding[12];
+uint32_t flags;
+uint64_t ext_off;
 } QEMU_PACKED ParallelsHeader;
 
 typedef enum ParallelsPreallocMode {
@@ -85,4 +86,7 @@ typedef struct BDRVParallelsState {
 Error *migration_blocker;
 } BDRVParallelsState;
 
+int parallels_read_format_extension(BlockDriverState *bs,
+int64_t ext_off, Error **errp);
+
 #endif
diff --git a/block/parallels-ext.c b/block/parallels-ext.c
new file mode 100644
index 00..e0dd0975c6
--- /dev/null
+++ b/block/parallels-ext.c
@@ -0,0 +1,300 @@
+/*
+ * Support of Parallels Format Extension. It's a part of Parallels format
+ * driver.
+ *
+ * Copyright (c) 2021 Virtuozzo International GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "block/block_int.h"
+#include "parallels.h"
+#include "crypto/hash.h"
+#include "qemu/uuid.h"
+
+#define PARALLELS_FORMAT_EXTENSION_MAGIC 0xAB234CEF23DCEA87ULL
+
+#define PARALLELS_END_OF_FEATURES_MAGIC 0x0ULL
+#define PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC 0x20385FAE252CB34AULL
+
+typedef struct ParallelsFormatExtensionHeader {
+uint64_t magic; /* PARALLELS_FORMAT_EXTENSION_MAGIC */
+uint8_t check_sum[16];
+} QEMU_PACKED ParallelsFormatExtensionHeader;
+
+typedef struct ParallelsFeatureHeader {
+uint64_t magic;
+uint64_t flags;
+uint32_t data_size;
+uint32_t _unused;
+} QEMU_PACKED ParallelsFeatureHeader;
+
+typedef struct ParallelsDirtyBitmapFeature {
+uint64_t size;
+uint8_t id[16];
+uint32_t granularity;
+uint32_t l1_size;
+/* L1 table follows */
+} QEMU_PACKED ParallelsDirtyBitmapFeature;
+
+/* Given L1 table read bitmap data from the image and populate @bitmap */
+static int parallels_load_bitmap_data(BlockDriverState *bs,
+  const uint64_t *l1_table,
+  uint32_t l1_size,
+  BdrvDirtyBitmap *bitmap,
+  Error **errp)
+{
+BDRVParallelsState *s = bs->opaque;
+int ret = 0;
+uint64_t offset, limit;
+uint64_t bm_size = bdrv_dirty_bitmap_size(bitmap);
+uint8_t *buf = NULL;
+uint64_t i, tab_size =
+DIV_ROUND_UP(bdrv_dirty_bitmap_serialization_size(bitmap, 0, bm_size),
+ s->cluster_size);
+
+if (tab_size != l1_size) {
+error_setg(errp, "Bitmap table size %" PRIu32 " does not correspond "
+   "to bitmap size and cluster size. Expected %" PRIu64,
+   l1_size, tab_size);
+return -EINVAL;
+}
+
+buf = qemu_blockalign(bs, s->cluster_size);
+limit = bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bitmap);
+for (i = 0, offset = 0; i < tab_size; ++i, offset += limit) {
+uint64_t count = MIN(bm_size - offset, limit);
+uint64_t entry = l1_table[i];
+
+if (entry == 0) {
+/* No need to deserialize zeros because @bitmap is cleared. */
+continue;
+}
+
+if (entry == 1) {
+bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, false);
+} else {
+ret = bdrv_pread(bs->file, entry << BDRV_SECTOR_BITS, buf,
+ s->cluster_size);
+if (ret < 0) {
+error_setg_errno(errp, -ret,
+   

[PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
We are going to use it in more places, calculating
"s->tracks << BDRV_SECTOR_BITS" doesn't look good.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 block/parallels.h | 1 +
 block/parallels.c | 8 
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/block/parallels.h b/block/parallels.h
index 5aa101cfc8..9a9209e320 100644
--- a/block/parallels.h
+++ b/block/parallels.h
@@ -79,6 +79,7 @@ typedef struct BDRVParallelsState {
 ParallelsPreallocMode prealloc_mode;
 
 unsigned int tracks;
+unsigned int cluster_size;
 
 unsigned int off_multiplier;
 Error *migration_blocker;
diff --git a/block/parallels.c b/block/parallels.c
index 3c22dfdc9d..9594d84978 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -421,7 +421,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState 
*bs,
 int ret;
 uint32_t i;
 bool flush_bat = false;
-int cluster_size = s->tracks << BDRV_SECTOR_BITS;
 
 size = bdrv_getlength(bs->file->bs);
 if (size < 0) {
@@ -472,7 +471,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState 
*bs,
 high_off = off;
 }
 
-if (prev_off != 0 && (prev_off + cluster_size) != off) {
+if (prev_off != 0 && (prev_off + s->cluster_size) != off) {
 res->bfi.fragmented_clusters++;
 }
 prev_off = off;
@@ -487,10 +486,10 @@ static int coroutine_fn 
parallels_co_check(BlockDriverState *bs,
 }
 }
 
-res->image_end_offset = high_off + cluster_size;
+res->image_end_offset = high_off + s->cluster_size;
 if (size > res->image_end_offset) {
 int64_t count;
-count = DIV_ROUND_UP(size - res->image_end_offset, cluster_size);
+count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
 fprintf(stderr, "%s space leaked at the end of the image %" PRId64 
"\n",
 fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR",
 size - res->image_end_offset);
@@ -771,6 +770,7 @@ static int parallels_open(BlockDriverState *bs, QDict 
*options, int flags,
 ret = -EFBIG;
 goto fail;
 }
+s->cluster_size = s->tracks << BDRV_SECTOR_BITS;
 
 s->bat_size = le32_to_cpu(ph.bat_entries);
 if (s->bat_size > INT_MAX / sizeof(uint32_t)) {
-- 
2.29.2




[PATCH v2 1/6] qcow2-bitmap: make bytes_covered_by_bitmap_cluster() public

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
Rename bytes_covered_by_bitmap_cluster() to
bdrv_dirty_bitmap_serialization_coverage() and make it public.
It is needed as we are going to share it with bitmap loading in
parallels format.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Reviewed-by: Denis V. Lunev 
---
 include/block/dirty-bitmap.h |  2 ++
 block/dirty-bitmap.c | 13 +
 block/qcow2-bitmap.c | 16 ++--
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 36e8da4fc2..f581cf9fd7 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -57,6 +57,8 @@ void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter);
 uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap,
   uint64_t offset, uint64_t bytes);
 uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap);
+uint64_t bdrv_dirty_bitmap_serialization_coverage(int serialized_chunk_size,
+const BdrvDirtyBitmap *bitmap);
 void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
   uint8_t *buf, uint64_t offset,
   uint64_t bytes);
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 9b9cd71238..a0eaa28785 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -726,6 +726,19 @@ uint64_t bdrv_dirty_bitmap_serialization_align(const 
BdrvDirtyBitmap *bitmap)
 return hbitmap_serialization_align(bitmap->bitmap);
 }
 
+/* Return the disk size covered by a chunk of serialized bitmap data. */
+uint64_t bdrv_dirty_bitmap_serialization_coverage(int serialized_chunk_size,
+  const BdrvDirtyBitmap 
*bitmap)
+{
+uint64_t granularity = bdrv_dirty_bitmap_granularity(bitmap);
+uint64_t limit = granularity * (serialized_chunk_size << 3);
+
+assert(QEMU_IS_ALIGNED(limit,
+   bdrv_dirty_bitmap_serialization_align(bitmap)));
+return limit;
+}
+
+
 void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
   uint8_t *buf, uint64_t offset,
   uint64_t bytes)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 5eef82fa55..42d81c44cd 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -278,18 +278,6 @@ static int free_bitmap_clusters(BlockDriverState *bs, 
Qcow2BitmapTable *tb)
 return 0;
 }
 
-/* Return the disk size covered by a single qcow2 cluster of bitmap data. */
-static uint64_t bytes_covered_by_bitmap_cluster(const BDRVQcow2State *s,
-const BdrvDirtyBitmap *bitmap)
-{
-uint64_t granularity = bdrv_dirty_bitmap_granularity(bitmap);
-uint64_t limit = granularity * (s->cluster_size << 3);
-
-assert(QEMU_IS_ALIGNED(limit,
-   bdrv_dirty_bitmap_serialization_align(bitmap)));
-return limit;
-}
-
 /* load_bitmap_data
  * @bitmap_table entries must satisfy specification constraints.
  * @bitmap must be cleared */
@@ -312,7 +300,7 @@ static int load_bitmap_data(BlockDriverState *bs,
 }
 
 buf = g_malloc(s->cluster_size);
-limit = bytes_covered_by_bitmap_cluster(s, bitmap);
+limit = bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bitmap);
 for (i = 0, offset = 0; i < tab_size; ++i, offset += limit) {
 uint64_t count = MIN(bm_size - offset, limit);
 uint64_t entry = bitmap_table[i];
@@ -1303,7 +1291,7 @@ static uint64_t *store_bitmap_data(BlockDriverState *bs,
 }
 
 buf = g_malloc(s->cluster_size);
-limit = bytes_covered_by_bitmap_cluster(s, bitmap);
+limit = bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bitmap);
 assert(DIV_ROUND_UP(bm_size, limit) == tb_size);
 
 offset = 0;
-- 
2.29.2




[PATCH v2 2/6] parallels.txt: fix bitmap L1 table description

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
Actually L1 table entry offset is in 512 bytes sectors. Fix the spec.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 docs/interop/parallels.txt | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/docs/interop/parallels.txt b/docs/interop/parallels.txt
index f15bf35bd1..73af9a2c4b 100644
--- a/docs/interop/parallels.txt
+++ b/docs/interop/parallels.txt
@@ -208,21 +208,24 @@ of its data area are:
   28 - 31:l1_size
   The number of entries in the L1 table of the bitmap.
 
-  variable:   l1_table (8 * l1_size bytes)
-  L1 offset table (in bytes)
+  variable:   L1 offset table (l1_table), size: 8 * l1_size bytes
 
-A dirty bitmap is stored using a one-level structure for the mapping to host
-clusters - an L1 table.
+Dirty bitmap is stored in the array of clusters inside Parallels Image file.
+Offsets of these clusters are saved in L1 offset table here. Each L1 table
+entry is a 64bit integer described below:
 
-Given an offset in bytes into the bitmap data, the offset in bytes into the
-image file can be obtained as follows:
+Given an offset in bytes into the bitmap data, corresponding L1 entry is
 
-offset = l1_table[offset / cluster_size] + (offset % cluster_size)
+l1_table[offset / cluster_size]
 
-If an L1 table entry is 0, the corresponding cluster of the bitmap is assumed
-to be zero.
+If L1 table entry is 0, all bits in the corresponding cluster of the bitmap
+are assumed to be 0.
 
-If an L1 table entry is 1, the corresponding cluster of the bitmap is assumed
-to have all bits set.
+If L1 table entry is 1, all bits in the corresponding cluster of the bitmap
+are assumed to be 1.
 
-If an L1 table entry is not 0 or 1, it allocates a cluster from the data area.
+If an L1 table entry is not 0 or 1, it contains corresponding cluster offset
+(in 512b sectors). Given an offset in bytes into the bitmap data the offset in
+bytes into the image file can be obtained as follows:
+
+offset = l1_table[offset / cluster_size] * 512 + (offset % cluster_size)
-- 
2.29.2




[PATCH v2 0/6] parallels: load bitmap extension

2021-02-24 Thread Vladimir Sementsov-Ogievskiy
Hi all!

We need to load bitmaps from parallels image in our product.
So here is a feature.

v2:
01: tweak commit message, add r-bs by Eric and Denis
02: tweak wording by Denis's suggestions
03: new, suggested by Denis
04: rebase on 03, add several error checking,
convert l1 table to cpu from small-endian,
allow loading several bitmaps
06: add copyright, drop "/work/mega"

Vladimir Sementsov-Ogievskiy (6):
  qcow2-bitmap: make bytes_covered_by_bitmap_cluster() public
  parallels.txt: fix bitmap L1 table description
  block/parallels: BDRVParallelsState: add cluster_size field
  parallels: support bitmap extension for read-only mode
  iotests.py: add unarchive_sample_image() helper
  iotests: add parallels-read-bitmap test

 docs/interop/parallels.txt|  27 +-
 block/parallels.h |   7 +-
 include/block/dirty-bitmap.h  |   2 +
 block/dirty-bitmap.c  |  13 +
 block/parallels-ext.c | 300 ++
 block/parallels.c |  26 +-
 block/qcow2-bitmap.c  |  16 +-
 block/meson.build |   3 +-
 tests/qemu-iotests/iotests.py |  10 +
 .../sample_images/parallels-with-bitmap.bz2   | Bin 0 -> 203 bytes
 .../sample_images/parallels-with-bitmap.sh|  51 +++
 .../qemu-iotests/tests/parallels-read-bitmap  |  55 
 .../tests/parallels-read-bitmap.out   |   6 +
 13 files changed, 484 insertions(+), 32 deletions(-)
 create mode 100644 block/parallels-ext.c
 create mode 100644 tests/qemu-iotests/sample_images/parallels-with-bitmap.bz2
 create mode 100755 tests/qemu-iotests/sample_images/parallels-with-bitmap.sh
 create mode 100755 tests/qemu-iotests/tests/parallels-read-bitmap
 create mode 100644 tests/qemu-iotests/tests/parallels-read-bitmap.out

-- 
2.29.2




Re: [PATCH v3] virtio-blk: Respect discard granularity

2021-02-24 Thread Stefano Garzarella

+Cc stefa...@redhat.com

Please explain a bit the changes in the commit message, for example that 
you added 'report-discard-granularity', disabled it for older machines, 
that we use blk_size as default granularity, etc.


Something like this:

Report the configured granularity for discard operation to the 
guest. If this is not set use the block size.


Since until now we have ignored the configured discard granularity 
and always reported the block size, let's add 
'report-discard-granularity' property and disable it for older 
machine types to avoid migration issues.


And use ./scripts/get_maintainer.pl to CC all the maintainers (e.g.  
Stefan Hajnoczi was missing)


Other than that, the patch LGTM.

Thanks,
Stefano

On Tue, Feb 23, 2021 at 09:09:40PM +0900, Akihiko Odaki wrote:

Signed-off-by: Akihiko Odaki 
---
hw/block/virtio-blk.c  | 8 +++-
hw/core/machine.c  | 4 +++-
include/hw/virtio/virtio-blk.h | 1 +
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index bac2d6fa2b2..f4378e61182 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -962,10 +962,14 @@ static void virtio_blk_update_config(VirtIODevice *vdev, 
uint8_t *config)
blkcfg.wce = blk_enable_write_cache(s->blk);
virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues);
if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_DISCARD)) {
+uint32_t discard_granularity = conf->discard_granularity;
+if (discard_granularity == -1 || !s->conf.report_discard_granularity) {
+discard_granularity = blk_size;
+}
virtio_stl_p(vdev, &blkcfg.max_discard_sectors,
 s->conf.max_discard_sectors);
virtio_stl_p(vdev, &blkcfg.discard_sector_alignment,
- blk_size >> BDRV_SECTOR_BITS);
+ discard_granularity >> BDRV_SECTOR_BITS);
/*
 * We support only one segment per request since multiple segments
 * are not widely used and there are no userspace APIs that allow
@@ -1299,6 +1303,8 @@ static Property virtio_blk_properties[] = {
 IOThread *),
DEFINE_PROP_BIT64("discard", VirtIOBlock, host_features,
  VIRTIO_BLK_F_DISCARD, true),
+DEFINE_PROP_BOOL("report-discard-granularity", VirtIOBlock,
+ conf.report_discard_granularity, true),
DEFINE_PROP_BIT64("write-zeroes", VirtIOBlock, host_features,
  VIRTIO_BLK_F_WRITE_ZEROES, true),
DEFINE_PROP_UINT32("max-discard-sectors", VirtIOBlock,
diff --git a/hw/core/machine.c b/hw/core/machine.c
index de3b8f1b318..e4df5797e72 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -33,7 +33,9 @@
#include "migration/global_state.h"
#include "migration/vmstate.h"

-GlobalProperty hw_compat_5_2[] = {};
+GlobalProperty hw_compat_5_2[] = {
+{ "virtio-blk-device", "report-discard-granularity", "off" },
+};
const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);

GlobalProperty hw_compat_5_1[] = {
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 214ab748229..29655a406dd 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -41,6 +41,7 @@ struct VirtIOBlkConf
uint16_t num_queues;
uint16_t queue_size;
bool seg_max_adjust;
+bool report_discard_granularity;
uint32_t max_discard_sectors;
uint32_t max_write_zeroes_sectors;
bool x_enable_wce_if_config_wce;
--
2.24.3 (Apple Git-128)