Received: from eggs.gnu.org ([2001:4830:134:3::10]:34847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayiAl-0006Qi-6S for qemu-devel@nongnu.org; Fri, 06 May 2016 12:00:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayiAZ-0007gi-0P for qemu-devel@nongnu.org; Fri, 06 May 2016 12:00:05 -0400 References: <1462419759-14694-1-git-send-email-eblake@redhat.com> <1462419759-14694-4-git-send-email-eblake@redhat.com> From: Max Reitz Message-ID: <9ee1be0b-439c-0344-5523-91c7def32676@redhat.com> Date: Fri, 6 May 2016 17:59:19 +0200 MIME-Version: 1.0 In-Reply-To: <1462419759-14694-4-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gN2iaFSr2GvVBpVkjnrVDsOqJUclKrO86" Subject: Re: [Qemu-devel] [PATCH v4 3/6] qemu-io: Allow unaligned access by default List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --gN2iaFSr2GvVBpVkjnrVDsOqJUclKrO86 Content-Type: multipart/mixed; boundary="XN41KHSMWbo21KRSp0TjKidFWPHKMCb3w" From: Max Reitz To: Eric Blake , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com Message-ID: <9ee1be0b-439c-0344-5523-91c7def32676@redhat.com> Subject: Re: [PATCH v4 3/6] qemu-io: Allow unaligned access by default References: <1462419759-14694-1-git-send-email-eblake@redhat.com> <1462419759-14694-4-git-send-email-eblake@redhat.com> In-Reply-To: <1462419759-14694-4-git-send-email-eblake@redhat.com> --XN41KHSMWbo21KRSp0TjKidFWPHKMCb3w Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 05.05.2016 05:42, Eric Blake wrote: > There's no reason to require the user to specify a flag just so > they can pass in unaligned numbers. Keep 'read -p' and 'write -p' > as no-ops so that I don't have to hunt down and update all users > of qemu-io, but otherwise make their behavior default as 'read' and > 'write'. Also fix 'write -z', 'readv', 'writev', 'writev', > 'aio_read', 'aio_write', and 'aio_write -z'. For now, 'read -b', > 'multiwrite', 'write -b', and 'write -c' still require alignment. >=20 > qemu-iotest 23 is updated to match, as the only test that was > previously explicitly expecting an error on an unaligned request. >=20 > Signed-off-by: Eric Blake > --- > qemu-io-cmds.c | 63 +- > tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++-------= -------- > 2 files changed, 1452 insertions(+), 771 deletions(-) >=20 > diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c > index dc6b0dc..8bcf742 100644 > --- a/qemu-io-cmds.c > +++ b/qemu-io-cmds.c > @@ -395,12 +395,6 @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov= , char **argv, int nr_iov, > goto fail; > } >=20 > - if (len & 0x1ff) { > - printf("length argument %" PRId64 > - " is not sector aligned\n", len); > - goto fail; > - } > - > sizes[i] =3D len; > count +=3D len; > } > @@ -634,7 +628,7 @@ static void read_help(void) > " -b, -- read from the VM state rather than the virtual disk\n" > " -C, -- report statistics in a machine parsable format\n" > " -l, -- length for pattern verification (only with -P)\n" > -" -p, -- allow unaligned access\n" > +" -p, -- ignored for back-compat\n" We're not so close to the 80 character limit here to justify shortening this as much. ;-) I really wouldn't mind a full "backwards compatibility". > " -P, -- use a pattern to verify read data\n" > " -q, -- quiet mode, do not show I/O statistics\n" > " -s, -- start offset for pattern verification (only with -P)\n" > @@ -650,7 +644,7 @@ static const cmdinfo_t read_cmd =3D { > .cfunc =3D read_f, > .argmin =3D 2, > .argmax =3D -1, > - .args =3D "[-abCpqv] [-P pattern [-s off] [-l len]] off len"= , > + .args =3D "[-abCqv] [-P pattern [-s off] [-l len]] off len",= > .oneline =3D "reads a number of bytes at a specified offset", > .help =3D read_help, > }; > @@ -658,7 +652,7 @@ static const cmdinfo_t read_cmd =3D { > static int read_f(BlockBackend *blk, int argc, char **argv) > { > struct timeval t1, t2; > - bool Cflag =3D false, pflag =3D false, qflag =3D false, vflag =3D = false; > + bool Cflag =3D false, qflag =3D false, vflag =3D false; > bool Pflag =3D false, sflag =3D false, lflag =3D false, bflag =3D = false; > int c, cnt; > char *buf; > @@ -686,7 +680,7 @@ static int read_f(BlockBackend *blk, int argc, char= **argv) > } > break; > case 'p': > - pflag =3D true; > + /* Ignored for back-compat */ > break; > case 'P': > Pflag =3D true; > @@ -718,11 +712,6 @@ static int read_f(BlockBackend *blk, int argc, cha= r **argv) > return qemuio_command_usage(&read_cmd); > } >=20 > - if (bflag && pflag) { > - printf("-b and -p cannot be specified at the same time\n"); > - return 0; > - } > - > offset =3D cvtnum(argv[optind]); > if (offset < 0) { > print_cvtnum_err(offset, argv[optind]); > @@ -753,7 +742,7 @@ static int read_f(BlockBackend *blk, int argc, char= **argv) > return 0; > } >=20 > - if (!pflag) { > + if (bflag) { > if (offset & 0x1ff) { > printf("offset %" PRId64 " is not sector aligned\n", > offset); > @@ -890,12 +879,6 @@ static int readv_f(BlockBackend *blk, int argc, ch= ar **argv) > } > optind++; >=20 > - if (offset & 0x1ff) { > - printf("offset %" PRId64 " is not sector aligned\n", > - offset); > - return 0; > - } > - > nr_iov =3D argc - optind; > buf =3D create_iovec(blk, &qiov, &argv[optind], nr_iov, 0xab); > if (buf =3D=3D NULL) { > @@ -952,7 +935,7 @@ static void write_help(void) > " filled with a set pattern (0xcdcdcdcd).\n" > " -b, -- write to the VM state rather than the virtual disk\n" > " -c, -- write compressed data with blk_write_compressed\n" > -" -p, -- allow unaligned access\n" > +" -p, -- ignored for back-compat\n" > " -P, -- use different pattern to fill file\n" > " -C, -- report statistics in a machine parsable format\n" > " -q, -- quiet mode, do not show I/O statistics\n" > @@ -968,7 +951,7 @@ static const cmdinfo_t write_cmd =3D { > .cfunc =3D write_f, > .argmin =3D 2, > .argmax =3D -1, > - .args =3D "[-bcCpqz] [-P pattern ] off len", > + .args =3D "[-bcCqz] [-P pattern ] off len", Would you mind removing the space after "pattern" along with this change?= > .oneline =3D "writes a number of bytes at a specified offset", > .help =3D write_help, > }; > @@ -976,7 +959,7 @@ static const cmdinfo_t write_cmd =3D { > static int write_f(BlockBackend *blk, int argc, char **argv) > { > struct timeval t1, t2; > - bool Cflag =3D false, pflag =3D false, qflag =3D false, bflag =3D = false; > + bool Cflag =3D false, qflag =3D false, bflag =3D false; > bool Pflag =3D false, zflag =3D false, cflag =3D false; > int c, cnt; > char *buf =3D NULL; > @@ -998,7 +981,7 @@ static int write_f(BlockBackend *blk, int argc, cha= r **argv) > Cflag =3D true; > break; > case 'p': > - pflag =3D true; > + /* Ignored for back-compat */ > break; > case 'P': > Pflag =3D true; > @@ -1022,8 +1005,8 @@ static int write_f(BlockBackend *blk, int argc, c= har **argv) > return qemuio_command_usage(&write_cmd); > } >=20 > - if (bflag + pflag + zflag > 1) { > - printf("-b, -p, or -z cannot be specified at the same time\n")= ; > + if (bflag + zflag > 1) { Could you make that "bflag && zflag" instead? Adding booleans was fine for the meantime between patch 2 and this one, but I'd rather not keep it in the long run. Max > + printf("-b and -z cannot be specified at the same time\n"); > return 0; > } >=20 --XN41KHSMWbo21KRSp0TjKidFWPHKMCb3w-- --gN2iaFSr2GvVBpVkjnrVDsOqJUclKrO86 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXLL9XAAoJEDuxQgLoOKytquMH/j2wevfdKUEru8OnOQRKrJ4X rkg6kR8/A0hBBlPn24HODf4HgeDcS9BxDT8fgDyF4yfhCrYNe30y+K2dBw7ehnvU rFaYzaGDFY+jW0wrPtZtXPxr7waaJVQh0DZd+D0+8hS0HgYhKn4hGS/kE7IzoLEV KsR9Nvrw+EUpnDYPzZAaUAGndo2QL2RINzyUoHvpck3SuMIQ/yFDUKPoJzNjpAAY FlhKmM4Typ7hwdu6sKt1PA58K97F/4OiUCBOM7yrk8e0kzphhdfARMRe9z2YvLC2 Hn/9woYWIsQkDNXKroJLTjK8UQVdR/dhf4ZXeZ2DKr15+g2eONOSF5F60lKWS/g= =W9nT -----END PGP SIGNATURE----- --gN2iaFSr2GvVBpVkjnrVDsOqJUclKrO86--