Received: from eggs.gnu.org ([2001:4830:134:3::10]:33681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZV0Mw-0003MH-Af for qemu-devel@nongnu.org; Thu, 27 Aug 2015 12:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZV0Mr-0001aQ-6r for qemu-devel@nongnu.org; Thu, 27 Aug 2015 12:49:42 -0400 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]:34007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZV0Mq-0001a8-VQ for qemu-devel@nongnu.org; Thu, 27 Aug 2015 12:49:37 -0400 Received: by qgeg42 with SMTP id g42so14239894qge.1 for ; Thu, 27 Aug 2015 09:49:36 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: <20150827162219.GC24486@redhat.com> Date: Thu, 27 Aug 2015 12:49:33 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <4225C154-6315-484A-9A6B-72F0324D0D07@gmail.com> References: <20150827134943.GS24486@redhat.com> <37557843-A1BA-4822-9933-B0B8AD588C90@gmail.com> <55DF1884.2030608@redhat.com> <20150827144253.GX24486@redhat.com> <20150827154057.GE2669@localhost.localdomain> <068B4976-968C-45A3-9219-77FB600BC257@gmail.com> <20150827160217.GA24486@redhat.com> <868FF75F-04AA-40CB-84D5-A4DFB3D06749@gmail.com> <20150827162219.GC24486@redhat.com> Subject: Re: [Qemu-devel] Should we auto-generate IDs? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Kevin Wolf , jsnow@redhat.com, Jeff Cody , Markus Armbruster , qemu-devel qemu-devel , Paolo Bonzini , =?iso-8859-1?Q?Andreas_F=E4rber?= On Aug 27, 2015, at 12:22 PM, Daniel P. Berrange wrote: > On Thu, Aug 27, 2015 at 12:08:25PM -0400, Programmingkid wrote: >>=20 >> On Aug 27, 2015, at 12:02 PM, Daniel P. Berrange wrote: >>=20 >>> On Thu, Aug 27, 2015 at 11:58:22AM -0400, Programmingkid wrote: >>>>=20 >>>> On Aug 27, 2015, at 11:40 AM, Jeff Cody wrote: >>>>=20 >>>>> On Thu, Aug 27, 2015 at 11:20:20AM -0400, Programmingkid wrote: >>>>>>=20 >>>>>> On Aug 27, 2015, at 10:42 AM, Daniel P. Berrange wrote: >>>>>>=20 >>>>>>> On Thu, Aug 27, 2015 at 10:34:05AM -0400, Programmingkid wrote: >>>>>>>>=20 >>>>>>>> On Aug 27, 2015, at 10:02 AM, Eric Blake wrote: >>>>>>>>=20 >>>>>>>>> On 08/27/2015 07:56 AM, Programmingkid wrote: >>>>>>>>>=20 >>>>>>>>>>> If we did have auto-generated names, we would need to come = up with a >>>>>>>>>>> scheme that is not going to clash with any existing naming = that users >>>>>>>>>>> of QEMU may already be doing, otherwise we risk causing a = regression. >>>>>>>>>>> Something as simple as what you suggest has non-trivial = chance of >>>>>>>>>>> clashing. >>>>>>>>>>=20 >>>>>>>>>> Actually there is a way to prevent clashing. When QEMU = auto-generates a >>>>>>>>>> name, it could scan all the ID's to see if there is a clash. = If the ID is already >>>>>>>>>> taken, just increment the ID until it is detected to be = unique. The previous >>>>>>>>>> threads on this subject has patches that did just that. This = means that a >>>>>>>>>> ID scheme that is just a single number would work without = clashes.=20 >>>>>>>>>=20 >>>>>>>>> No, because you cannot predict what FUTURE names the user will = request. >>>>>>>>> The name generated by qemu must be IMPOSSIBLE to request = manually, and >>>>>>>>> not just one that happens not to clash at the current moment. >>>>>>>>=20 >>>>>>>> If I add a device with an ID that is taken, QEMU can just say = sorry that ID is already >>>>>>>> taken. I could just increment the ID myself until I find one = that is unique. It is a >>>>>>>> simple algorithm. Maybe you are talking about some program that = has hard coded >>>>>>>> ID's it depends on. If that is the case, perhaps this = management program could be >>>>>>>> made to be a little flexible. Or use a 160-bit SHA-1 generated = ID that is virtually >>>>>>>> guaranteed to always be unique. >>>>>>>=20 >>>>>>> If breaking existing apps was OK, we would just mandate that = users always >>>>>>> provide an ID which trivially avoids the problem of not having = an ID to >>>>>>> use when deleting the object. We want to /avoid/ breaking = existing apps >>>>>>> though, so saying an app should change the way it works in order = to cope >>>>>>> with QEMU's ID generation is not appropriate. Hence any use of = auto-generated >>>>>>> IDs, must use a separate namespace to avoid such clashes. >>>>>>=20 >>>>>> This is making the assumption that an auto-generated ID system = would break any existing >>>>>> application. We don't know this. In fact, I predict a future = patch would allow existing >>>>>> applications to continue running without modification. The patch = would be a win-win >>>>>> for both users and any management application. >>>>>>=20 >>>>>=20 >>>>> Daniel's assumption is spot on. The idea of "QEMU can just say = sorry >>>>> that ID is already taken" will break existing applications. >>>>>=20 >>>>> But we are all striving to make your prediction true, with this = very >>>>> conversation. >>>>=20 >>>> Ok, it sounds like some are concerned that Libvirt would not be = able to work with this >>>> feature. Let me ask you this: does Libvirt interact with QEMU = before the user has a >>>> chance to do so? If the answer is yes, then that means Libvirt will = have finished=20 >>>> creating all its devices with their ID's long before the user has a = chance to enter >>>> his own devices. >>>=20 >>> Just to be clear - libvirt will *never* use an auto-generated device >>> IDs feature. It is way more complicated to let QEMU assign device = IDs >>> and then auto-detect them from some 'info device-list' output, than >>> to just specify IDs upfront at device/object creation time which >>> it already does[1]. There is simply no benefit to auto-generating = device >>> IDs for a mgmt app like libvirt, and plenty of downside. = Auto-generated >>> IDs will only be of interest to humans talking to the monitor = directly >>> without a mgmt app involved. >>=20 >> I've haven't used Libvirt but I do believe in the saying "never say = never". The >> rest of what you said does sound accurate.=20 >=20 > I say that based on history of the development of libvirt. Many, many > years ago now, with QEMU 0.8.x, -device / device_add did not exist, > so you had to configure devices using args like -drive, or before > that, -hda, -hdb, etc. With that old syntax, QEMU would in fact > auto-generate a unique ID for each device. Libvirt then had to > figure out what that unique ID would be which was non-trivial to > get right, and risked changing with new QEMU releases. It also > did not cope well when hotplug was combined with migraiton, as > two guest machines with identical guest hardware could have > different assigned IDs depending on the sequence of hotplug/unplug > operations performed. All in all it was a world of hurt and > we were very happy when -device came along and allowed libvirt > to specify the deivce IDs upfront itself. So yes, I am confident > we will not go back to letting QEMU auto-generate IDs in libvirt. Thank you very much for this history. I didn't know about this.=20=