From: Stefano Stabellini Subject: Re: [PATCH for-4.6] libxl: handle read-only drives with qemu-xen Date: Mon, 14 Sep 2015 10:49:00 +0100 Message-ID: References: <1441990829-18122-1-git-send-email-stefano.stabellini@eu.citrix.com> <20150914090341.GB2294@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZbQPh-0002qW-9A for xen-devel@lists.xenproject.org; Mon, 14 Sep 2015 09:51:05 +0000 In-Reply-To: <20150914090341.GB2294@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: Ian.Campbell@eu.citrix.com, xen-devel@lists.xenproject.org, Ian.Jackson@eu.citrix.com, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Mon, 14 Sep 2015, Wei Liu wrote: > On Fri, Sep 11, 2015 at 06:00:29PM +0100, Stefano Stabellini wrote: > > The current libxl code doesn't deal with read-only drives at all. > > > > Upstream QEMU and qemu-xen only support read-only cdrom drives: make > > sure to specify "readonly=on" for cdrom drives and return error in case > > the user requested a non-cdrom read-only drive. > > > > The commit message speaks about both upstream QEMU and traditional QEMU, > but the code only touches upstream routine. I know that QEMU-trad uses > different method to get disk parameters so _args_old is not an option, > but perhaps something else is missing? Or is it because QEMU-trad is > doing the right thing already? I know that QEMU naming is very confusing, but qemu-xen is the upstream QEMU based tree which xen-unstable uses. We are only talking about upstream QEMU based trees here. > > Signed-off-by: Stefano Stabellini > > --- > > tools/libxl/libxl_dm.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > > index 02c0162..468ff9c 100644 > > --- a/tools/libxl/libxl_dm.c > > +++ b/tools/libxl/libxl_dm.c > > @@ -1110,13 +1110,18 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, > > if (disks[i].is_cdrom) { > > if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) > > drive = libxl__sprintf > > - (gc, "if=ide,index=%d,media=cdrom,cache=writeback,id=ide-%i", > > - disk, dev_number); > > + (gc, "if=ide,index=%d,readonly=%s,media=cdrom,cache=writeback,id=ide-%i", > > + disk, disks[i].readwrite ? "off" : "on", dev_number); > > else > > drive = libxl__sprintf > > - (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback,id=ide-%i", > > - disks[i].pdev_path, disk, format, dev_number); > > + (gc, "file=%s,if=ide,index=%d,readonly=%s,media=cdrom,format=%s,cache=writeback,id=ide-%i", > > + disks[i].pdev_path, disk, disks[i].readwrite ? "off" : "on", format, dev_number); > > } else { > > + if (!disks[i].readwrite) { > > + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "QEMU doesn't support read-only disk drivers"); > > I think the "new" way of doing thing is to use LOG() macro. But for the > sake of consistency I think this is fine. > > I shall look into writing a spatch to covert all LIBXL__LOG macros to > LOG. > > Wei. > > > + return ERROR_INVAL; > > + } > > + > > if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) { > > LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support" > > " empty disk format for %s", disks[i].vdev); > > -- > > 1.7.10.4 >