Received: from eggs.gnu.org ([2001:4830:134:3::10]:49084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wswld-0002xc-Bp for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:13:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WswlU-0003sg-JJ for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:13:21 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:201:233:1::3]:57044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WswlU-0003sb-7x for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:13:12 -0400 From: Markus Armbruster References: <1402059060-17544-1-git-send-email-armbru@redhat.com> <1402059060-17544-2-git-send-email-armbru@redhat.com> <20140606140524.GB16494@irqsave.net> Date: Fri, 06 Jun 2014 18:13:09 +0200 In-Reply-To: <20140606140524.GB16494@irqsave.net> (=?utf-8?Q?=22Beno=C3=AE?= =?utf-8?Q?t?= Canet"'s message of "Fri, 6 Jun 2014 16:05:24 +0200") Message-ID: <87k38um2y2.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] blockdev: Rename drive_init(), drive_uninit() to drive_new(), drive_del() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Beno=C3=AEt?= Canet Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Beno=C3=AEt Canet writes: > The Friday 06 Jun 2014 =C3=A0 14:50:58 (+0200), Markus Armbruster wrote : >> "Init" and "uninit" suggest the functions don't allocate / free >> storage. But they do. >>=20 >> Signed-off-by: Markus Armbruster >> --- >> blockdev.c | 14 +++++++------- >> device-hotplug.c | 2 +- >> hw/usb/dev-storage.c | 2 +- >> include/sysemu/blockdev.h | 4 ++-- >> vl.c | 4 ++-- >> 5 files changed, 13 insertions(+), 13 deletions(-) >>=20 >> diff --git a/blockdev.c b/blockdev.c >> index 9b5261b..1256013 100644 >> --- a/blockdev.c >> +++ b/blockdev.c >> @@ -213,7 +213,7 @@ static void bdrv_format_print(void *opaque, const ch= ar *name) >> error_printf(" %s", name); >> } >>=20=20 >> -static void drive_uninit(DriveInfo *dinfo) >> +static void drive_del(DriveInfo *dinfo) >> { >> if (dinfo->opts) { >> qemu_opts_del(dinfo->opts); >> @@ -230,7 +230,7 @@ void drive_put_ref(DriveInfo *dinfo) >> { >> assert(dinfo->refcount); >> if (--dinfo->refcount =3D=3D 0) { >> - drive_uninit(dinfo); >> + drive_del(dinfo); >> } >> } >>=20=20 >> @@ -658,7 +658,7 @@ QemuOptsList qemu_legacy_drive_opts =3D { >> }, >> }; >>=20=20 >> -DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_defa= ult_type) >> +DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_defau= lt_type) >> { >> const char *value; >> DriveInfo *dinfo =3D NULL; >> @@ -1791,7 +1791,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict,= QObject **ret_data) >> bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT, >> BLOCKDEV_ON_ERROR_REPORT); >> } else { >> - drive_uninit(drive_get_by_blockdev(bs)); >> + drive_del(drive_get_by_blockdev(bs)); >> } >>=20=20 >> return 0; >> @@ -2334,9 +2334,9 @@ void qmp_blockdev_add(BlockdevOptions *options, Er= ror **errp) >> goto fail; >> } >>=20=20 >> - /* TODO Sort it out in raw-posix and drive_init: Reject aio=3Dnativ= e with >> + /* TODO Sort it out in raw-posix and drive_new(): Reject aio=3Dnati= ve with >> * cache.direct=3Dfalse instead of silently switching to aio=3Dthre= ads, except >> - * if called from drive_init. >> + * when called from drive_new(). >> * >> * For now, simply forbidding the combination for all drivers will = do. */ >> if (options->has_aio && options->aio =3D=3D BLOCKDEV_AIO_OPTIONS_NA= TIVE) { >> @@ -2368,7 +2368,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Er= ror **errp) >> } >>=20=20 >> if (bdrv_key_required(dinfo->bdrv)) { >> - drive_uninit(dinfo); >> + drive_del(dinfo); >> error_setg(errp, "blockdev-add doesn't support encrypted device= s"); >> goto fail; >> } >> diff --git a/device-hotplug.c b/device-hotplug.c >> index eecb08e..fc09d10 100644 >> --- a/device-hotplug.c >> +++ b/device-hotplug.c >> @@ -40,7 +40,7 @@ DriveInfo *add_init_drive(const char *optstr) >> return NULL; >>=20=20 >> mc =3D MACHINE_GET_CLASS(current_machine); >> - dinfo =3D drive_init(opts, mc->block_default_type); >> + dinfo =3D drive_new(opts, mc->block_default_type); >> if (!dinfo) { >> qemu_opts_del(opts); >> return NULL; >> diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c >> index e919100..ae4efcb 100644 >> --- a/hw/usb/dev-storage.c >> +++ b/hw/usb/dev-storage.c >> @@ -691,7 +691,7 @@ static USBDevice *usb_msd_init(USBBus *bus, const ch= ar *filename) >> qemu_opt_set(opts, "if", "none"); >>=20=20 >> /* create host drive */ >> - dinfo =3D drive_init(opts, 0); >> + dinfo =3D drive_new(opts, 0); >> if (!dinfo) { >> qemu_opts_del(opts); >> return NULL; >> diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h >> index 134712b..0fdbd68 100644 >> --- a/include/sysemu/blockdev.h >> +++ b/include/sysemu/blockdev.h >> @@ -37,7 +37,7 @@ struct DriveInfo { >> int bus; >> int unit; >> int auto_del; /* see blockdev_mark_auto_del() */ >> - bool enable_auto_del; /* Only for legacy drive_init() */ >> + bool enable_auto_del; /* Only for legacy drive_new() */ >> int media_cd; >> int cyls, heads, secs, trans; >> QemuOpts *opts; >> @@ -57,7 +57,7 @@ DriveInfo *drive_get_by_blockdev(BlockDriverState *bs); >> QemuOpts *drive_def(const char *optstr); >> QemuOpts *drive_add(BlockInterfaceType type, int index, const char *fil= e, >> const char *optstr); >> -DriveInfo *drive_init(QemuOpts *arg, BlockInterfaceType block_default_t= ype); >> +DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_ty= pe); >>=20=20 >> /* device-hotplug */ >>=20=20 >> diff --git a/vl.c b/vl.c > gG> index a3def97..f4b4841 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -1074,7 +1074,7 @@ static int drive_init_func(QemuOpts *opts, void *o= paque) >> { >> BlockInterfaceType *block_default_type =3D opaque; >>=20=20 >> - return drive_init(opts, *block_default_type) =3D=3D NULL; >> + return drive_new(opts, *block_default_type) =3D=3D NULL; >> } >>=20=20 >> static int drive_enable_snapshot(QemuOpts *opts, void *opaque) >> @@ -1098,7 +1098,7 @@ static void default_drive(int enable, int snapshot= , BlockInterfaceType type, >> if (snapshot) { >> drive_enable_snapshot(opts, NULL); >> } >> - if (!drive_init(opts, type)) { >> + if (!drive_new(opts, type)) { > > Unrelated but it seems QEMU is leaking this one on exit. The kernel cleans it up for free, along with zillions of other unfreed pieces of memory, file descriptors, and more. > >> exit(1); >> } >> } >> --=20 >> 1.9.3 >>=20 >>=20 > > Reviewed-by: Benoit Canet Thanks!