On Mon, Aug 14, 2023 at 04:58:01PM +0800, Sam Li wrote: > By adding zone operations and zoned metadata, the zoned emulation > capability enables full emulation support of zoned device using > a qcow2 file. The zoned device metadata includes zone type, > zoned device state and write pointer of each zone, which is stored > to an array of unsigned integers. > > Each zone of a zoned device makes state transitions following > the zone state machine. The zone state machine mainly describes > five states, IMPLICIT OPEN, EXPLICIT OPEN, FULL, EMPTY and CLOSED. > READ ONLY and OFFLINE states will generally be affected by device > internal events. The operations on zones cause corresponding state > changing. > > Zoned devices have a limit on zone resources, which puts constraints on > write operations into zones. > > Signed-off-by: Sam Li <faithilike...@gmail.com> > --- > block/qcow2.c | 676 ++++++++++++++++++++++++++++++++++++++++- > block/qcow2.h | 2 + > docs/interop/qcow2.txt | 2 + > 3 files changed, 678 insertions(+), 2 deletions(-) > > diff --git a/block/qcow2.c b/block/qcow2.c > index c1077c4a4a..5ccf79cbe7 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -194,6 +194,164 @@ qcow2_extract_crypto_opts(QemuOpts *opts, const char > *fmt, Error **errp) > return cryptoopts_qdict; > } > > +#define QCOW2_ZT_IS_CONV(wp) (wp & 1ULL << 59) > + > +static inline int qcow2_get_wp(uint64_t wp) > +{ > + /* clear state and type information */ > + return ((wp << 5) >> 5); > +} > + > +static inline int qcow2_get_zs(uint64_t wp) > +{ > + return (wp >> 60); > +} > + > +static inline void qcow2_set_wp(uint64_t *wp, BlockZoneState zs) > +{ > + uint64_t addr = qcow2_get_wp(*wp); > + addr |= ((uint64_t)zs << 60); > + *wp = addr; > +}
Although the function is called qcow2_set_wp() it seems to actually be qcow2_set_zs() since it only changes the zone state, not the write pointer. Want to rename it? > + > +/* > + * File wp tracking: reset zone, finish zone and append zone can > + * change the value of write pointer. All zone operations will change > + * the state of that/those zone. > + * */ > +static inline void qcow2_wp_tracking_helper(int index, uint64_t wp) { > + /* format: operations, the wp. */ > + printf("wps[%d]: 0x%x\n", index, qcow2_get_wp(wp)>>BDRV_SECTOR_BITS); > +} This looks like debugging code that shouldn't go into qemu.git. Please use tracing (docs/devel/tracing.rst) to capture internal information in production code. I will review more of this patch series another time because I need to get going. Stefan
signature.asc
Description: PGP signature