[Libvir] [PATCH] Check the version of Xen in xenDaemonAttachDevice()

Hi When virsh attach-disk/attach-interface is executed in < Xen 3.0.4, the OS type of domain is NULL in xenDaemonAttachDevice(). As a result, the command becomes segmentation fault. This patch fixes it by checking the version of Xen in xenDaemonAttachDevice(). Signed-off-by: Masayuki Sunou <fj1826dm@aa.jp.fujitsu.com> Thanks, Masayuki Sunou. ---------------------------------------------------------------------- Index: src/xend_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.c,v retrieving revision 1.132 diff -u -p -r1.132 xend_internal.c --- src/xend_internal.c 9 Aug 2007 20:19:12 -0000 1.132 +++ src/xend_internal.c 16 Aug 2007 07:38:42 -0000 @@ -3091,6 +3091,9 @@ xenDaemonAttachDevice(virDomainPtr domai priv = (xenUnifiedPrivatePtr) domain->conn->privateData; + if (domain->id < 0 && priv->xendConfigVersion < 3) + return(-1); + str = virDomainGetOSType(domain); if (strcmp(str, "linux")) hvm = 1; ----------------------------------------------------------------------

On Thu, Aug 16, 2007 at 05:41:47PM +0900, Masayuki Sunou wrote:
Hi
When virsh attach-disk/attach-interface is executed in < Xen 3.0.4, the OS type of domain is NULL in xenDaemonAttachDevice(). As a result, the command becomes segmentation fault.
This patch fixes it by checking the version of Xen in xenDaemonAttachDevice().
Signed-off-by: Masayuki Sunou <fj1826dm@aa.jp.fujitsu.com> [...]
+ if (domain->id < 0 && priv->xendConfigVersion < 3) + return(-1); + str = virDomainGetOSType(domain); if (strcmp(str, "linux")) hvm = 1;
I do not understand the patch. Why is that dependant on domain->id < 0 ? Can you explain the logic there ? Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Thu, Aug 16, 2007 at 09:27:04AM -0400, Daniel Veillard wrote:
On Thu, Aug 16, 2007 at 05:41:47PM +0900, Masayuki Sunou wrote:
Hi
When virsh attach-disk/attach-interface is executed in < Xen 3.0.4, the OS type of domain is NULL in xenDaemonAttachDevice(). As a result, the command becomes segmentation fault.
This patch fixes it by checking the version of Xen in xenDaemonAttachDevice().
Signed-off-by: Masayuki Sunou <fj1826dm@aa.jp.fujitsu.com> [...]
+ if (domain->id < 0 && priv->xendConfigVersion < 3) + return(-1); + str = virDomainGetOSType(domain); if (strcmp(str, "linux")) hvm = 1;
I do not understand the patch. Why is that dependant on domain->id < 0 ? Can you explain the logic there ?
That just ensures that this command fails in a sensible way with inactive guests when run on older XenD without the inactive domain management APIs. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Thu, Aug 16, 2007 at 02:56:07PM +0100, Daniel P. Berrange wrote:
On Thu, Aug 16, 2007 at 09:27:04AM -0400, Daniel Veillard wrote:
On Thu, Aug 16, 2007 at 05:41:47PM +0900, Masayuki Sunou wrote:
Hi
When virsh attach-disk/attach-interface is executed in < Xen 3.0.4, the OS type of domain is NULL in xenDaemonAttachDevice(). As a result, the command becomes segmentation fault.
This patch fixes it by checking the version of Xen in xenDaemonAttachDevice().
Signed-off-by: Masayuki Sunou <fj1826dm@aa.jp.fujitsu.com> [...]
+ if (domain->id < 0 && priv->xendConfigVersion < 3) + return(-1); + str = virDomainGetOSType(domain); if (strcmp(str, "linux")) hvm = 1;
I do not understand the patch. Why is that dependant on domain->id < 0 ? Can you explain the logic there ?
That just ensures that this command fails in a sensible way with inactive guests when run on older XenD without the inactive domain management APIs.
Oh right, a domain->inactive flag or some such would be so much more readable. Applied and commited then ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Masayuki Sunou