Skip to contentSkip to conversation

Fix change of CDROM for block-configure command

PATCH In review Kasai Takanori 2 participants 3 messages Jun 19, 2007 – Jun 20, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix change of CDROM for block-configure command

Hi All,

We contributed the problem when CD-ROM was changed as follows. There was especially no comment though we confirmed the correction method. Therefore, the patch that corrects these problems is contributed.

Best Regards,

---
Takanori Kasai

----- Original Message ----- From: "Kasai Takanori" <[email protected]>
To: "xen-devel" <[email protected]>
Sent: Thursday, June 14, 2007 7:30 PM
Subject: [Xen-devel] About change of CDROM

Quoted 67 lines

Hi All,

We tested xm block-configure command.
Because when the domain image is made, we install it from multiple CDROM.

The procedure of the installation is as follows.
1) The HVM domain is started with the CDROM device. ・configuration file :
 disk = [
'file:/xen/test/install-test.img,hda,w','phy:/dev/cdrom,hdc:cdrom,r' ]
 boot="d"
2) When the installation from CDROM of the first piece is completed, CDROM is exchanged.
3) The exchange of CD-ROM is set by the xm block-configure command.

 # xm block-configure <DomID> phy:/dev/cdrom hdc:cdrom r
4) The installation from CDROM of the second piece is continued.

However, there are two problems in this procedure.
1) It takes time to recognize the exchange of CDROM.
2) Even if the same device is specified, it is not recognized.

We investigated these problems.

1) It takes time to recognize the exchange of CDROM.

The problem that it takes time for recognition is to wait intentionally on the qemu-dm side.
・tools/ioemu/xenstore.c
314 void xenstore_process_event(void *opaque)
315 {
...
343 if (image[0]) {
344 media_filename[hd_index] = strdup(image);
345 xenstore_check_new_media_present(5000); << This
346 }

The processing recognized after it waits for five seconds is executed. We think that this waiting is unnecessary after exchanges CDROM.

Why do you wait for five seconds before CDROM recognizes it? If it is unnecessary, we want to correct not to wait.

2) Even if the same device is specified, it is not recognized.

Therefore, we allocated it in other devices once.

# xm block-configure <DomID> phy:/dev/null hdc:cdrom r
# xm block-configure <DomID> phy:/dev/cdrom hdc:cdrom r

It is made not to recognize that the same device is specified in qemu-dm. ・tools/ioemu/xenstore.c
314 void xenstore_process_event(void *opaque)
315 {
...
332 image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len);
333 if (image == NULL || !strcmp(image, bs_table[hd_index]->filename)) <<
This
334 goto out; /* gone or identical */

It doesn't operate because it becomes naturally the same name when physics CDROM is allocated.
Even if the name is the same, the content might be not same. Only when CDROM is exchanged, it is executed.

When the same device is specified, should we check it? We want to correct not to check it.

Quoted 7 lines

We have confirmed these problems are canceled by the appended patch.

Best Regards,

--
Takanori Kasai

# HG changeset patch
# User [email protected]
# Date 1182234223 -32400
# Node ID 0ac9a762d013746efe81ccefeea7ed9e143bd3a8 # Parent c82934987a257e49101b657c54fea0a27b7d25e5 Do not check the same device

tools/ioemu/xenstore.c +1 -1
diff -r c82934987a25 -r 0ac9a762d013 tools/ioemu/xenstore.c
@@ -330,7 +330,7 @@ void xenstore_process_event(void *opaque
         goto out;
     hd_index = vec[XS_WATCH_TOKEN][2] - 'a';
     image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len);
-    if (image == NULL || !strcmp(image, bs_table[hd_index]->filename))
+    if (image == NULL)
         goto out;  /* gone or identical */
 
     do_eject(0, vec[XS_WATCH_TOKEN]);

# HG changeset patch
# User [email protected]
# Date 1182233964 -32400
# Node ID c82934987a257e49101b657c54fea0a27b7d25e5 # Parent c3f280acf41af0ca876002e6e501cd67e72b3725 Do not wait by changing CDROM.

