From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYGjq-00032i-BH for qemu-devel@nongnu.org; Fri, 03 May 2013 10:13:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYGjo-0004l4-LZ for qemu-devel@nongnu.org; Fri, 03 May 2013 10:13:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYGU2-0008Qa-C6 for qemu-devel@nongnu.org; Fri, 03 May 2013 09:57:10 -0400 Date: Fri, 3 May 2013 14:57:06 +0100 From: "Daniel P. Berrange" Message-ID: <20130503135706.GM20766@redhat.com> References: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> <1367005387-330-4-git-send-email-aliguori@us.ibm.com> <20130502084926.GA30664@dhcp-200-207.str.redhat.com> <878v3x4hy9.fsf@codemonkey.ws> <20130502140622.GC30664@dhcp-200-207.str.redhat.com> <87obct4ch5.fsf@codemonkey.ws> <20130503123157.GH20766@redhat.com> <87ppx85fwk.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87ppx85fwk.fsf@codemonkey.ws> Subject: Re: [Qemu-devel] [libvirt] [PATCH 3/3] gtk: add devices menu to allow changing removable block devices Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Kevin Wolf , Libvirt , qemu-devel@nongnu.org On Fri, May 03, 2013 at 08:52:59AM -0500, Anthony Liguori wrote: > "Daniel P. Berrange" writes: > > > On Thu, May 02, 2013 at 10:40:06AM -0500, Anthony Liguori wrote: > >> Kevin Wolf writes: > >> >> >> + > >> >> >> + if (strcmp(type, "ide-cd") == 0) { > >> >> >> + disk_type = DT_CDROM; > >> >> >> + } else if (strcmp(type, "isa-fdc") == 0) { > >> >> >> + disk_type = DT_FLOPPY; > >> >> >> + } else { > >> >> >> + disk_type = DT_NORMAL; > >> >> >> + } > >> >> > > >> >> > Same thing here, comparing against strings is a hack. Devices should > >> >> > probably have a property that says what kind of device they are. > >> >> > >> >> Ack, this is nasty. I would like to eliminate this. There is a type > >> >> field in BlockInfo but: > >> >> > >> >> # @type: This field is returned only for compatibility reasons, it should > >> >> # not be used (always returns 'unknown') > >> >> > >> >> I vaguely remember this happening but I don't remember the specific > >> >> reason why. I would definitely prefer that we filled out type > >> >> correctly. > >> >> > >> >> I think Markus was involved in this. Markus or Luiz, do you remember > >> >> the story here? > >> > > >> > The reason is that BlockInfo is about the backend and it simply doesn't > >> > know (ever since we introduced if=none, this was buggy, so we just > >> > abandoned it at some point). We would have to ask the device, not the > >> > block layer. > >> > >> Yes, this makes sense. We could introduce an interface that all disks > >> implemented that returned information about whether it was a CD-ROM, > >> Floppy, etc. > >> > >> How does libvirt cope with this today? I presume they do something > >> similar to what this patch is doing in terms of hard coding device > >> names. > > > > Sorry, not really sure what your question is here - how does libvirt > > cope with what exactly ? > > Given a device, how do you figure out if it's a cdrom/floppy/whatever > without hard coding a mapping of class name -> device type. > > Pretty sure libvirt just has a class name mapping, right? The only place where we'd ever need todo that is when we reverse engineer a libvirt XML config from a set of QEMU command line args. For that we just look at the if=XXX parameter currently. Our reverse engineering code is currently broken for if=none scenarios, due mostly to our laziness in writing code to parse the corresponding -device arg. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|