Re: [RFC PATCH 00/17] hw/sd: Rework models for eMMC support
Hello, On 3/18/22 14:28, Cédric Le Goater wrote: Hello Philippe, I am restarting the discussion we started in : http://patchwork.ozlabs.org/project/qemu-devel/list/?series=250563 This series adds an extension for a new eMMC device using the framework you put in place. It's not perfect but we are getting close. The SPI variant would need its own class I suppose and there are more cleanups to be done in the set of commands. Please comment ! Since patch 01-09 are nearly all reviewed, may be we could start by merging those ? Thanks, C.
[PATCH 0/6] scsi: add support for FORMAT UNIT command and quirks
Here are the next set of patches from my ongoing work to allow the q800 machine to boot MacOS related to SCSI devices. The first patch implements a dummy FORMAT UNIT command which is used by the Apple HD SC Setup program when preparing an empty disk to install MacOS. Patches 2 adds a new quirks bitmap to SCSIDiskState to allow buggy and/or legacy features to enabled on an individual device basis. Once the quirks bitmap has been added, patch 3 uses the quirks feature to implement an Apple-specific mode page which is required to allow the disk to be recognised and used by Apple HD SC Setup. Patch 4 adds compat_props to the q800 machine which enable the MODE_PAGE_APPLE quirk for all scsi-hd devices attached to the machine. Finally patches 5 and 6 augment the compat_props to set the default vendor, product and version information for all scsi-hd and scsi-cd devices attached to the q800 machine, taken from real drives. This is because MacOS will only allow a known set of SCSI devices to be recognised during the installation process. Signed-off-by: Mark Cave-Ayland Mark Cave-Ayland (6): scsi-disk: add FORMAT UNIT command scsi-disk: add new quirks bitmap to SCSIDiskState scsi-disk: add MODE_PAGE_APPLE quirk for Macintosh q800: implement compat_props to enable quirk_mode_page_apple for scsi-hd devices q800: add default vendor, product and version information for scsi-hd devices q800: add default vendor, product and version information for scsi-cd devices hw/m68k/q800.c | 12 hw/scsi/scsi-disk.c | 24 hw/scsi/trace-events | 1 + include/hw/scsi/scsi.h | 3 +++ include/scsi/constants.h | 1 + 5 files changed, 41 insertions(+) -- 2.20.1
[PATCH 2/6] scsi-disk: add new quirks bitmap to SCSIDiskState
Since the MacOS SCSI implementation is quite old (and Apple added some firmware customisations to their drives for m68k Macs) there is need to add a mechanism to correctly handle Apple-specific quirks. Add a new quirks bitmap to SCSIDiskState that can be used to enable these features as required. Signed-off-by: Mark Cave-Ayland --- hw/scsi/scsi-disk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 090679f3b5..d89cdd4e4a 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -94,6 +94,7 @@ struct SCSIDiskState { uint16_t port_index; uint64_t max_unmap_size; uint64_t max_io_size; +uint32_t quirks; QEMUBH *bh; char *version; char *serial; -- 2.20.1
[PATCH 4/6] q800: implement compat_props to enable quirk_mode_page_apple for scsi-hd devices
By default quirk_mode_page_apple should be enabled for all scsi-hd devices connected to the q800 machine to enable MacOS to detect and use them. Signed-off-by: Mark Cave-Ayland --- hw/m68k/q800.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 099a758c6f..cfab0c54fc 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -686,6 +686,11 @@ static void q800_init(MachineState *machine) } } +static GlobalProperty hw_compat_q800[] = { +{ "scsi-hd", "quirk_mode_page_apple", "on"}, +}; +static const size_t hw_compat_q800_len = G_N_ELEMENTS(hw_compat_q800); + static void q800_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -695,6 +700,7 @@ static void q800_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus = 1; mc->block_default_type = IF_SCSI; mc->default_ram_id = "m68k_mac.ram"; +compat_props_add(mc->compat_props, hw_compat_q800, hw_compat_q800_len); } static const TypeInfo q800_machine_typeinfo = { -- 2.20.1
[PATCH 5/6] q800: add default vendor, product and version information for scsi-hd devices
The Apple HD SC Setup program uses a SCSI INQUIRY command to check that any SCSI hard disks detected match a whitelist of vendors and products before allowing the "Initialise" button to prepare an empty disk. Add known-good default vendor and product information using the existing compat_prop mechanism so the user doesn't have to use long command lines to set the qdev properties manually. Signed-off-by: Mark Cave-Ayland --- hw/m68k/q800.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index cfab0c54fc..a5d20bb64b 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -688,6 +688,9 @@ static void q800_init(MachineState *machine) static GlobalProperty hw_compat_q800[] = { { "scsi-hd", "quirk_mode_page_apple", "on"}, +{ "scsi-hd", "vendor", " SEAGATE" }, +{ "scsi-hd", "product", " ST225N" }, +{ "scsi-hd", "ver", "1.0 " }, }; static const size_t hw_compat_q800_len = G_N_ELEMENTS(hw_compat_q800); -- 2.20.1
[PATCH 1/6] scsi-disk: add FORMAT UNIT command
When initialising a drive ready to install MacOS, Apple HD SC Setup first attempts to format the drive. Add a simple FORMAT UNIT command which simply returns success to allow the format to succeed. Signed-off-by: Mark Cave-Ayland --- hw/scsi/scsi-disk.c | 4 hw/scsi/trace-events | 1 + 2 files changed, 5 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 072686ed58..090679f3b5 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2127,6 +2127,9 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf) trace_scsi_disk_emulate_command_WRITE_SAME( req->cmd.buf[0] == WRITE_SAME_10 ? 10 : 16, r->req.cmd.xfer); break; +case FORMAT_UNIT: +trace_scsi_disk_emulate_command_FORMAT_UNIT(r->req.cmd.xfer); +break; default: trace_scsi_disk_emulate_command_UNKNOWN(buf[0], scsi_command_name(buf[0])); @@ -2533,6 +2536,7 @@ static const SCSIReqOps *const scsi_disk_reqops_dispatch[256] = { [VERIFY_10] = &scsi_disk_emulate_reqops, [VERIFY_12] = &scsi_disk_emulate_reqops, [VERIFY_16] = &scsi_disk_emulate_reqops, +[FORMAT_UNIT] = &scsi_disk_emulate_reqops, [READ_6] = &scsi_disk_dma_reqops, [READ_10] = &scsi_disk_dma_reqops, diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index 20fb0dc162..e91b55a961 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -334,6 +334,7 @@ scsi_disk_emulate_command_UNMAP(size_t xfer) "Unmap (len %zd)" scsi_disk_emulate_command_VERIFY(int bytchk) "Verify (bytchk %d)" scsi_disk_emulate_command_WRITE_SAME(int cmd, size_t xfer) "WRITE SAME %d (len %zd)" scsi_disk_emulate_command_UNKNOWN(int cmd, const char *name) "Unknown SCSI command (0x%2.2x=%s)" +scsi_disk_emulate_command_FORMAT_UNIT(size_t xfer) "Format Unit (len %zd)" scsi_disk_dma_command_READ(uint64_t lba, uint32_t len) "Read (sector %" PRId64 ", count %u)" scsi_disk_dma_command_WRITE(const char *cmd, uint64_t lba, int len) "Write %s(sector %" PRId64 ", count %u)" scsi_disk_new_request(uint32_t lun, uint32_t tag, const char *line) "Command: lun=%d tag=0x%x data=%s" -- 2.20.1
[PATCH 3/6] scsi-disk: add MODE_PAGE_APPLE quirk for Macintosh
One of the mechanisms MacOS uses to identify drives compatible with MacOS is to send a custom MODE SELECT command for page 0x30 to the drive. The response to this is a hard-coded manufacturer string which must match in order for the drive to be usable within MacOS. Add an implementation of the MODE SELECT page 0x30 response guarded by a newly defined SCSI_DISK_QUIRK_MODE_PAGE_APPLE quirk bit so that drives attached to non-Apple machines function exactly as before. Signed-off-by: Mark Cave-Ayland --- hw/scsi/scsi-disk.c | 19 +++ include/hw/scsi/scsi.h | 3 +++ include/scsi/constants.h | 1 + 3 files changed, 23 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index d89cdd4e4a..37013756d5 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1085,6 +1085,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, [MODE_PAGE_R_W_ERROR] = (1 << TYPE_DISK) | (1 << TYPE_ROM), [MODE_PAGE_AUDIO_CTL] = (1 << TYPE_ROM), [MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM), +[MODE_PAGE_APPLE] = (1 << TYPE_ROM), }; uint8_t *p = *p_outbuf + 2; @@ -1229,6 +1230,22 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, p[19] = (16 * 176) & 0xff; break; + case MODE_PAGE_APPLE: +if (s->qdev.type == TYPE_DISK && +(s->quirks & SCSI_DISK_QUIRK_MODE_PAGE_APPLE)) { + +length = 0x24; +if (page_control == 1) { /* Changeable Values */ +break; +} + +memset(p, 0, length); +strcpy((char *)p + 8, "APPLE COMPUTER, INC "); +break; +} else { +return -1; +} + default: return -1; } @@ -3042,6 +3059,8 @@ static Property scsi_hd_properties[] = { DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_version, 5), +DEFINE_PROP_BIT("quirk_mode_page_apple", SCSIDiskState, quirks, +SCSI_DISK_QUIRK_MODE_PAGE_APPLE, 0), DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 1ffb367f94..f629706250 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -226,4 +226,7 @@ SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, int target, int lun); /* scsi-generic.c. */ extern const SCSIReqOps scsi_generic_req_ops; +/* scsi-disk.c */ +#define SCSI_DISK_QUIRK_MODE_PAGE_APPLE 0 + #endif diff --git a/include/scsi/constants.h b/include/scsi/constants.h index 2a32c08b5e..21ca7b50cd 100644 --- a/include/scsi/constants.h +++ b/include/scsi/constants.h @@ -234,6 +234,7 @@ #define MODE_PAGE_FAULT_FAIL 0x1c #define MODE_PAGE_TO_PROTECT 0x1d #define MODE_PAGE_CAPABILITIES0x2a +#define MODE_PAGE_APPLE 0x30 #define MODE_PAGE_ALLS0x3f /* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor * of MODE_PAGE_SENSE_POWER */ -- 2.20.1
[PATCH 6/6] q800: add default vendor, product and version information for scsi-cd devices
The MacOS CDROM driver uses a SCSI INQUIRY command to check that any SCSI CDROMs detected match a whitelist of vendors and products before adding them to the list of available devices. Add known-good default vendor and product information using the existing compat_prop mechanism so the user doesn't have to use long command lines to set the qdev properties manually. Signed-off-by: Mark Cave-Ayland --- hw/m68k/q800.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index a5d20bb64b..e050d45040 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -691,6 +691,9 @@ static GlobalProperty hw_compat_q800[] = { { "scsi-hd", "vendor", " SEAGATE" }, { "scsi-hd", "product", " ST225N" }, { "scsi-hd", "ver", "1.0 " }, +{ "scsi-cd", "vendor", "MATSHITA" }, +{ "scsi-cd", "product", "CD-ROM CR-8005" }, +{ "scsi-cd", "ver", "1.0k" }, }; static const size_t hw_compat_q800_len = G_N_ELEMENTS(hw_compat_q800); -- 2.20.1
Re: [PATCH 2/2] hw/nvme: fix copy cmd for pi enabled namespaces
On Wed, Apr 20, 2022 at 21:16:15, Klaus Jensen wrote: > Discussed this with the TP authors and, no, reftag should not be > re-computed for PRACT 0, regardless of the PI type. Ok, should i resend patch with only adding nvme_dif_mangle_mdata in the read part?
Re: [PATCH 2/2] hw/nvme: fix copy cmd for pi enabled namespaces
On Apr 21 10:41, Dmitry Tikhov wrote: > On Wed, Apr 20, 2022 at 21:16:15, Klaus Jensen wrote: > > Discussed this with the TP authors and, no, reftag should not be > > re-computed for PRACT 0, regardless of the PI type. > Ok, should i resend patch with only adding nvme_dif_mangle_mdata in > the read part? Yes, that is still a bug :) signature.asc Description: PGP signature
Re: [PATCH 02/26] qcow2: remove incorrect coroutine_fn annotations
On Tue, Apr 19, 2022 at 01:07:19PM -0500, Eric Blake wrote: > On Fri, Apr 15, 2022 at 03:18:36PM +0200, Paolo Bonzini wrote: > > Signed-off-by: Paolo Bonzini > > --- > > Again, a sentence on why this is correct would be helpful. > > > block/qcow2-refcount.c | 4 ++-- > > block/qcow2.h | 4 ++-- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > > index b91499410c..b6f90b2702 100644 > > --- a/block/qcow2-refcount.c > > +++ b/block/qcow2-refcount.c > > @@ -1206,7 +1206,7 @@ void qcow2_free_any_cluster(BlockDriverState *bs, > > uint64_t l2_entry, > > } > > } > > > > -int coroutine_fn qcow2_write_caches(BlockDriverState *bs) > > +int qcow2_write_caches(BlockDriverState *bs) > > { > > BDRVQcow2State *s = bs->opaque; > > int ret; > > @@ -1226,7 +1226,7 @@ int coroutine_fn qcow2_write_caches(BlockDriverState > > *bs) > > return 0; > > } > > > > -int coroutine_fn qcow2_flush_caches(BlockDriverState *bs) > > +int qcow2_flush_caches(BlockDriverState *bs) > > { > > int ret = qcow2_write_caches(bs); > > Both of these eventually hit qcow2_cache_write, which is not marked > coroutine, so these should not be either. coroutine_fn may call non-coroutine_fn, so this alone is not a reason for removing it from qcow2_write_caches(). There must be a call chain where qcow2_write_caches() and qcow2_flush_caches() are is invoked from outside coroutine_fn. Stefan signature.asc Description: PGP signature
Re: [PATCH 01/26] block: remove incorrect coroutine_fn annotations
On Tue, Apr 19, 2022 at 12:57:54PM -0500, Eric Blake wrote: > On Fri, Apr 15, 2022 at 03:18:35PM +0200, Paolo Bonzini wrote: > > Signed-off-by: Paolo Bonzini > > Might be nice to document in the commit message why the annotation was > incorrect, so someone stumbling across this commit in a bisect but > otherwise unfamiliar with the rules of when to annotate doesn't get > lost. If I understand right, the argument is more-or-less: > > This function defers to the generated blk_do_pwritev_part, which is > safe to call outside coroutine context. > > But although the commit message is weak, the change itself appears > correct from what I have observed with the annotation in other places. > > Reviewed-by: Eric Blake Yes, please! I'm also wondering how to review a patch like this because I can only infer the meaning and audit the code myself to check my guess. Stefan signature.asc Description: PGP signature
[PATCH v2] hw/nvme: fix copy cmd for pi enabled namespaces
Current implementation have problem in the read part of copy command. Because there is no metadata mangling before nvme_dif_check invocation, reftag error could be thrown for blocks of namespace that have not been previously written to. Signed-off-by: Dmitry Tikhov --- v2: * remove refactoring * remove write part fix --- hw/nvme/ctrl.c | 4 1 file changed, 4 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 74540a03d5..08574c4dcb 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2787,6 +2787,10 @@ static void nvme_copy_in_completed_cb(void *opaque, int ret) size_t mlen = nvme_m2b(ns, nlb); uint8_t *mbounce = iocb->bounce + nvme_l2b(ns, nlb); +status = nvme_dif_mangle_mdata(ns, mbounce, mlen, slba); +if (status) { +goto invalid; +} status = nvme_dif_check(ns, iocb->bounce, len, mbounce, mlen, prinfor, slba, apptag, appmask, &reftag); if (status) { -- 2.35.1
Re: [PATCH 2/3] iotests: 314 test on duplicated clusters (parallels format)
On Mon, Apr 18, 2022 at 02:04:29PM +0300, Natalia Kuzmina wrote: > Reading from duplicated offset and from original offset returns > the same data. After repairing changing either of these > blocks of data does not affect another one. > > Signed-off-by: Natalia Kuzmina > --- > tests/qemu-iotests/314| 88 ++ > tests/qemu-iotests/314.out| 36 +++ > .../parallels-2-duplicated-cluster.bz2| Bin 0 -> 148 bytes > 3 files changed, 124 insertions(+) > create mode 100755 tests/qemu-iotests/314 > create mode 100644 tests/qemu-iotests/314.out > create mode 100644 > tests/qemu-iotests/sample_images/parallels-2-duplicated-cluster.bz2 Reviewed-by: Stefan Hajnoczi signature.asc Description: PGP signature
Re: [PATCH 00/19] block: fix coroutine_fn annotations
On Fri, Apr 15, 2022 at 03:18:34PM +0200, Paolo Bonzini wrote: > This is the initial result of reviving Marc-André's series at > https://patchew.org/QEMU/20170704220346.29244-1-marcandre.lur...@redhat.com/. > A lot of the patches are similar to the ones that Marc-André wrote, > but due to the changes in the code it was easier to redo them. > > For nbd, the patch is on top of "nbd: mark more coroutine_fns" that > I sent a few days ago and that (AIUI) Eric has already queued; only > one function was missing, much to my surprise. > > Apart from this, I also identified the following functions that > can be called both in coroutine context and outside: > > - qmp_dispatch > - schedule_next_request > - nvme_get_free_req > - bdrv_create > - bdrv_remove_persistent_dirty_bitmap > - bdrv_can_store_new_dirty_bitmap > - bdrv_do_drained_begin > - bdrv_do_drained_end > - bdrv_drain_all_begin > - qcow2_open > - qcow2_has_zero_init > - bdrv_qed_open > - qio_channel_readv_full_all_eof > - qio_channel_writev_full_all > > besides, of course, everything that is generated by > scripts/block-coroutine-wrapper.py. This looks useful, thanks for bringing it back! As Eric mentioned, the commits need justifications. The following cases come to mind: 1. Add coroutine_fn because the function calls a function that is marked with coroutine_fn. This must be fixed because it can lead to crashes. 2. Remove coroutine_fn because the function does not call any functions marked with coroutine_fn. This is optional because it does not lead to crashes and maybe the author intended to be explicit that this function runs only in coroutine context even though it doesn't yield. 3. Variants of these cases but related to runtime qemu_in_coroutine() checks. Functions should not have coroutine_fn if they legitimately are called in both contexts. Any calls to coroutine_fn child functions must be conditional on qemu_in_coroutine() or something else that indicates whether we are running in coroutine context. Stefan signature.asc Description: PGP signature
Re: [PATCH 04/26] coroutine: remove incorrect coroutine_fn annotations
On Fri, Apr 15, 2022 at 03:18:38PM +0200, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini > --- > include/qemu/coroutine.h | 2 +- > util/qemu-coroutine.c| 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) This one is easy to audit because the implementation of qemu_coroutine_get_aio_context() definitely does not require running in coroutine context. :) Reviewed-by: Stefan Hajnoczi signature.asc Description: PGP signature
Re: [PATCH 3/6] scsi-disk: add MODE_PAGE_APPLE quirk for Macintosh
On 2022-04-21 07:51, Mark Cave-Ayland wrote: > One of the mechanisms MacOS uses to identify drives compatible with MacOS is > to > send a custom MODE SELECT command for page 0x30 to the drive. The response to > this is a hard-coded manufacturer string which must match in order for the > drive to be usable within MacOS. > > Add an implementation of the MODE SELECT page 0x30 response guarded by a newly > defined SCSI_DISK_QUIRK_MODE_PAGE_APPLE quirk bit so that drives attached > to non-Apple machines function exactly as before. > > Signed-off-by: Mark Cave-Ayland > --- > hw/scsi/scsi-disk.c | 19 +++ > include/hw/scsi/scsi.h | 3 +++ > include/scsi/constants.h | 1 + > 3 files changed, 23 insertions(+) > > diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c > index d89cdd4e4a..37013756d5 100644 > --- a/hw/scsi/scsi-disk.c > +++ b/hw/scsi/scsi-disk.c > @@ -1085,6 +1085,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, > uint8_t **p_outbuf, > [MODE_PAGE_R_W_ERROR] = (1 << TYPE_DISK) | (1 << > TYPE_ROM), > [MODE_PAGE_AUDIO_CTL] = (1 << TYPE_ROM), > [MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM), > +[MODE_PAGE_APPLE] = (1 << TYPE_ROM), > }; > > uint8_t *p = *p_outbuf + 2; > @@ -1229,6 +1230,22 @@ static int mode_sense_page(SCSIDiskState *s, int page, > uint8_t **p_outbuf, > p[19] = (16 * 176) & 0xff; > break; > > + case MODE_PAGE_APPLE: > +if (s->qdev.type == TYPE_DISK && > +(s->quirks & SCSI_DISK_QUIRK_MODE_PAGE_APPLE)) { This is always false. SCSI_DISK_QUIRK_MODE_PAGE_APPLE is defined 0. You need (1 << SCSI_DISK_QUIRK_MODE_PAGE_APPLE) instead. > + > +length = 0x24; > +if (page_control == 1) { /* Changeable Values */ > +break; > +} > + > +memset(p, 0, length); > +strcpy((char *)p + 8, "APPLE COMPUTER, INC "); > +break; > +} else { > +return -1; > +} > + > default: > return -1; > } > @@ -3042,6 +3059,8 @@ static Property scsi_hd_properties[] = { > DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), > DEFINE_PROP_INT32("scsi_version", SCSIDiskState, > qdev.default_scsi_version, >5), > +DEFINE_PROP_BIT("quirk_mode_page_apple", SCSIDiskState, quirks, > +SCSI_DISK_QUIRK_MODE_PAGE_APPLE, 0), > DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf), > DEFINE_PROP_END_OF_LIST(), > }; > diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h > index 1ffb367f94..f629706250 100644 > --- a/include/hw/scsi/scsi.h > +++ b/include/hw/scsi/scsi.h > @@ -226,4 +226,7 @@ SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, > int target, int lun); > /* scsi-generic.c. */ > extern const SCSIReqOps scsi_generic_req_ops; > > +/* scsi-disk.c */ > +#define SCSI_DISK_QUIRK_MODE_PAGE_APPLE 0 > + > #endif > diff --git a/include/scsi/constants.h b/include/scsi/constants.h > index 2a32c08b5e..21ca7b50cd 100644 > --- a/include/scsi/constants.h > +++ b/include/scsi/constants.h > @@ -234,6 +234,7 @@ > #define MODE_PAGE_FAULT_FAIL 0x1c > #define MODE_PAGE_TO_PROTECT 0x1d > #define MODE_PAGE_CAPABILITIES0x2a > +#define MODE_PAGE_APPLE 0x30 > #define MODE_PAGE_ALLS0x3f > /* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor > * of MODE_PAGE_SENSE_POWER */ > -- > 2.20.1 > > Fam
[PULL 05/30] include: rename qemu-common.h qemu/help-texts.h
From: Marc-André Lureau Suggested-by: Peter Maydell Signed-off-by: Marc-André Lureau Reviewed-by: Warner Losh Message-Id: <20220420132624.2439741-7-marcandre.lur...@redhat.com> --- include/{qemu-common.h => qemu/help-texts.h} | 0 bsd-user/main.c | 2 +- linux-user/main.c| 2 +- qemu-img.c | 2 +- qemu-io.c| 2 +- qemu-nbd.c | 2 +- qga/main.c | 2 +- scsi/qemu-pr-helper.c| 2 +- softmmu/vl.c | 2 +- storage-daemon/qemu-storage-daemon.c | 2 +- tools/virtiofsd/passthrough_ll.c | 2 +- ui/cocoa.m | 2 +- 12 files changed, 11 insertions(+), 11 deletions(-) rename include/{qemu-common.h => qemu/help-texts.h} (100%) diff --git a/include/qemu-common.h b/include/qemu/help-texts.h similarity index 100% rename from include/qemu-common.h rename to include/qemu/help-texts.h diff --git a/bsd-user/main.c b/bsd-user/main.c index 74f2d35a5497..6f09180d6541 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -24,7 +24,7 @@ #include #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qemu/units.h" #include "qemu/accel.h" #include "qemu-version.h" diff --git a/linux-user/main.c b/linux-user/main.c index 5fb6ecac3f86..7ca48664e447 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -18,7 +18,7 @@ */ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qemu/units.h" #include "qemu/accel.h" #include "qemu-version.h" diff --git a/qemu-img.c b/qemu-img.c index ef3224a9d4a8..6337a63b3b80 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qemu/qemu-progress.h" #include "qemu-version.h" #include "qapi/error.h" diff --git a/qemu-io.c b/qemu-io.c index 38321a27a301..d70d3dd4fde5 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -15,7 +15,7 @@ #include #endif -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qapi/error.h" #include "qemu-io.h" #include "qemu/error-report.h" diff --git a/qemu-nbd.c b/qemu-nbd.c index bf9c5fedceba..397ffa64d768 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -21,7 +21,7 @@ #include #include -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "sysemu/block-backend.h" diff --git a/qga/main.c b/qga/main.c index 1deb0ee2fbfe..e4b22df01dcd 100644 --- a/qga/main.c +++ b/qga/main.c @@ -18,7 +18,7 @@ #include #include #endif -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 1f2a84c53454..df493e2a503e 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -36,7 +36,7 @@ #include #endif -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" diff --git a/softmmu/vl.c b/softmmu/vl.c index f679d48d7415..2a38ebe5fbb4 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -23,7 +23,7 @@ */ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qemu/datadir.h" #include "qemu/units.h" #include "exec/cpu-common.h" diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c index 1398f0443d76..9b8b17f52e48 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -42,7 +42,7 @@ #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h" -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qemu-version.h" #include "qemu/config-file.h" #include "qemu/error-report.h" diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c index 028dacdd8f5a..b15c631ca512 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -38,7 +38,7 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "qemu-version.h" -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "fuse_virtio.h" #include "fuse_log.h" #include "fuse_lowlevel.h" diff --git a/ui/cocoa.m b/ui/cocoa.m index 839ae4f58a69..68bff4ff3796 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -27,7 +27,7 @@ #import #include -#include "qemu-common.h" +#include "qemu/help-texts.h" #include "qemu-main.h" #include "ui/clipboard.h" #include "ui/console.h" -- 2.36.0
[PULL 13/30] compiler.h: replace QEMU_NORETURN with G_NORETURN
From: Marc-André Lureau G_NORETURN was introduced in glib 2.68, fallback to G_GNUC_NORETURN in glib-compat. Note that this attribute must be placed before the function declaration (bringing a bit of consistency in qemu codebase usage). Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Reviewed-by: Warner Losh Message-Id: <20220420132624.2439741-20-marcandre.lur...@redhat.com> --- accel/tcg/internal.h | 3 +-- include/exec/exec-all.h | 20 +- include/exec/helper-head.h | 2 +- include/glib-compat.h| 4 include/hw/core/cpu.h| 2 +- include/hw/core/tcg-cpu-ops.h| 6 +++--- include/hw/hw.h | 2 +- include/qemu/compiler.h | 2 -- include/qemu/osdep.h | 3 ++- include/qemu/thread.h| 2 +- include/tcg/tcg-ldst.h | 4 ++-- include/tcg/tcg.h| 2 +- linux-user/user-internals.h | 2 +- scripts/cocci-macro-file.h | 2 +- target/alpha/cpu.h | 10 - target/arm/internals.h | 12 +-- target/hppa/cpu.h| 2 +- target/i386/tcg/helper-tcg.h | 24 ++--- target/microblaze/cpu.h | 6 +++--- target/mips/tcg/tcg-internal.h | 17 --- target/nios2/cpu.h | 6 +++--- target/openrisc/exception.h | 2 +- target/ppc/cpu.h | 14 ++--- target/ppc/internal.h| 6 +++--- target/riscv/cpu.h | 10 - target/s390x/s390x-internal.h| 6 +++--- target/s390x/tcg/tcg_s390x.h | 12 +-- target/sh4/cpu.h | 6 +++--- target/sparc/cpu.h | 10 - target/xtensa/cpu.h | 6 +++--- accel/stubs/tcg-stub.c | 4 ++-- bsd-user/signal.c| 3 ++- hw/misc/mips_itu.c | 3 ++- linux-user/signal.c | 3 ++- monitor/hmp.c| 4 ++-- qemu-img.c | 12 +++ target/alpha/helper.c| 10 - target/arm/pauth_helper.c| 4 ++-- target/arm/tlb_helper.c | 7 --- target/hexagon/op_helper.c | 9 target/hppa/cpu.c| 8 +++ target/hppa/op_helper.c | 4 ++-- target/i386/tcg/bpt_helper.c | 2 +- target/i386/tcg/excp_helper.c| 31 ++-- target/i386/tcg/misc_helper.c| 6 +++--- target/i386/tcg/sysemu/misc_helper.c | 7 --- target/openrisc/exception.c | 2 +- target/openrisc/exception_helper.c | 3 ++- target/riscv/op_helper.c | 4 ++-- target/rx/op_helper.c| 22 +++- target/s390x/tcg/excp_helper.c | 22 +++- target/sh4/op_helper.c | 5 +++-- target/sparc/mmu_helper.c| 8 +++ target/tricore/op_helper.c | 6 +++--- tcg/tcg.c| 3 ++- tests/fp/fp-bench.c | 3 ++- tests/fp/fp-test.c | 3 ++- scripts/checkpatch.pl| 2 +- 58 files changed, 214 insertions(+), 191 deletions(-) diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h index 881bc1ede0b1..3092bfa96430 100644 --- a/accel/tcg/internal.h +++ b/accel/tcg/internal.h @@ -14,8 +14,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, uint32_t flags, int cflags); - -void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr); +G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr); void page_init(void); void tb_htable_init(void); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index d2cb0981f405..311e5fb422a3 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -58,10 +58,10 @@ void restore_state_to_opc(CPUArchState *env, TranslationBlock *tb, */ bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc, bool will_exit); -void QEMU_NORETURN cpu_loop_exit_noexc(CPUState *cpu); -void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); -void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); -void QEMU_NORETURN cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc); +G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); +G_NORETURN void cpu_loop_exit(CPUState *cpu); +G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); +G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc); /** * cpu_loop_exit_requested: @@ -669,9 +669,9 @@ bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, * Use the TCGCPUOps hook to record cpu state, do guest operating system * specific things to raise SIGSEGV, and ju
[PULL 17/30] include: move qdict_{crumple,flatten} declarations
From: Marc-André Lureau Move them where they belong, since the functions are implemented in block-qdict.c. Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Message-Id: <20220420132624.2439741-25-marcandre.lur...@redhat.com> --- include/block/qdict.h | 3 +++ include/qapi/qmp/qdict.h | 3 --- softmmu/vl.c | 1 + tests/unit/check-qobject.c | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/block/qdict.h b/include/block/qdict.h index ced2acfb92a0..b4c28d96a9e5 100644 --- a/include/block/qdict.h +++ b/include/block/qdict.h @@ -12,6 +12,9 @@ #include "qapi/qmp/qdict.h" +QObject *qdict_crumple(const QDict *src, Error **errp); +void qdict_flatten(QDict *qdict); + void qdict_copy_default(QDict *dst, QDict *src, const char *key); void qdict_set_default_str(QDict *dst, const char *key, const char *val); diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 882d950bde89..82e90fc07229 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -68,7 +68,4 @@ const char *qdict_get_try_str(const QDict *qdict, const char *key); QDict *qdict_clone_shallow(const QDict *src); -QObject *qdict_crumple(const QDict *src, Error **errp); -void qdict_flatten(QDict *qdict); - #endif /* QDICT_H */ diff --git a/softmmu/vl.c b/softmmu/vl.c index 5312bd25649f..06a0e342fe9e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -125,6 +125,7 @@ #include "qapi/qapi-visit-qom.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" +#include "block/qdict.h" #include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" #include "qemu/guest-random.h" diff --git a/tests/unit/check-qobject.c b/tests/unit/check-qobject.c index 0ed094e55f3a..c5e850a10cb5 100644 --- a/tests/unit/check-qobject.c +++ b/tests/unit/check-qobject.c @@ -15,6 +15,7 @@ #include "qapi/qmp/qnull.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" +#include "block/qdict.h" #include -- 2.36.0
[PULL 27/30] util: replace qemu_get_local_state_pathname()
From: Marc-André Lureau Simplify the function to only return the directory path. Callers are adjusted to use the GLib function to build paths, g_build_filename(). Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Message-Id: <20220420132624.2439741-39-marcandre.lur...@redhat.com> --- include/qemu/osdep.h | 9 +++-- qga/main.c| 8 scsi/qemu-pr-helper.c | 6 -- tools/virtiofsd/fuse_virtio.c | 4 +++- util/oslib-posix.c| 7 ++- util/oslib-win32.c| 5 ++--- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 4bf2883a60b3..baaa23c1568d 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -556,16 +556,13 @@ void qemu_set_cloexec(int fd); void fips_set_state(bool requested); bool fips_get_state(void); -/* Return a dynamically allocated pathname denoting a file or directory that is - * appropriate for storing local state. - * - * @relative_pathname need not start with a directory separator; one will be - * added automatically. +/* Return a dynamically allocated directory path that is appropriate for storing + * local state. * * The caller is responsible for releasing the value returned with g_free() * after use. */ -char *qemu_get_local_state_pathname(const char *relative_pathname); +char *qemu_get_local_state_dir(void); /* Find program directory, and save it for later usage with * qemu_get_exec_dir(). diff --git a/qga/main.c b/qga/main.c index aa00ad8fabdf..3c20bf1fbfe0 100644 --- a/qga/main.c +++ b/qga/main.c @@ -129,12 +129,12 @@ static void stop_agent(GAState *s, bool requested); static void init_dfl_pathnames(void) { +g_autofree char *state = qemu_get_local_state_dir(); + g_assert(dfl_pathnames.state_dir == NULL); g_assert(dfl_pathnames.pidfile == NULL); -dfl_pathnames.state_dir = qemu_get_local_state_pathname( - QGA_STATE_RELATIVE_DIR); -dfl_pathnames.pidfile = qemu_get_local_state_pathname( - QGA_STATE_RELATIVE_DIR G_DIR_SEPARATOR_S "qemu-ga.pid"); +dfl_pathnames.state_dir = g_build_filename(state, QGA_STATE_RELATIVE_DIR, NULL); +dfl_pathnames.pidfile = g_build_filename(state, QGA_STATE_RELATIVE_DIR, "qemu-ga.pid", NULL); } static void quit_handler(int sig) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index df493e2a503e..196b78c00df5 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -77,8 +77,10 @@ static int gid = -1; static void compute_default_paths(void) { -socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock"); -pidfile = qemu_get_local_state_pathname("run/qemu-pr-helper.pid"); +g_autofree char *state = qemu_get_local_state_dir(); + +socket_path = g_build_filename(state, "run", "qemu-pr-helper.sock", NULL); +pidfile = g_build_filename(state, "run", "qemu-pr-helper.pid", NULL); } static void usage(const char *name) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 60b96470c51a..a52eacf82e1e 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -901,10 +901,12 @@ static bool fv_socket_lock(struct fuse_session *se) { g_autofree gchar *sk_name = NULL; g_autofree gchar *pidfile = NULL; +g_autofree gchar *state = NULL; g_autofree gchar *dir = NULL; Error *local_err = NULL; -dir = qemu_get_local_state_pathname("run/virtiofsd"); +state = qemu_get_local_state_dir(); +dir = g_build_filename(state, "run", "virtiofsd", NULL); if (g_mkdir_with_parents(dir, S_IRWXU) < 0) { fuse_log(FUSE_LOG_ERR, "%s: Failed to create directory %s: %s\n", diff --git a/util/oslib-posix.c b/util/oslib-posix.c index bcb35c3c8246..b8bf7d4070ce 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -297,12 +297,9 @@ int qemu_pipe(int pipefd[2]) } char * -qemu_get_local_state_pathname(const char *relative_pathname) +qemu_get_local_state_dir(void) { -g_autofree char *dir = g_strdup_printf("%s/%s", - CONFIG_QEMU_LOCALSTATEDIR, - relative_pathname); -return get_relocated_path(dir); +return get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR); } void qemu_set_tty_echo(int fd, bool echo) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index b897d759365f..9c1e8121fd6d 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -235,7 +235,7 @@ int qemu_get_thread_id(void) } char * -qemu_get_local_state_pathname(const char *relative_pathname) +qemu_get_local_state_dir(void) { HRESULT result; char base_path[MAX_PATH+1] = ""; @@ -247,8 +247,7 @@ qemu_get_local_state_pathname(const char *relative_pathname) g_critical("CSIDL_COMMON_APPDATA unavailable: %ld", (long)result); abort(); } -return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", base_path, - rel
[PATCH] iotests/108: Fix when missing user_allow_other
FUSE exports' allow-other option defaults to "auto", which means that it will try passing allow_other as a mount option, and fall back to not using it when an error occurs. We make no effort to hide fusermount's error message (because it would be difficult, and because users might want to know about the fallback occurring), and so when allow_other does not work (primarily when /etc/fuse.conf does not contain user_allow_other), this error message will appear and break the reference output. We do not need allow_other here, though, so we can just pass allow-other=off to fix that. Reported-by: Markus Armbruster Signed-off-by: Hanna Reitz --- tests/qemu-iotests/108 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 index 688d3ae8f6..9e923d6a59 100755 --- a/tests/qemu-iotests/108 +++ b/tests/qemu-iotests/108 @@ -326,7 +326,7 @@ else $QSD \ --blockdev file,node-name=export-node,filename="$TEST_IMG" \ ---export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off \ +--export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off,allow-other=off \ --pidfile "$TEST_DIR/qsd.pid" \ --daemonize fi -- 2.35.1
Re: introducing vrc :)
On 4/20/22 20:12, Peter Xu wrote: a while ago I looked at tools that could be used too build a call graph. The simplest but most effective that I found was a small Perl program (called "egypt", which is rot13 for "rtlcg" aka RTL call graph) that used the GCC dumps to build the graph. Do you have any plan to put it into some git repository? Good idea, it's now at https://github.com/bonzini/vrc. It can be installed using "pip install --user ." after checking out the repository. Paolo
[PULL 02/17] scripts/bench-block-job: switch to AQMP
For this commit, we only need to remove accommodations for the synchronous QMP library. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Acked-by: Hanna Reitz Message-id: 20220321203315.909411-3-js...@redhat.com Signed-off-by: John Snow --- scripts/simplebench/bench_block_job.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/bench_block_job.py index a403c35b08f..af9d1646a46 100755 --- a/scripts/simplebench/bench_block_job.py +++ b/scripts/simplebench/bench_block_job.py @@ -27,7 +27,6 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu.machine import QEMUMachine -from qemu.qmp import QMPConnectError from qemu.aqmp import ConnectError @@ -50,7 +49,7 @@ def bench_block_job(cmd, cmd_args, qemu_args): vm.launch() except OSError as e: return {'error': 'popen failed: ' + str(e)} -except (QMPConnectError, ConnectError, socket.timeout): +except (ConnectError, socket.timeout): return {'error': 'qemu failed: ' + str(vm.get_log())} try: -- 2.34.1
[PULL 07/17] python/qmp-shell: relicense as LGPLv2+
qmp-shell is presently licensed as GPLv2 (only). I intend to include this tool as an add-on to an LGPLv2+ library package hosted on PyPI.org. I've selected LGPLv2+ to maximize compatibility with other licenses while retaining a copyleft license. To keep licensing matters simple, I'd like to relicense this tool as LGPLv2+ as well in order to keep the resultant license of the hosted release files simple -- even if library users won't "link against" this command line tool. Therefore, I am asking permission from the current authors of this tool to loosen the license. At present, those people are: - John Snow (me!), 411/609 - Luiz Capitulino, Author, 97/609 - Daniel Berrangé, 81/609 - Eduardo Habkost, 10/609 - Marc-André Lureau, 6/609 - Fam Zheng, 3/609 - Cleber Rosa, 1/609 (All of which appear to have been written under redhat.com addresses.) Eduardo's fixes are largely automated from 2to3 conversion tools and may not necessarily constitute authorship, but his signature would put to rest any questions. Cleber's changes concern a single import statement change. Also won't hurt to ask. Signed-off-by: John Snow Reviewed-by: Marc-André Lureau Acked-by: Fam Zheng Acked-by: Luiz Capitulino Acked-by: Eduardo Habkost Acked-by: Daniel P. Berrangé Acked-by: Cleber Rosa Message-id: 20220325200438.2556381-4-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/qmp_shell.py | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/qemu/aqmp/qmp_shell.py b/python/qemu/aqmp/qmp_shell.py index 35691494d0a..c23f1b19280 100644 --- a/python/qemu/aqmp/qmp_shell.py +++ b/python/qemu/aqmp/qmp_shell.py @@ -1,11 +1,12 @@ # -# Copyright (C) 2009, 2010 Red Hat Inc. +# Copyright (C) 2009-2022 Red Hat Inc. # # Authors: # Luiz Capitulino +# John Snow # -# This work is licensed under the terms of the GNU GPL, version 2. See -# the COPYING file in the top-level directory. +# This work is licensed under the terms of the GNU LGPL, version 2 or +# later. See the COPYING file in the top-level directory. # """ -- 2.34.1
[PULL 00/17] Python patches
The following changes since commit b1efff6bf031a93b5b8bf3912ddc720cc1653a61: Merge tag 'pull-ppc-20220420-2' of https://gitlab.com/danielhb/qemu into staging (2022-04-20 21:54:24 -0700) are available in the Git repository at: https://gitlab.com/jsnow/qemu.git tags/python-pull-request for you to fetch changes up to 47430775ed1a48d7beb2c7b8d7feaab73104ec46: python/qmp: remove pylint workaround from legacy.py (2022-04-21 11:01:00 -0400) Python patches This PR finalizes the switch from Luiz's QMP library to mine. John Snow (17): python/machine: permanently switch to AQMP scripts/bench-block-job: switch to AQMP iotests/mirror-top-perms: switch to AQMP iotests: switch to AQMP python/aqmp: add explicit GPLv2 license to legacy.py python/aqmp: relicense as LGPLv2+ python/qmp-shell: relicense as LGPLv2+ python/aqmp-tui: relicense as LGPLv2+ python: temporarily silence pylint duplicate-code warnings python/aqmp: take QMPBadPortError and parse_address from qemu.qmp python/aqmp: fully separate from qmp.QEMUMonitorProtocol python/aqmp: copy qmp docstrings to qemu.aqmp.legacy python: remove the old QMP package python: re-enable pylint duplicate-code warnings python: rename qemu.aqmp to qemu.qmp python: rename 'aqmp-tui' to 'qmp-tui' python/qmp: remove pylint workaround from legacy.py python/README.rst | 2 +- python/qemu/qmp/README.rst| 9 - python/qemu/aqmp/__init__.py | 59 --- python/qemu/aqmp/legacy.py| 177 --- python/qemu/aqmp/py.typed | 0 python/qemu/machine/machine.py| 18 +- python/qemu/machine/qtest.py | 2 +- python/qemu/qmp/__init__.py | 445 ++ python/qemu/{aqmp => qmp}/error.py| 0 python/qemu/{aqmp => qmp}/events.py | 2 +- python/qemu/qmp/legacy.py | 315 + python/qemu/{aqmp => qmp}/message.py | 0 python/qemu/{aqmp => qmp}/models.py | 0 python/qemu/{aqmp => qmp}/protocol.py | 4 +- python/qemu/{aqmp => qmp}/qmp_client.py | 16 +- python/qemu/{aqmp => qmp}/qmp_shell.py| 11 +- .../qemu/{aqmp/aqmp_tui.py => qmp/qmp_tui.py} | 17 +- python/qemu/{aqmp => qmp}/util.py | 0 python/qemu/utils/qemu_ga_client.py | 4 +- python/qemu/utils/qom.py | 2 +- python/qemu/utils/qom_common.py | 4 +- python/qemu/utils/qom_fuse.py | 2 +- python/setup.cfg | 11 +- python/tests/protocol.py | 14 +- scripts/cpu-x86-uarch-abi.py | 2 +- scripts/device-crash-test | 4 +- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp-shell-wrap| 2 +- scripts/render_block_graph.py | 4 +- scripts/simplebench/bench_block_job.py| 5 +- tests/qemu-iotests/iotests.py | 3 +- tests/qemu-iotests/tests/mirror-top-perms | 11 +- 32 files changed, 422 insertions(+), 725 deletions(-) delete mode 100644 python/qemu/qmp/README.rst delete mode 100644 python/qemu/aqmp/__init__.py delete mode 100644 python/qemu/aqmp/legacy.py delete mode 100644 python/qemu/aqmp/py.typed rename python/qemu/{aqmp => qmp}/error.py (100%) rename python/qemu/{aqmp => qmp}/events.py (99%) create mode 100644 python/qemu/qmp/legacy.py rename python/qemu/{aqmp => qmp}/message.py (100%) rename python/qemu/{aqmp => qmp}/models.py (100%) rename python/qemu/{aqmp => qmp}/protocol.py (99%) rename python/qemu/{aqmp => qmp}/qmp_client.py (97%) rename python/qemu/{aqmp => qmp}/qmp_shell.py (98%) rename python/qemu/{aqmp/aqmp_tui.py => qmp/qmp_tui.py} (98%) rename python/qemu/{aqmp => qmp}/util.py (100%) -- 2.34.1
[PULL 05/17] python/aqmp: add explicit GPLv2 license to legacy.py
The legacy.py module is heavily based on the QMP module by Luiz Capitulino (et al) which is licensed as explicit GPLv2-only. The async QMP package is currently licensed similarly, but I intend to relicense the async package to the more flexible LGPLv2+. In preparation for that change, make the license on legacy.py explicit. Signed-off-by: John Snow Message-id: 20220325200438.2556381-2-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 11 +++ 1 file changed, 11 insertions(+) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 46026e9fdc6..f86cb298049 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -4,6 +4,17 @@ This class pretends to be qemu.qmp.QEMUMonitorProtocol. """ +# +# Copyright (C) 2009-2022 Red Hat Inc. +# +# Authors: +# Luiz Capitulino +# John Snow +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# + import asyncio from typing import ( Any, -- 2.34.1
[PULL 03/17] iotests/mirror-top-perms: switch to AQMP
We don't have to maintain compatibility with both QMP libraries anymore, so we can just remove the old exception. While we're here, take advantage of the extra fields present in the VMLaunchFailure exception that machine.py now raises. (Note: I'm leaving the logging suppression here unchanged. I had suggested previously we use filters to scrub the PID out of the logging information so it could just be diffed as part of the iotest output, but that meant *always* scrubbing PID from logger output, which defeated the point of even offering that information in the output to begin with. Ultimately, I decided it's fine to just suppress the logger temporarily.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Acked-by: Hanna Reitz Message-id: 20220321203315.909411-4-js...@redhat.com Signed-off-by: John Snow --- tests/qemu-iotests/tests/mirror-top-perms | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests/tests/mirror-top-perms index 6ac8d5efccb..a9f275cd7f2 100755 --- a/tests/qemu-iotests/tests/mirror-top-perms +++ b/tests/qemu-iotests/tests/mirror-top-perms @@ -22,7 +22,6 @@ import os from qemu.machine import machine -from qemu.qmp import QMPConnectError import iotests from iotests import change_log_level, qemu_img @@ -98,15 +97,13 @@ class TestMirrorTopPerms(iotests.QMPTestCase): self.vm_b.add_blockdev(f'file,node-name=drive0,filename={source}') self.vm_b.add_device('virtio-blk,drive=drive0,share-rw=on') try: -# Silence AQMP errors temporarily. -# TODO: Remove this and just allow the errors to be logged when -# AQMP fully replaces QMP. +# Silence AQMP logging errors temporarily. with change_log_level('qemu.aqmp'): self.vm_b.launch() print('ERROR: VM B launched successfully, ' 'this should not have happened') -except (QMPConnectError, machine.VMLaunchFailure): -assert 'Is another process using the image' in self.vm_b.get_log() +except machine.VMLaunchFailure as exc: +assert 'Is another process using the image' in exc.output result = self.vm.qmp('block-job-cancel', device='mirror') -- 2.34.1
[PULL 09/17] python: temporarily silence pylint duplicate-code warnings
The next several commits copy some code from qemu.qmp to qemu.aqmp, then delete qemu.qmp. In the interim, to prevent test failures, the duplicate code detection needs to be silenced to prevent bisect problems with CI testing. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20220330172812.3427355-2-js...@redhat.com Signed-off-by: John Snow --- python/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.cfg b/python/setup.cfg index 241f243e8b9..cdeced44d2b 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -119,6 +119,7 @@ disable=consider-using-f-string, too-many-function-args, # mypy handles this with less false positives. too-many-instance-attributes, no-member, # mypy also handles this better. +duplicate-code, # To be removed by the end of this patch series. [pylint.basic] # Good variable names which should always be accepted, separated by a comma. -- 2.34.1
[PULL 08/17] python/aqmp-tui: relicense as LGPLv2+
aqmp-tui, the async QMP text user interface tool, is presently licensed as GPLv2+. I intend to include this tool as an add-on to an LGPLv2+ library package hosted on PyPI.org. I've selected LGPLv2+ to maximize compatibility with other licenses while retaining a copyleft license. To keep licensing matters simple, I'd like to relicense this tool as LGPLv2+ as well in order to keep the resultant license of the hosted release files simple -- even if library users won't "link against" this command line tool. Therefore, I am asking permission to loosen the license. Niteesh is effectively the sole author of this code, with scattered lines from myself. Signed-off-by: John Snow Reviewed-by: G S Niteesh Babu Message-id: 20220325200438.2556381-5-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/aqmp_tui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index f1e926dd756..946ba9af24e 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -3,7 +3,7 @@ # Authors: # Niteesh Babu G S # -# This work is licensed under the terms of the GNU GPL, version 2 or +# This work is licensed under the terms of the GNU LGPL, version 2 or # later. See the COPYING file in the top-level directory. """ AQMP TUI -- 2.34.1
[PULL 10/17] python/aqmp: take QMPBadPortError and parse_address from qemu.qmp
Shift these definitions over from the qmp package to the async qmp package. (Licensing: this is a lateral move, from GPLv2 (only) to GPLv2 (only)) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Message-id: 20220330172812.3427355-3-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/aqmp_tui.py | 3 +-- python/qemu/aqmp/legacy.py | 30 ++ python/qemu/qmp/__init__.py | 26 -- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index 946ba9af24e..59d3036be38 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -35,9 +35,8 @@ import urwid import urwid_readline -from qemu.qmp import QEMUMonitorProtocol, QMPBadPortError - from .error import ProtocolError +from .legacy import QEMUMonitorProtocol, QMPBadPortError from .message import DeserializationError, Message, UnexpectedTypeError from .protocol import ConnectError, Runstate from .qmp_client import ExecInterruptedError, QMPClient diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index f86cb298049..f0262749491 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -33,9 +33,6 @@ from .qmp_client import QMPClient -# (Temporarily) Re-export QMPBadPortError -QMPBadPortError = qemu.qmp.QMPBadPortError - #: QMPMessage is an entire QMP message of any kind. QMPMessage = Dict[str, Any] @@ -56,6 +53,12 @@ # pylint: disable=missing-docstring +class QMPBadPortError(QMPError): +""" +Unable to parse socket address: Port was non-numerical. +""" + + class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol): def __init__(self, address: SocketAddrT, server: bool = False, @@ -86,7 +89,26 @@ def _get_greeting(self) -> Optional[QMPMessage]: return None # __enter__ and __exit__ need no changes -# parse_address needs no changes + +@classmethod +def parse_address(cls, address: str) -> SocketAddrT: +""" +Parse a string into a QMP address. + +Figure out if the argument is in the port:host form. +If it's not, it's probably a file path. +""" +components = address.split(':') +if len(components) == 2: +try: +port = int(components[1]) +except ValueError: +msg = f"Bad port: '{components[1]}' in '{address}'." +raise QMPBadPortError(msg) from None +return (components[0], port) + +# Treat as filepath. +return address def connect(self, negotiate: bool = True) -> Optional[QMPMessage]: self._aqmp.await_greeting = negotiate diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 358c0971d06..4e086411544 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -102,12 +102,6 @@ def __init__(self, reply: QMPMessage): self.reply = reply -class QMPBadPortError(QMPError): -""" -Unable to parse socket address: Port was non-numerical. -""" - - class QEMUMonitorProtocol: """ Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and then @@ -237,26 +231,6 @@ def __exit__(self, # Implement context manager exit function. self.close() -@classmethod -def parse_address(cls, address: str) -> SocketAddrT: -""" -Parse a string into a QMP address. - -Figure out if the argument is in the port:host form. -If it's not, it's probably a file path. -""" -components = address.split(':') -if len(components) == 2: -try: -port = int(components[1]) -except ValueError: -msg = f"Bad port: '{components[1]}' in '{address}'." -raise QMPBadPortError(msg) from None -return (components[0], port) - -# Treat as filepath. -return address - def connect(self, negotiate: bool = True) -> Optional[QMPMessage]: """ Connect to the QMP Monitor and perform capabilities negotiation. -- 2.34.1
[PULL 13/17] python: remove the old QMP package
Thank you for your service! Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Message-id: 20220330172812.3427355-6-js...@redhat.com Signed-off-by: John Snow --- python/PACKAGE.rst | 4 +- python/README.rst | 2 +- python/qemu/qmp/README.rst | 9 - python/qemu/qmp/__init__.py | 396 python/qemu/qmp/py.typed| 0 python/setup.cfg| 3 +- 6 files changed, 4 insertions(+), 410 deletions(-) delete mode 100644 python/qemu/qmp/README.rst delete mode 100644 python/qemu/qmp/__init__.py delete mode 100644 python/qemu/qmp/py.typed diff --git a/python/PACKAGE.rst b/python/PACKAGE.rst index b0b86cc4c31..ddfa9ba3f59 100644 --- a/python/PACKAGE.rst +++ b/python/PACKAGE.rst @@ -8,11 +8,11 @@ to change at any time. Usage - -The ``qemu.qmp`` subpackage provides a library for communicating with +The ``qemu.aqmp`` subpackage provides a library for communicating with QMP servers. The ``qemu.machine`` subpackage offers rudimentary facilities for launching and managing QEMU processes. Refer to each package's documentation -(``>>> help(qemu.qmp)``, ``>>> help(qemu.machine)``) +(``>>> help(qemu.aqmp)``, ``>>> help(qemu.machine)``) for more information. Contributing diff --git a/python/README.rst b/python/README.rst index fcf74f69eae..eb5213337d2 100644 --- a/python/README.rst +++ b/python/README.rst @@ -3,7 +3,7 @@ QEMU Python Tooling This directory houses Python tooling used by the QEMU project to build, configure, and test QEMU. It is organized by namespace (``qemu``), and -then by package (e.g. ``qemu/machine``, ``qemu/qmp``, etc). +then by package (e.g. ``qemu/machine``, ``qemu/aqmp``, etc). ``setup.py`` is used by ``pip`` to install this tooling to the current environment. ``setup.cfg`` provides the packaging configuration used by diff --git a/python/qemu/qmp/README.rst b/python/qemu/qmp/README.rst deleted file mode 100644 index 5bfb82535f8..000 --- a/python/qemu/qmp/README.rst +++ /dev/null @@ -1,9 +0,0 @@ -qemu.qmp package - - -This package provides a library used for connecting to and communicating -with QMP servers. It is used extensively by iotests, vm tests, -avocado tests, and other utilities in the ./scripts directory. It is -not a fully-fledged SDK and is subject to change at any time. - -See the documentation in ``__init__.py`` for more information. diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py deleted file mode 100644 index 4e086411544..000 --- a/python/qemu/qmp/__init__.py +++ /dev/null @@ -1,396 +0,0 @@ -""" -QEMU Monitor Protocol (QMP) development library & tooling. - -This package provides a fairly low-level class for communicating to QMP -protocol servers, as implemented by QEMU, the QEMU Guest Agent, and the -QEMU Storage Daemon. This library is not intended for production use. - -`QEMUMonitorProtocol` is the primary class of interest, and all errors -raised derive from `QMPError`. -""" - -# Copyright (C) 2009, 2010 Red Hat Inc. -# -# Authors: -# Luiz Capitulino -# -# This work is licensed under the terms of the GNU GPL, version 2. See -# the COPYING file in the top-level directory. - -import errno -import json -import logging -import socket -import struct -from types import TracebackType -from typing import ( -Any, -Dict, -List, -Optional, -TextIO, -Tuple, -Type, -TypeVar, -Union, -cast, -) - - -#: QMPMessage is an entire QMP message of any kind. -QMPMessage = Dict[str, Any] - -#: QMPReturnValue is the 'return' value of a command. -QMPReturnValue = object - -#: QMPObject is any object in a QMP message. -QMPObject = Dict[str, object] - -# QMPMessage can be outgoing commands or incoming events/returns. -# QMPReturnValue is usually a dict/json object, but due to QAPI's -# 'returns-whitelist', it can actually be anything. -# -# {'return': {}} is a QMPMessage, -# {} is the QMPReturnValue. - - -InternetAddrT = Tuple[str, int] -UnixAddrT = str -SocketAddrT = Union[InternetAddrT, UnixAddrT] - - -class QMPError(Exception): -""" -QMP base exception -""" - - -class QMPConnectError(QMPError): -""" -QMP connection exception -""" - - -class QMPCapabilitiesError(QMPError): -""" -QMP negotiate capabilities exception -""" - - -class QMPTimeoutError(QMPError): -""" -QMP timeout exception -""" - - -class QMPProtocolError(QMPError): -""" -QMP protocol error; unexpected response -""" - - -class QMPResponseError(QMPError): -""" -Represents erroneous QMP monitor reply -""" -def __init__(self, reply: QMPMessage): -try: -desc = reply['error']['desc'] -except KeyError: -desc = reply -super().__init__(desc) -self.reply = reply - - -class QEMUMonitorProtocol: -""" -Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and then -al
[PULL 11/17] python/aqmp: fully separate from qmp.QEMUMonitorProtocol
After this patch, qemu.aqmp.legacy.QEMUMonitorProtocol no longer inherits from qemu.qmp.QEMUMonitorProtocol. To do this, several inherited methods need to be explicitly re-defined. (Licensing: This is copying and modifying GPLv2-only code into a GPLv2-only file.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Message-id: 20220330172812.3427355-4-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 37 +++-- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index f0262749491..10c7c99c4f0 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -16,18 +16,18 @@ # import asyncio +from types import TracebackType from typing import ( Any, Awaitable, Dict, List, Optional, +Type, TypeVar, Union, ) -import qemu.qmp - from .error import QMPError from .protocol import Runstate, SocketAddrT from .qmp_client import QMPClient @@ -59,12 +59,11 @@ class QMPBadPortError(QMPError): """ -class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol): +class QEMUMonitorProtocol: def __init__(self, address: SocketAddrT, server: bool = False, nickname: Optional[str] = None): -# pylint: disable=super-init-not-called self._aqmp = QMPClient(nickname) self._aloop = asyncio.get_event_loop() self._address = address @@ -88,7 +87,18 @@ def _get_greeting(self) -> Optional[QMPMessage]: return self._aqmp.greeting._asdict() return None -# __enter__ and __exit__ need no changes +def __enter__(self: _T) -> _T: +# Implement context manager enter function. +return self + +def __exit__(self, + # pylint: disable=duplicate-code + # see https://github.com/PyCQA/pylint/issues/3619 + exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + exc_tb: Optional[TracebackType]) -> None: +# Implement context manager exit function. +self.close() @classmethod def parse_address(cls, address: str) -> SocketAddrT: @@ -142,7 +152,22 @@ def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: ) ) -# Default impl of cmd() delegates to cmd_obj +def cmd(self, name: str, +args: Optional[Dict[str, object]] = None, +cmd_id: Optional[object] = None) -> QMPMessage: +""" +Build a QMP command and send it to the QMP Monitor. + +@param name: command name (string) +@param args: command arguments (dict) +@param cmd_id: command id (dict, list, string or int) +""" +qmp_cmd: QMPMessage = {'execute': name} +if args: +qmp_cmd['arguments'] = args +if cmd_id: +qmp_cmd['id'] = cmd_id +return self.cmd_obj(qmp_cmd) def command(self, cmd: str, **kwds: object) -> QMPReturnValue: return self._sync( -- 2.34.1
[PULL 17/17] python/qmp: remove pylint workaround from legacy.py
Pylint upgraded recently (2.13.z) and having a pylint: disable comment in the middle of an argument field causes it some grief (It appears to stop parsing when it encounters it, causing some syntax problems). Since the duplicate line threshold was bumped up in 22305c2a081b, we don't need this workaround anymore. Drop it. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20220330172812.3427355-10-js...@redhat.com Signed-off-by: John Snow --- python/qemu/qmp/legacy.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/qemu/qmp/legacy.py b/python/qemu/qmp/legacy.py index a8629b44dff..03b5574618f 100644 --- a/python/qemu/qmp/legacy.py +++ b/python/qemu/qmp/legacy.py @@ -106,8 +106,6 @@ def __enter__(self: _T) -> _T: return self def __exit__(self, - # pylint: disable=duplicate-code - # see https://github.com/PyCQA/pylint/issues/3619 exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: -- 2.34.1
[PULL 01/17] python/machine: permanently switch to AQMP
Remove the QEMU_PYTHON_LEGACY_QMP environment variable, making the switch from sync qmp to async qmp permanent. Update exceptions and import paths as necessary. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Acked-by: Hanna Reitz Message-id: 20220321203315.909411-2-js...@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 18 +++--- python/qemu/machine/qtest.py | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index a5972fab4d2..41be025ac7b 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -40,21 +40,16 @@ TypeVar, ) -from qemu.qmp import ( # pylint: disable=import-error +from qemu.aqmp import SocketAddrT +from qemu.aqmp.legacy import ( +QEMUMonitorProtocol, QMPMessage, QMPReturnValue, -SocketAddrT, ) from . import console_socket -if os.environ.get('QEMU_PYTHON_LEGACY_QMP'): -from qemu.qmp import QEMUMonitorProtocol -else: -from qemu.aqmp.legacy import QEMUMonitorProtocol - - LOG = logging.getLogger(__name__) @@ -743,8 +738,9 @@ def events_wait(self, :param timeout: Optional timeout, in seconds. See QEMUMonitorProtocol.pull_event. -:raise QMPTimeoutError: If timeout was non-zero and no matching events -were found. +:raise asyncio.TimeoutError: +If timeout was non-zero and no matching events were found. + :return: A QMP event matching the filter criteria. If timeout was 0 and no event matched, None. """ @@ -767,7 +763,7 @@ def _match(event: QMPMessage) -> bool: event = self._qmp.pull_event(wait=timeout) if event is None: # NB: None is only returned when timeout is false-ish. -# Timeouts raise QMPTimeoutError instead! +# Timeouts raise asyncio.TimeoutError instead! break if _match(event): return event diff --git a/python/qemu/machine/qtest.py b/python/qemu/machine/qtest.py index f2f9aaa5e50..13e0aaff846 100644 --- a/python/qemu/machine/qtest.py +++ b/python/qemu/machine/qtest.py @@ -26,7 +26,7 @@ TextIO, ) -from qemu.qmp import SocketAddrT # pylint: disable=import-error +from qemu.aqmp import SocketAddrT from .machine import QEMUMachine -- 2.34.1
[PULL 04/17] iotests: switch to AQMP
iotests is already using async QMP, but to finalize the switchover we only need to update any remaining import paths to rely solely on the new library instead. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Acked-by: Hanna Reitz Message-id: 20220321203315.909411-5-js...@redhat.com [Fixed minor rebase conflict. --js] Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index fe10a6cf05a..6f9aa38e0e8 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -37,9 +37,8 @@ from contextlib import contextmanager -from qemu.aqmp.legacy import QEMUMonitorProtocol +from qemu.aqmp.legacy import QMPMessage, QEMUMonitorProtocol from qemu.machine import qtest -from qemu.qmp import QMPMessage from qemu.utils import VerboseProcessError # Use this logger for logging messages directly from the iotests module -- 2.34.1
[PULL 06/17] python/aqmp: relicense as LGPLv2+
I am the sole author of all of the async QMP code (python/qemu/aqmp) with the following exceptions: python/qemu/aqmp/qmp_shell.py and python/qemu/aqmp/legacy.py were written by Luiz Capitulino (et al) and are already licensed separately as GPLv2 (only). aqmp_tui.py was written by Niteesh Babu G S and is licensed as GPLv2+. I wish to relicense as LGPLv2+ in order to provide as much flexibility as I reasonably can, while retaining a copyleft license. It is my belief that LGPLv2+ is a suitable license for the Python ecosystem that aligns with the goals and philosophy of the QEMU project. The intent is to eventually drop legacy.py, leaving only library code that is LGPLv2+. Signed-off-by: John Snow Message-id: 20220325200438.2556381-3-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/qemu/aqmp/__init__.py b/python/qemu/aqmp/__init__.py index 4c22c380790..2b69b264f4f 100644 --- a/python/qemu/aqmp/__init__.py +++ b/python/qemu/aqmp/__init__.py @@ -11,15 +11,15 @@ managing QMP events. """ -# Copyright (C) 2020, 2021 John Snow for Red Hat, Inc. +# Copyright (C) 2020-2022 John Snow for Red Hat, Inc. # # Authors: # John Snow # # Based on earlier work by Luiz Capitulino . # -# This work is licensed under the terms of the GNU GPL, version 2. See -# the COPYING file in the top-level directory. +# This work is licensed under the terms of the GNU LGPL, version 2 or +# later. See the COPYING file in the top-level directory. import logging -- 2.34.1
[PULL 12/17] python/aqmp: copy qmp docstrings to qemu.aqmp.legacy
Copy the docstrings out of qemu.qmp, adjusting them as necessary to more accurately reflect the current state of this class. (Licensing: This is copying and modifying GPLv2-only licensed docstrings into a GPLv2-only file.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Message-id: 20220330172812.3427355-5-js...@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 98 ++ 1 file changed, 90 insertions(+), 8 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 10c7c99c4f0..dfcd20bbd23 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -1,7 +1,13 @@ """ -Sync QMP Wrapper +(Legacy) Sync QMP Wrapper -This class pretends to be qemu.qmp.QEMUMonitorProtocol. +This module provides the `QEMUMonitorProtocol` class, which is a +synchronous wrapper around `QMPClient`. + +Its design closely resembles that of the original QEMUMonitorProtocol +class, originally written by Luiz Capitulino. It is provided here for +compatibility with scripts inside the QEMU source tree that expect the +old interface. """ # @@ -50,9 +56,6 @@ # {} is the QMPReturnValue. -# pylint: disable=missing-docstring - - class QMPBadPortError(QMPError): """ Unable to parse socket address: Port was non-numerical. @@ -60,6 +63,17 @@ class QMPBadPortError(QMPError): class QEMUMonitorProtocol: +""" +Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) +and then allow to handle commands and events. + +:param address: QEMU address, can be either a unix socket path (string) + or a tuple in the form ( address, port ) for a TCP + connection +:param server: Act as the socket server. (See 'accept') +:param nickname: Optional nickname used for logging. +""" + def __init__(self, address: SocketAddrT, server: bool = False, nickname: Optional[str] = None): @@ -121,6 +135,12 @@ def parse_address(cls, address: str) -> SocketAddrT: return address def connect(self, negotiate: bool = True) -> Optional[QMPMessage]: +""" +Connect to the QMP Monitor and perform capabilities negotiation. + +:return: QMP greeting dict, or None if negotiate is false +:raise ConnectError: on connection errors +""" self._aqmp.await_greeting = negotiate self._aqmp.negotiate = negotiate @@ -130,6 +150,16 @@ def connect(self, negotiate: bool = True) -> Optional[QMPMessage]: return self._get_greeting() def accept(self, timeout: Optional[float] = 15.0) -> QMPMessage: +""" +Await connection from QMP Monitor and perform capabilities negotiation. + +:param timeout: +timeout in seconds (nonnegative float number, or None). +If None, there is no timeout, and this may block forever. + +:return: QMP greeting dict +:raise ConnectError: on connection errors +""" self._aqmp.await_greeting = True self._aqmp.negotiate = True @@ -140,6 +170,12 @@ def accept(self, timeout: Optional[float] = 15.0) -> QMPMessage: return ret def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: +""" +Send a QMP command to the QMP Monitor. + +:param qmp_cmd: QMP command to be sent as a Python dict +:return: QMP response as a Python dict +""" return dict( self._sync( # pylint: disable=protected-access @@ -158,9 +194,9 @@ def cmd(self, name: str, """ Build a QMP command and send it to the QMP Monitor. -@param name: command name (string) -@param args: command arguments (dict) -@param cmd_id: command id (dict, list, string or int) +:param name: command name (string) +:param args: command arguments (dict) +:param cmd_id: command id (dict, list, string or int) """ qmp_cmd: QMPMessage = {'execute': name} if args: @@ -170,6 +206,9 @@ def cmd(self, name: str, return self.cmd_obj(qmp_cmd) def command(self, cmd: str, **kwds: object) -> QMPReturnValue: +""" +Build and send a QMP command to the monitor, report errors if any +""" return self._sync( self._aqmp.execute(cmd, kwds), self._timeout @@ -177,6 +216,19 @@ def command(self, cmd: str, **kwds: object) -> QMPReturnValue: def pull_event(self, wait: Union[bool, float] = False) -> Optional[QMPMessage]: +""" +Pulls a single event. + +:param wait: +If False or 0, do not wait. Return None if no events ready. +If True, wait forever until the next event. +Otherwise, wait for the specified number of seconds. + +:raise asyncio.TimeoutError: +When
[PULL 14/17] python: re-enable pylint duplicate-code warnings
With the old library gone, there's nothing duplicated in the tree, so the warning suppression can be removed. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal Message-id: 20220330172812.3427355-7-js...@redhat.com Signed-off-by: John Snow --- python/setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/python/setup.cfg b/python/setup.cfg index 4340c29a24f..49e3c285f19 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -118,7 +118,6 @@ disable=consider-using-f-string, too-many-function-args, # mypy handles this with less false positives. too-many-instance-attributes, no-member, # mypy also handles this better. -duplicate-code, # To be removed by the end of this patch series. [pylint.basic] # Good variable names which should always be accepted, separated by a comma. -- 2.34.1
[PULL 16/17] python: rename 'aqmp-tui' to 'qmp-tui'
This is the last vestige of the "aqmp" moniker surviving in the tree; remove it. Signed-off-by: John Snow Reviewed-by: Beraldo Leal Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20220330172812.3427355-9-js...@redhat.com Signed-off-by: John Snow --- python/qemu/qmp/{aqmp_tui.py => qmp_tui.py} | 12 ++-- python/setup.cfg| 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) rename python/qemu/qmp/{aqmp_tui.py => qmp_tui.py} (98%) diff --git a/python/qemu/qmp/aqmp_tui.py b/python/qemu/qmp/qmp_tui.py similarity index 98% rename from python/qemu/qmp/aqmp_tui.py rename to python/qemu/qmp/qmp_tui.py index 59d3036be38..ce239d8979b 100644 --- a/python/qemu/qmp/aqmp_tui.py +++ b/python/qemu/qmp/qmp_tui.py @@ -6,13 +6,13 @@ # This work is licensed under the terms of the GNU LGPL, version 2 or # later. See the COPYING file in the top-level directory. """ -AQMP TUI +QMP TUI -AQMP TUI is an asynchronous interface built on top the of the AQMP library. +QMP TUI is an asynchronous interface built on top the of the QMP library. It is the successor of QMP-shell and is bought-in as a replacement for it. -Example Usage: aqmp-tui -Full Usage: aqmp-tui --help +Example Usage: qmp-tui +Full Usage: qmp-tui --help """ import argparse @@ -129,7 +129,7 @@ def has_handler_type(logger: logging.Logger, class App(QMPClient): """ -Implements the AQMP TUI. +Implements the QMP TUI. Initializes the widgets and starts the urwid event loop. @@ -612,7 +612,7 @@ def main() -> None: Driver of the whole script, parses arguments, initialize the TUI and the logger. """ -parser = argparse.ArgumentParser(description='AQMP TUI') +parser = argparse.ArgumentParser(description='QMP TUI') parser.add_argument('qmp_server', help='Address of the QMP server. ' 'Format ') parser.add_argument('--num-retries', type=int, default=10, diff --git a/python/setup.cfg b/python/setup.cfg index 773e51b34e7..e877ea56475 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -51,7 +51,7 @@ devel = fuse = fusepy >= 2.0.4 -# AQMP TUI dependencies +# QMP TUI dependencies tui = urwid >= 2.1.2 urwid-readline >= 0.13 @@ -68,7 +68,7 @@ console_scripts = qemu-ga-client = qemu.utils.qemu_ga_client:main qmp-shell = qemu.qmp.qmp_shell:main qmp-shell-wrap = qemu.qmp.qmp_shell:main_wrap -aqmp-tui = qemu.qmp.aqmp_tui:main [tui] +qmp-tui = qemu.qmp.qmp_tui:main [tui] [flake8] extend-ignore = E722 # Prefer pylint's bare-except checks to flake8's @@ -84,7 +84,7 @@ namespace_packages = True # fusepy has no type stubs: allow_subclassing_any = True -[mypy-qemu.qmp.aqmp_tui] +[mypy-qemu.qmp.qmp_tui] # urwid and urwid_readline have no type stubs: allow_subclassing_any = True -- 2.34.1
[PULL 15/17] python: rename qemu.aqmp to qemu.qmp
Now that we are fully switched over to the new QMP library, move it back over the old namespace. This is being done primarily so that we may upload this package simply as "qemu.qmp" without introducing confusion over whether or not "aqmp" is a new protocol or not. The trade-off is increased confusion inside the QEMU developer tree. Sorry! Note: the 'private' member "_aqmp" in legacy.py also changes to "_qmp"; not out of necessity, but just to remove any traces of the "aqmp" name. Signed-off-by: John Snow Reviewed-by: Beraldo Leal Acked-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20220330172812.3427355-8-js...@redhat.com Signed-off-by: John Snow --- python/PACKAGE.rst| 4 +-- python/README.rst | 4 +-- python/qemu/machine/machine.py| 4 +-- python/qemu/machine/qtest.py | 2 +- python/qemu/{aqmp => qmp}/__init__.py | 6 ++-- python/qemu/{aqmp => qmp}/aqmp_tui.py | 0 python/qemu/{aqmp => qmp}/error.py| 0 python/qemu/{aqmp => qmp}/events.py | 2 +- python/qemu/{aqmp => qmp}/legacy.py | 38 +++ python/qemu/{aqmp => qmp}/message.py | 0 python/qemu/{aqmp => qmp}/models.py | 0 python/qemu/{aqmp => qmp}/protocol.py | 4 +-- python/qemu/{aqmp => qmp}/py.typed| 0 python/qemu/{aqmp => qmp}/qmp_client.py | 16 +- python/qemu/{aqmp => qmp}/qmp_shell.py| 4 +-- python/qemu/{aqmp => qmp}/util.py | 0 python/qemu/utils/qemu_ga_client.py | 4 +-- python/qemu/utils/qom.py | 2 +- python/qemu/utils/qom_common.py | 4 +-- python/qemu/utils/qom_fuse.py | 2 +- python/setup.cfg | 10 +++--- python/tests/protocol.py | 14 - scripts/cpu-x86-uarch-abi.py | 2 +- scripts/device-crash-test | 4 +-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp-shell-wrap| 2 +- scripts/render_block_graph.py | 4 +-- scripts/simplebench/bench_block_job.py| 2 +- tests/qemu-iotests/iotests.py | 2 +- tests/qemu-iotests/tests/mirror-top-perms | 4 +-- 30 files changed, 71 insertions(+), 71 deletions(-) rename python/qemu/{aqmp => qmp}/__init__.py (87%) rename python/qemu/{aqmp => qmp}/aqmp_tui.py (100%) rename python/qemu/{aqmp => qmp}/error.py (100%) rename python/qemu/{aqmp => qmp}/events.py (99%) rename python/qemu/{aqmp => qmp}/legacy.py (91%) rename python/qemu/{aqmp => qmp}/message.py (100%) rename python/qemu/{aqmp => qmp}/models.py (100%) rename python/qemu/{aqmp => qmp}/protocol.py (99%) rename python/qemu/{aqmp => qmp}/py.typed (100%) rename python/qemu/{aqmp => qmp}/qmp_client.py (97%) rename python/qemu/{aqmp => qmp}/qmp_shell.py (99%) rename python/qemu/{aqmp => qmp}/util.py (100%) diff --git a/python/PACKAGE.rst b/python/PACKAGE.rst index ddfa9ba3f59..b0b86cc4c31 100644 --- a/python/PACKAGE.rst +++ b/python/PACKAGE.rst @@ -8,11 +8,11 @@ to change at any time. Usage - -The ``qemu.aqmp`` subpackage provides a library for communicating with +The ``qemu.qmp`` subpackage provides a library for communicating with QMP servers. The ``qemu.machine`` subpackage offers rudimentary facilities for launching and managing QEMU processes. Refer to each package's documentation -(``>>> help(qemu.aqmp)``, ``>>> help(qemu.machine)``) +(``>>> help(qemu.qmp)``, ``>>> help(qemu.machine)``) for more information. Contributing diff --git a/python/README.rst b/python/README.rst index eb5213337d2..9c1fceaee73 100644 --- a/python/README.rst +++ b/python/README.rst @@ -3,7 +3,7 @@ QEMU Python Tooling This directory houses Python tooling used by the QEMU project to build, configure, and test QEMU. It is organized by namespace (``qemu``), and -then by package (e.g. ``qemu/machine``, ``qemu/aqmp``, etc). +then by package (e.g. ``qemu/machine``, ``qemu/qmp``, etc). ``setup.py`` is used by ``pip`` to install this tooling to the current environment. ``setup.cfg`` provides the packaging configuration used by @@ -59,7 +59,7 @@ Package installation also normally provides executable console scripts, so that tools like ``qmp-shell`` are always available via $PATH. To invoke them without installation, you can invoke e.g.: -``> PYTHONPATH=~/src/qemu/python python3 -m qemu.aqmp.qmp_shell`` +``> PYTHONPATH=~/src/qemu/python python3 -m qemu.qmp.qmp_shell`` The mappings between console script name and python module path can be found in ``setup.cfg``. diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 41be025ac7b..07ac5a710be 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -40,8 +40,8 @@ TypeVar, ) -from qemu.aqmp import SocketAddrT -from qemu.aqmp.legacy import ( +from qemu.qmp import SocketAddrT +from qemu.qmp.legacy import ( QEMUMonitorProtocol,
Re: [PATCH] iotests/108: Fix when missing user_allow_other
Hanna Reitz writes: > FUSE exports' allow-other option defaults to "auto", which means that it > will try passing allow_other as a mount option, and fall back to not > using it when an error occurs. We make no effort to hide fusermount's > error message (because it would be difficult, and because users might > want to know about the fallback occurring), and so when allow_other does > not work (primarily when /etc/fuse.conf does not contain > user_allow_other), this error message will appear and break the > reference output. > > We do not need allow_other here, though, so we can just pass > allow-other=off to fix that. > > Reported-by: Markus Armbruster > Signed-off-by: Hanna Reitz Tested-by: Markus Armbruster Thanks!
Re: [PATCH 3/6] scsi-disk: add MODE_PAGE_APPLE quirk for Macintosh
On 21/04/2022 14:27, Fam Zheng wrote: On 2022-04-21 07:51, Mark Cave-Ayland wrote: One of the mechanisms MacOS uses to identify drives compatible with MacOS is to send a custom MODE SELECT command for page 0x30 to the drive. The response to this is a hard-coded manufacturer string which must match in order for the drive to be usable within MacOS. Add an implementation of the MODE SELECT page 0x30 response guarded by a newly defined SCSI_DISK_QUIRK_MODE_PAGE_APPLE quirk bit so that drives attached to non-Apple machines function exactly as before. Signed-off-by: Mark Cave-Ayland --- hw/scsi/scsi-disk.c | 19 +++ include/hw/scsi/scsi.h | 3 +++ include/scsi/constants.h | 1 + 3 files changed, 23 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index d89cdd4e4a..37013756d5 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1085,6 +1085,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, [MODE_PAGE_R_W_ERROR] = (1 << TYPE_DISK) | (1 << TYPE_ROM), [MODE_PAGE_AUDIO_CTL] = (1 << TYPE_ROM), [MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM), +[MODE_PAGE_APPLE] = (1 << TYPE_ROM), }; uint8_t *p = *p_outbuf + 2; @@ -1229,6 +1230,22 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, p[19] = (16 * 176) & 0xff; break; + case MODE_PAGE_APPLE: +if (s->qdev.type == TYPE_DISK && +(s->quirks & SCSI_DISK_QUIRK_MODE_PAGE_APPLE)) { This is always false. SCSI_DISK_QUIRK_MODE_PAGE_APPLE is defined 0. You need (1 << SCSI_DISK_QUIRK_MODE_PAGE_APPLE) instead. Doh, you're absolutely right. I believe the current recommendation is to use the BIT() macro in these cases. I'll wait to see if there is any further feedback on the whole quirks concept before posting an updated v2. + +length = 0x24; +if (page_control == 1) { /* Changeable Values */ +break; +} + +memset(p, 0, length); +strcpy((char *)p + 8, "APPLE COMPUTER, INC "); +break; +} else { +return -1; +} + default: return -1; } @@ -3042,6 +3059,8 @@ static Property scsi_hd_properties[] = { DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_version, 5), +DEFINE_PROP_BIT("quirk_mode_page_apple", SCSIDiskState, quirks, +SCSI_DISK_QUIRK_MODE_PAGE_APPLE, 0), DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 1ffb367f94..f629706250 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -226,4 +226,7 @@ SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, int target, int lun); /* scsi-generic.c. */ extern const SCSIReqOps scsi_generic_req_ops; +/* scsi-disk.c */ +#define SCSI_DISK_QUIRK_MODE_PAGE_APPLE 0 + #endif diff --git a/include/scsi/constants.h b/include/scsi/constants.h index 2a32c08b5e..21ca7b50cd 100644 --- a/include/scsi/constants.h +++ b/include/scsi/constants.h @@ -234,6 +234,7 @@ #define MODE_PAGE_FAULT_FAIL 0x1c #define MODE_PAGE_TO_PROTECT 0x1d #define MODE_PAGE_CAPABILITIES0x2a +#define MODE_PAGE_APPLE 0x30 #define MODE_PAGE_ALLS0x3f /* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor * of MODE_PAGE_SENSE_POWER */ -- 2.20.1 Fam ATB, Mark.
Re: introducing vrc :)
On Thu, Apr 21, 2022 at 05:04:52PM +0200, Paolo Bonzini wrote: > On 4/20/22 20:12, Peter Xu wrote: > > > a while ago I looked at tools that could be used too build a call graph. > > > The simplest but most effective that I found was a small Perl program > > > (called "egypt", which is rot13 for "rtlcg" aka RTL call graph) that used > > > the GCC dumps to build the graph. > > > > Do you have any plan to put it into some git repository? > > Good idea, it's now at https://github.com/bonzini/vrc. > > It can be installed using "pip install --user ." after checking out the > repository. Looks great. Another trivial request is whether you'd like to add a sentence to the 1st paragraph of README.md on showing why it's named "vrc"? I'm just curious :-D Thanks again! -- Peter Xu
[PATCH v2] Only advertise aio=io_uring if support is actually available
Change --help output for aio option to only list the aio backend options that are actually available. io_uring is an optional, linux only backend option so hide it for cases where it isn't there. Reviewed-by: Eric Blake Signed-off-by: Dirk Müller --- block/file-posix.c | 4 qemu-nbd.c | 4 qemu-options.hx| 6 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 39a3d6dbe6..aec4763862 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -544,7 +544,11 @@ static QemuOptsList raw_runtime_opts = { { .name = "aio", .type = QEMU_OPT_STRING, +#ifdef CONFIG_LINUX_IO_URING .help = "host AIO implementation (threads, native, io_uring)", +#else +.help = "host AIO implementation (threads, native)", +#endif }, { .name = "aio-max-batch", diff --git a/qemu-nbd.c b/qemu-nbd.c index 713e7557a9..4634a0fc42 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -147,7 +147,11 @@ static void usage(const char *name) " --cache=MODE set cache mode used to access the disk image, the\n" "valid options are: 'none', 'writeback' (default),\n" "'writethrough', 'directsync' and 'unsafe'\n" +#ifdef CONFIG_LINUX_IO_URING " --aio=MODEset AIO mode (native, io_uring or threads)\n" +#else +" --aio=MODEset AIO mode (native or threads)\n" +#endif " --discard=MODEset discard mode (ignore, unmap)\n" " --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n" " --image-opts treat FILE as a full set of image options\n" diff --git a/qemu-options.hx b/qemu-options.hx index 34e9b32a5c..973125cfca 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1338,7 +1338,11 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, " [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n" " [,snapshot=on|off][,rerror=ignore|stop|report]\n" " [,werror=ignore|stop|report|enospc][,id=name]\n" -" [,aio=threads|native|io_uring]\n" +" [,aio=threads|native" +#if defined(CONFIG_LINUX_IO_URING) +"|io_uring" +#endif +"]\n" " [,readonly=on|off][,copy-on-read=on|off]\n" " [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n" " [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]]\n" -- 2.35.3
Re: [PATCH] Only advertise aio=io_uring if support is actually available
On Mittwoch, 20. April 2022 10:33:38 CEST Daniel P. Berrangé wrote: Hi Daniel, > That all said, the patch itself is OK, because for human targetted > interactive usage, it is desirable for --help to be representative > of what's available. > > IOW, I'm just complaining about the commit message justification > here & warning against writing tools to use --help :-) understood, thank you for the good feedback, I've sent a v2 with a reworded commit message. Greetings, Dirk
Re: [PATCH v14 1/8] virtio: drop name parameter for virtio_init()
* Jonah Palmer (jonah.pal...@oracle.com) wrote: > This patch drops the name parameter for the virtio_init function. > > The pair between the numeric device ID and the string device ID > (name) of a virtio device already exists, but not in a way that > lets us map between them. > > This patch lets us do this and removes the need for the name > parameter in the virtio_init function. > > Signed-off-by: Jonah Palmer So this looks OK to me, but is really a question for the virtio folk rather than hmp/qmp that a lot of the rest of this series does. Dave > --- > hw/9pfs/virtio-9p-device.c | 2 +- > hw/block/vhost-user-blk.c | 2 +- > hw/block/virtio-blk.c | 2 +- > hw/char/virtio-serial-bus.c| 3 +- > hw/display/virtio-gpu-base.c | 2 +- > hw/input/virtio-input.c| 3 +- > hw/net/virtio-net.c| 2 +- > hw/scsi/virtio-scsi.c | 3 +- > hw/virtio/vhost-user-fs.c | 3 +- > hw/virtio/vhost-user-i2c.c | 7 +--- > hw/virtio/vhost-user-rng.c | 2 +- > hw/virtio/vhost-user-vsock.c | 2 +- > hw/virtio/vhost-vsock-common.c | 5 +-- > hw/virtio/vhost-vsock.c| 2 +- > hw/virtio/virtio-balloon.c | 3 +- > hw/virtio/virtio-crypto.c | 2 +- > hw/virtio/virtio-iommu.c | 3 +- > hw/virtio/virtio-mem.c | 3 +- > hw/virtio/virtio-pmem.c| 3 +- > hw/virtio/virtio-rng.c | 2 +- > hw/virtio/virtio.c | 55 -- > include/hw/virtio/vhost-vsock-common.h | 2 +- > include/hw/virtio/virtio-gpu.h | 3 +- > include/hw/virtio/virtio.h | 4 +- > 24 files changed, 77 insertions(+), 43 deletions(-) > > diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c > index 54ee93b71f..5f522e68e9 100644 > --- a/hw/9pfs/virtio-9p-device.c > +++ b/hw/9pfs/virtio-9p-device.c > @@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev, > Error **errp) > } > > v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag); > -virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size); > +virtio_init(vdev, VIRTIO_ID_9P, v->config_size); > v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output); > } > > diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c > index 1a42ae9187..e8cb170032 100644 > --- a/hw/block/vhost-user-blk.c > +++ b/hw/block/vhost-user-blk.c > @@ -491,7 +491,7 @@ static void vhost_user_blk_device_realize(DeviceState > *dev, Error **errp) > return; > } > > -virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, > +virtio_init(vdev, VIRTIO_ID_BLOCK, > sizeof(struct virtio_blk_config)); > > s->virtqs = g_new(VirtQueue *, s->num_queues); > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c > index 540c38f829..27c71ad316 100644 > --- a/hw/block/virtio-blk.c > +++ b/hw/block/virtio-blk.c > @@ -1206,7 +1206,7 @@ static void virtio_blk_device_realize(DeviceState *dev, > Error **errp) > > virtio_blk_set_config_size(s, s->host_features); > > -virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size); > +virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); > > s->blk = conf->conf.blk; > s->rq = NULL; > diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c > index 6048d408b8..7d4601cb5d 100644 > --- a/hw/char/virtio-serial-bus.c > +++ b/hw/char/virtio-serial-bus.c > @@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState > *dev, Error **errp) > VIRTIO_CONSOLE_F_EMERG_WRITE)) { > config_size = offsetof(struct virtio_console_config, emerg_wr); > } > -virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE, > -config_size); > +virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size); > > /* Spawn a new virtio-serial bus on which the ports will ride as devices > */ > qbus_init(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, > diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c > index fff0fb4a82..8ba5da4312 100644 > --- a/hw/display/virtio-gpu-base.c > +++ b/hw/display/virtio-gpu-base.c > @@ -173,7 +173,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, > } > > g->virtio_config.num_scanouts = cpu_to_le32(g->conf.max_outputs); > -virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, > +virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU, > sizeof(struct virtio_gpu_config)); > > if (virtio_gpu_virgl_enabled(g->conf)) { > diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c > index 54bcb46c74..5b5398b3ca 100644 > --- a/hw/input/virtio-input.c > +++ b/hw/input/virtio-input.c > @@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState
Re: [PATCH 3/6] scsi-disk: add MODE_PAGE_APPLE quirk for Macintosh
On 4/21/22 08:29, Mark Cave-Ayland wrote: You need (1 << SCSI_DISK_QUIRK_MODE_PAGE_APPLE) instead. Doh, you're absolutely right. I believe the current recommendation is to use the BIT() macro in these cases. We probably need to fix BIT() to use 1ULL. At present it's using 1UL, to match the other (unfortunate) uses of unsigned long within bitops.h. The use of BIT() for things unrelated to bitops.h just bit a recent risc-v pull request, in that it failed to build on all 32-bit hosts. r~
Re: [PATCH v2] Only advertise aio=io_uring if support is actually available
On Thu, Apr 21, 2022 at 06:50:48PM +0200, Dirk Müller wrote: > Change --help output for aio option to only list the aio backend options that > are actually available. io_uring is an optional, linux only backend > option so hide it for cases where it isn't there. As pointed out by Dan, this commit message is not quite accurate. It hides only one of the two conditional options, but 'native' is also a Linux-only optional backend (CONFIG_LINUX_AIO). > > Reviewed-by: Eric Blake > Signed-off-by: Dirk Müller > --- > block/file-posix.c | 4 > qemu-nbd.c | 4 > qemu-options.hx| 6 +- > 3 files changed, 13 insertions(+), 1 deletion(-) > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 3/6] scsi-disk: add MODE_PAGE_APPLE quirk for Macintosh
On Thu, 21 Apr 2022, Richard Henderson wrote: On 4/21/22 08:29, Mark Cave-Ayland wrote: You need (1 << SCSI_DISK_QUIRK_MODE_PAGE_APPLE) instead. Doh, you're absolutely right. I believe the current recommendation is to use the BIT() macro in these cases. I think it's not a recommendation (as in code style) but it often makes things simpler by reducing the number of parenthesis so using it is probably a good idea for readability. But if you never need the bit number only the value then you could define the quirks constants as that in the first place. (Otherwise if you want bit numbers maybe make it an enum.) We probably need to fix BIT() to use 1ULL. At present it's using 1UL, to match the other (unfortunate) uses of unsigned long within bitops.h. The use of BIT() for things unrelated to bitops.h just bit a recent risc-v pull request, in that it failed to build on all 32-bit hosts. There's already a BIT_ULL(nr) when ULL is needed but in this case quirks was declared uint32_t so probably OK with UL as well. (Was this bitops.h taken from Linux? Keeping it compatible then may be a good idea to avoid confusion.) Regards, BALATON Zoltan
Re: [PULL 00/17] Python patches
On 4/21/22 08:15, John Snow wrote: The following changes since commit b1efff6bf031a93b5b8bf3912ddc720cc1653a61: Merge tag 'pull-ppc-20220420-2' of https://gitlab.com/danielhb/qemu into staging (2022-04-20 21:54:24 -0700) are available in the Git repository at: https://gitlab.com/jsnow/qemu.git tags/python-pull-request for you to fetch changes up to 47430775ed1a48d7beb2c7b8d7feaab73104ec46: python/qmp: remove pylint workaround from legacy.py (2022-04-21 11:01:00 -0400) Python patches This PR finalizes the switch from Luiz's QMP library to mine. Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate. r~ John Snow (17): python/machine: permanently switch to AQMP scripts/bench-block-job: switch to AQMP iotests/mirror-top-perms: switch to AQMP iotests: switch to AQMP python/aqmp: add explicit GPLv2 license to legacy.py python/aqmp: relicense as LGPLv2+ python/qmp-shell: relicense as LGPLv2+ python/aqmp-tui: relicense as LGPLv2+ python: temporarily silence pylint duplicate-code warnings python/aqmp: take QMPBadPortError and parse_address from qemu.qmp python/aqmp: fully separate from qmp.QEMUMonitorProtocol python/aqmp: copy qmp docstrings to qemu.aqmp.legacy python: remove the old QMP package python: re-enable pylint duplicate-code warnings python: rename qemu.aqmp to qemu.qmp python: rename 'aqmp-tui' to 'qmp-tui' python/qmp: remove pylint workaround from legacy.py python/README.rst | 2 +- python/qemu/qmp/README.rst| 9 - python/qemu/aqmp/__init__.py | 59 --- python/qemu/aqmp/legacy.py| 177 --- python/qemu/aqmp/py.typed | 0 python/qemu/machine/machine.py| 18 +- python/qemu/machine/qtest.py | 2 +- python/qemu/qmp/__init__.py | 445 ++ python/qemu/{aqmp => qmp}/error.py| 0 python/qemu/{aqmp => qmp}/events.py | 2 +- python/qemu/qmp/legacy.py | 315 + python/qemu/{aqmp => qmp}/message.py | 0 python/qemu/{aqmp => qmp}/models.py | 0 python/qemu/{aqmp => qmp}/protocol.py | 4 +- python/qemu/{aqmp => qmp}/qmp_client.py | 16 +- python/qemu/{aqmp => qmp}/qmp_shell.py| 11 +- .../qemu/{aqmp/aqmp_tui.py => qmp/qmp_tui.py} | 17 +- python/qemu/{aqmp => qmp}/util.py | 0 python/qemu/utils/qemu_ga_client.py | 4 +- python/qemu/utils/qom.py | 2 +- python/qemu/utils/qom_common.py | 4 +- python/qemu/utils/qom_fuse.py | 2 +- python/setup.cfg | 11 +- python/tests/protocol.py | 14 +- scripts/cpu-x86-uarch-abi.py | 2 +- scripts/device-crash-test | 4 +- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp-shell-wrap| 2 +- scripts/render_block_graph.py | 4 +- scripts/simplebench/bench_block_job.py| 5 +- tests/qemu-iotests/iotests.py | 3 +- tests/qemu-iotests/tests/mirror-top-perms | 11 +- 32 files changed, 422 insertions(+), 725 deletions(-) delete mode 100644 python/qemu/qmp/README.rst delete mode 100644 python/qemu/aqmp/__init__.py delete mode 100644 python/qemu/aqmp/legacy.py delete mode 100644 python/qemu/aqmp/py.typed rename python/qemu/{aqmp => qmp}/error.py (100%) rename python/qemu/{aqmp => qmp}/events.py (99%) create mode 100644 python/qemu/qmp/legacy.py rename python/qemu/{aqmp => qmp}/message.py (100%) rename python/qemu/{aqmp => qmp}/models.py (100%) rename python/qemu/{aqmp => qmp}/protocol.py (99%) rename python/qemu/{aqmp => qmp}/qmp_client.py (97%) rename python/qemu/{aqmp => qmp}/qmp_shell.py (98%) rename python/qemu/{aqmp/aqmp_tui.py => qmp/qmp_tui.py} (98%) rename python/qemu/{aqmp => qmp}/util.py (100%)