Bug 747290

Summary: libguestfs ignores <readonly/> in libvirt XML
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: berrange, mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-26 18:35:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Richard W.M. Jones 2011-10-19 11:34:05 UTC
Description of problem:

A fairly typical configuration is a guest which has a
read-only CD-ROM ISO file attached.

However if you open this guest with
guestfish --rw -d GuestName
or equivalently with guestfs_add_domain (without the
readonly flag) then libguestfs tries to open the CD-ROM
file for writes.

It's not completely clear what we should be doing.  Possibly
one of:

(a) open the disk read-only, even if the readonly flag is not set
(b) error if the readonly flag is not set and a disk is <readonly/>
(c) (b) + an extra flag to select fallback mode (a)

Version-Release number of selected component (if applicable):

1.13.21

How reproducible:

100%

Comment 1 Daniel Berrangé 2011-10-19 11:43:52 UTC
I don't think there's any perfect answer here.

You have a guest XML with 2 (or more) disks

  1. Primary disk, read-write
  2. Secondary disk, marked read-only

Then, if you run  guestfish --rw, there are two possible desirable outcomes

  a. Both disks opened read-write.
  b. Primary disk opened read-write, secondary disk read-only

I think 'b' makes sense as the default, since that is honouring the guest definition, however, I could see a very occasional need to do 'a'. eg if the read-only disk, was in fact some shared HD that the guests normally share read-only, but you want to make some changes to now.

Comment 2 Richard W.M. Jones 2011-10-26 18:35:29 UTC
Fixed upstream in libguestfs 1.13.26.

** Dan **:

A useful feature for the libvirt test:/// XML would be the
ability to start off a test domain in a state other than
"running", ie. shut off.

At the moment it's hard to create automated tests for this
feature because libguestfs prevents you from trying to open
a domain for write when it thinks it is running.

See:
http://git.annexia.org/?p=libguestfs.git;a=blob;f=regressions/test-add-domain.sh;hb=HEAD

Comment 3 Daniel Berrangé 2011-10-27 08:08:58 UTC
@rjones: while you can't make the test driver open with an existing shutoff domain, you can make it open with no existing domains, and then just use virDomainDefineXML to create yourself a shutoff guest. Use test:///path/to/node.xml - see examples/xml/test/testnode.xml for an example of syntax

Comment 4 Richard W.M. Jones 2011-10-27 08:14:56 UTC
Sure, I realized that (or conversely: start with a running
domain and call virDomainShutdown on it).

However if you look at the test (comment 2) you'll see I'm
not in a position to make libvirt API calls.  It would be nice
if it was directly available in the XML.