tools/ioemu/xenstore.c +1 -1
diff -r c3f280acf41a -r c82934987a25 tools/ioemu/xenstore.c
@@ -342,7 +342,7 @@ void xenstore_process_event(void *opaque
 
     if (image[0]) {
         media_filename[hd_index] = strdup(image);
-        xenstore_check_new_media_present(5000);
+        xenstore_check_new_media_present(0);
     }
 
  out:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

ioemu-nowait-change: This 5s timeout is deliberate. If the media change event is not delayed by some significant amount of time after the eject event, Windows guests ignore the media change! The only fix we discovered for this was to add the large timeout (but in fact Windows polls the CD-ROM before that triggers, so in fact it detects the media significantly before the 5 second delay is finished).

ioemu-nocheck-change: The strcmp is deliberate, to filter out redundant firings of the xenstore watch. If you want to be able to e.g., notify of changes to '/dev/cdrom' then that should be implemented at a higher level (e.g., in xend) by writing an empty string to xenstore, immediately followed by '/dev/cdrom' (or whatever filename).

-- Keir

Quoted 101 lines · Kasai Takanori

Hi All,

We contributed the problem when CD-ROM was changed as follows. There was especially no comment though we confirmed the correction method. Therefore, the patch that corrects these problems is contributed.

Best Regards,

---
Takanori Kasai

----- Original Message -----
From: "Kasai Takanori" <[email protected]>
To: "xen-devel" <[email protected]>
Sent: Thursday, June 14, 2007 7:30 PM
Subject: [Xen-devel] About change of CDROM

Quoted 69 lines

Hi All,

We tested xm block-configure command.
Because when the domain image is made, we install it from multiple CDROM.

The procedure of the installation is as follows.
1) The HVM domain is started with the CDROM device. ・configuration file :
 disk = [
'file:/xen/test/install-test.img,hda,w','phy:/dev/cdrom,hdc:cdrom,r' ]
 boot="d"
2) When the installation from CDROM of the first piece is completed, CDROM is exchanged.
3) The exchange of CD-ROM is set by the xm block-configure command.

 # xm block-configure <DomID> phy:/dev/cdrom hdc:cdrom r
4) The installation from CDROM of the second piece is continued.

However, there are two problems in this procedure.
1) It takes time to recognize the exchange of CDROM.
2) Even if the same device is specified, it is not recognized.

We investigated these problems.

1) It takes time to recognize the exchange of CDROM.

The problem that it takes time for recognition is to wait intentionally on the
qemu-dm side.
・tools/ioemu/xenstore.c
314 void xenstore_process_event(void *opaque)
315 {
...
343 if (image[0]) {
344 media_filename[hd_index] = strdup(image);
345 xenstore_check_new_media_present(5000); << This
346 }

The processing recognized after it waits for five seconds is executed. We think that this waiting is unnecessary after exchanges CDROM.

Why do you wait for five seconds before CDROM recognizes it? If it is unnecessary, we want to correct not to wait.

2) Even if the same device is specified, it is not recognized.

Therefore, we allocated it in other devices once.

# xm block-configure <DomID> phy:/dev/null hdc:cdrom r
# xm block-configure <DomID> phy:/dev/cdrom hdc:cdrom r

It is made not to recognize that the same device is specified in qemu-dm. ・tools/ioemu/xenstore.c
314 void xenstore_process_event(void *opaque)
315 {
...
332 image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len);
333 if (image == NULL || !strcmp(image, bs_table[hd_index]->filename))
<<
This
334 goto out; /* gone or identical */

It doesn't operate because it becomes naturally the same name when physics CDROM is allocated.
Even if the name is the same, the content might be not same. Only when CDROM is exchanged, it is executed.

When the same device is specified, should we check it? We want to correct not to check it.

Quoted 7 lines

We have confirmed these problems are canceled by the appended patch.

Best Regards,

--
Takanori Kasai

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Hi Keir,

Thank you for reply.

Quoted 1 line

ioemu-nowait-change: This 5s timeout is deliberate.

We consented that waiting was necessary for the Windows guest.

Quoted 2 lines

ioemu-nocheck-change: The strcmp is deliberate, to filter out redundant firings of the xenstore watch. If you want to be able to e.g., ...

We corrected the patch like writing an empty once character in xend.

BTW, there is an acute problem in the change of CDROM.

When physical device (/dev/cdrom) of CDROM is set first, CDROM of the second piece cannot be correctly read.

It remains opening former device on backend even if it changes with block-configure.

Therefore, CDROM of the second piece can read only the size of the first piece.

linux-2.6.18-xen.hg/drivers/xen/blkback/xenbus.c 264 static void backend_changed(struct xenbus_watch *watch,
265 const char **vec, unsigned int len)
...
315 err = vbd_create(be->blkif, handle, major, minor,
316 (NULL == strchr(be->mode, 'w')));

How do you think that we should correct about this problem?

Best Regards,

--
Takanori Kasai

# HG changeset patch
# User [email protected]
# Date 1182309779 -32400
# Node ID d8431f7e8a3038ca9aa27a7dae614e4aa46974e3
# Parent fb5077ecf9a440ab4fa128788172ce604c4b28f2
Fix writing an empty character string to xenstore for block-configure.

tools/python/xen/xend/server/blkif.py +5 -0
diff -r fb5077ecf9a4 -r d8431f7e8a30 tools/python/xen/xend/server/blkif.py
@@ -98,6 +98,11 @@ class BlkifController(DevController):
 
         if (dev_type == 'cdrom' and new_front['device-type'] == 'cdrom' and
             dev == new_back['dev'] and mode == 'r'):
+            # dummy device
+            self.writeBackend(devid,
+                              'type', new_back['type'],
+                              'params', '')
+            # new backend-device
             self.writeBackend(devid,
                               'type', new_back['type'],
                               'params', new_back['params'])

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel