Bug 1327578 - xen xm parser assumes 'extra' is always present if 'root' specified
Summary: xen xm parser assumes 'extra' is always present if 'root' specified
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard: LibvirtFirstBug
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-15 12:41 UTC by Cole Robinson
Modified: 2018-05-15 13:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-15 13:38:08 UTC
Embargoed:


Attachments (Terms of Use)

Description Cole Robinson 2016-04-15 12:41:20 UTC
(from bug 584777)

# cat f
kernel      = '/boot/vmlinuz-2.6.26-2-xen-amd64'
ramdisk     = '/boot/initrd.img-2.6.26-2-xen-amd64'
memory      = '128'
root        = '/dev/xvda2 ro'
disk        = [
                  'file:/opt/xen/domains/domU/swap.img,xvda1,w',
                  'file:/opt/xen/domains/domU/disk.img,xvda2,w',
              ]
name        = 'domU'
dhcp        = 'dhcp'
vif = [ 'mac=00:16:3E:70:61:00,bridge=xenbr0' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

# sudo virsh domxml-from-native xen-xm f | grep cmdline
    <cmdline>root=/dev/xvda2 ro (null)</cmdline>


Notice the '(null)' bit. If root= is specified, the code expects that extra= was always specified too. The code is in src/xenconfig/xen_xm.c:

        if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
            return -1;

        if (xenConfigGetString(conf, "root", &root, NULL) < 0)
            return -1;

        if (root) {
            if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0)
                return -1;
        } else {
            if (VIR_STRDUP(def->os.cmdline, extra) < 0)
                return -1;

root and extra need to be handled separately. Note, this can be tested without a xen setup, just drop that xm config in tests/xmconfigdata and extend tests/xmconfigtest.c to test it.

Comment 1 Cole Robinson 2018-05-15 13:38:08 UTC
Upstream now:

commit 656151bf5dd299322dcf37d06d20534e667a1963
Author: Filip Alac <filipalac>
Date:   Sat May 12 17:45:02 2018 +0200

    xenconfig: xm: Fix checking for extra in parser


Note You need to log in before you can comment on or make changes to this bug.