Received: from eggs.gnu.org ([2001:4830:134:3::10]:56624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVF7p-00014j-Tb for qemu-devel@nongnu.org; Mon, 15 Feb 2016 04:07:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVF7m-0001H1-Mk for qemu-devel@nongnu.org; Mon, 15 Feb 2016 04:07:21 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:46604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVF7m-0001F0-9S for qemu-devel@nongnu.org; Mon, 15 Feb 2016 04:07:18 -0500 From: Paul Durrant Date: Mon, 15 Feb 2016 09:07:13 +0000 Message-ID: <3fbbf2a606a14f708655037f5e4fb31e@AMSPEX02CL03.citrite.net> References: <20160212191037.GF8818@citrix.com> In-Reply-To: <20160212191037.GF8818@citrix.com> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [Qemu-devel] RFC: configuring QEMU virtfs for Xen PV(H) guests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wei Liu , "qemu-devel@nongnu.org" , Xen-devel Cc: Anthony Perard , Stefano Stabellini , "aneesh.kumar@linux.vnet.ibm.com" , "gkurz@linux.vnet.ibm.com" > -----Original Message----- > From: qemu-devel-bounces+paul.durrant=3Dcitrix.com@nongnu.org > [mailto:qemu-devel-bounces+paul.durrant=3Dcitrix.com@nongnu.org] On > Behalf Of Wei Liu > Sent: 12 February 2016 19:11 > To: qemu-devel@nongnu.org; Xen-devel > Cc: Anthony Perard; gkurz@linux.vnet.ibm.com; Wei Liu; > aneesh.kumar@linux.vnet.ibm.com; Stefano Stabellini > Subject: [Qemu-devel] RFC: configuring QEMU virtfs for Xen PV(H) guests >=20 > # Background >=20 > To configure virtfs, there is two methods in QEMU command line: >=20 > 1. Use -fsdev and -device virtio-9p-pci,XXX directives > 2. Use -virtfs directive >=20 > The second method is actually shorthand for the first method. It > constructs fsdev and device options behind the scene. In the end, > there will be a virtio-9p-pci device (transport for 9pfs) in QEMU. To > make the discussion easier, I only use the first syntax. >=20 > Xen uses QEMU for two purposes. One is to use QEMU to emulate a PC > machine (which is more or less the same as KVM), the other is to use > QEMU to provide services (no emulation needed). The discussion is > about the second usecase. >=20 > While Xen uses QEMU as a backend to provide service to PV(H) guests, > it has its own idea of various objects. It is not totally compatible > with QEMU's world view. >=20 > To avoid digging to deep into the code, here is how Xen arranges QEMU > to work as PV backends (using nic as example): >=20 > 1. Toolstack arranges some xenstore entries. > 2. Toolstack arranges command line options for QEMU: > -netdev XXX -device YYY > 3. QEMU starts up in xen-attach mode, scans xenstore for relevant > entries, then traverse QEMU's nb_table (where information for all > nics is stored) for relevant entries and "steals" the device. >=20 > Now the question is how we to configure virtfs for Xen PV(H) guests? >=20 > # Option 1: Try to steal the device as before. >=20 > There doesn't seem to be a centralised reference point for > virtio-9p-pci devices. So even if I want to steal it, I would need to > traverse whole machine hierarchy. I would be happy if anybody knows a > way to pick out specific devices -- in this case virtio-9p-pci. In > this particular case: >=20 > 1. Toolstack arranges some xenstore entries. > 2. Toolstack arranges command line options for QEMU: > -fsdev XXX -device virtio-9p-pci,XXX > 3. QEMU starts up in xen-attach mode, scans xenstore for relevant > entries, traverses its object hierarchy for device and then > steals it. >=20 > Downside: The main difficulty is I don't know how to pick the right > device. But maybe that's just me not knowing the right way of doing > things. >=20 > # Option 2: Invent a xen-9p device >=20 > Another way of doing it is to expose a dummy xen-9p device, so that we > can use -fsdev XXX -device xen-9p,YYY. This simple device should be > used to capture the parameters like mount_tag and fsdev_id, and then > chained itself to a known location. Later Xen transport can traverse > this known location. This xen-9p device doesn't seem to fit well into > the hierarchy. The best I can think of its parent should be > TYPE_DEVICE. In this case: >=20 > 1. Toolstack arranges some xenstore entries. > 2. Toolstack arranges command line options for QEMU: > -fsdev XXX -device xen-9p,XXX > 3. QEMU starts up in xen-attach mode, scans xenstore for relevant > entries, then traverses the known location. >=20 > Downside: Inventing a dummy device looks suboptimal to me. >=20 This sounds like a reasonable approach to me and surely it can be made gene= ric (i.e. not tied to virtfs specifically). All we need as a new device typ= e 'xenbus-device' or somesuch and a parameter to that device which specifie= s the exact xenstore entry for that device and all other configuration info= rmation is specified there e.g whether it's a vif, vbd, 9p or whatever. The= correct backend can then be kicked off directly. No scanning required. No = stealing required. As for the device type, would it not be best to have a proper XENBUS bus ty= pe? All the code which actually talks to xenstore could be collected there = and then you could have all XENBUS_DEVICEs using that common code via the c= lass hierarchy? Paul > # Option 3: Only use -fsdev >=20 > The third way of doing it would be to not use QEMU command line to > create device at all. We only use -fsdev to create fsdev and in > xen_init_pv we reply on information in xenstore to create 9pfs > transport. In this case: >=20 > 1. Toolstack arranges some xenstore entries. > 2. Toolstack arranges command line options for QEMU: > -fsdev XXX > 3. QEMU starts up in xen-attach mode, scans xenstore for relevant > entries, creates 9pfs transport on the fly. >=20 > Downside: This seems to deviate from how we do things before > (comparing with other device like nic and disk). >=20 > # Option 4 >=20 > If you have other ideas, do let me know. :-) >=20 > Comments are welcome. I would like to know your opinions before > actually writing code. >=20 >=20 > Wei.