<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 4, 2018 at 6:24 PM, John Ferlan <span dir="ltr"><<a href="mailto:jferlan@redhat.com" target="_blank">jferlan@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
On 05/21/2018 07:10 AM, Prerna Saxena wrote:<br>
> Augment definition to include virStorageSourcePtr that<br>
> more comprehensively describes the nature of backing element.<br>
> Also include flags for annotating if input XML definition is<br>
> old-style or new-style.<br>
> <br>
> 2) Parse domain XML to generate virDomainLoaderDef & virDomainNvramDef.<br>
> <br>
> This patch is used to interpret domain XML and store the Loader &<br>
> Nvram's backing definitions as virStorageSource.<br>
> It also identifies if input XML used old or new-style declaration.<br>
> (This will later be used by the formatter).<br>
> <br>
> 3) Format the loader source appropriately.<br>
> <br>
> If the initial XML used the old-style declaration as follows:<br>
> <loader type='pflash'>/path/to/file</<wbr>loader><br>
> <br>
> we format it as was read.<br>
> <br>
> However, if it used new-style declaration:<br>
> <loader type='pflash' backing='file'><br>
>   <source file='path/to/file'/><br>
> </loader><br>
> <br>
> The formatter identifies that this is a new-style format<br>
> and renders it likewise.<br>
> <br>
> 4) Plumb the loader source into generation of QEMU command line.<br>
> <br>
> Given that nvram & loader elements can now be backed by a non-local<br>
> source too, adjust all steps leading to generation of<br>
> QEMU command line.<br>
> <br>
> 5) Fix the domain def inference logic to correctly account for network-backed<br>
> pflash devices.<br>
> <br>
> 6) Bhyve: Fix command line generation to correctly pick up local loader path.<br>
> <br>
> 7) virt-aa-helper: Adjust references to loader & nvram elements to correctly<br>
> parse the virStorageSource types.<br>
> <br>
> 8) Vbox: Adjust references to 'loader' and 'nvram' elements given that<br>
> these are now represented by virStorageSourcePtr.<br>
> <br>
> 9)Xen: Adjust all references to loader & nvram elements given that they are now backed by virStorageSourcePtr<br>
> ---<br>
>  src/bhyve/bhyve_command.c       |   6 +-<br>
>  src/conf/domain_conf.c          | 250 ++++++++++++++++++++++++++++++<wbr>+++++++---<br>
>  src/conf/domain_conf.h          |  11 +-<br>
>  src/qemu/qemu_cgroup.c          |  13 ++-<br>
>  src/qemu/qemu_command.c         |  21 +++-<br>
>  src/qemu/qemu_domain.c          |  31 +++--<br>
>  src/qemu/qemu_driver.c          |   7 +-<br>
>  src/qemu/qemu_parse_command.c   |  30 ++++-<br>
>  src/qemu/qemu_process.c         |  54 ++++++---<br>
>  src/security/security_dac.c     |   6 +-<br>
>  src/security/security_selinux.<wbr>c |   6 +-<br>
>  src/security/virt-aa-helper.c   |  14 ++-<br>
>  src/vbox/vbox_common.c          |  11 +-<br>
>  src/xenapi/xenapi_driver.c      |   4 +-<br>
>  src/xenconfig/xen_sxpr.c        |  19 +--<br>
>  src/xenconfig/xen_xm.c          |   9 +-<br>
>  16 files changed, 409 insertions(+), 83 deletions(-)<br>
> <br>
<br>
</div></div>The $SUBJ and commit message are just poorly formatted.<br>
<br>
But it pretty much shows that everything just got thrown into this one<br>
patch and you went from there.<br>
<br>
This series needs to progress a bit more "reasonably" to the desired<br>
goal. Consider this progression (with the following as patch 1 of the<br>
entire series):<br>
<br>
1. Change path of loader to union:<br>
<br>
struct _virDomainLoaderDef {<br>
    union {<br>
        char *path;<br>
    } loader;<br>
<br>
then compile/fix up references.<br>
<br>
2. Create an accessor to loader.path - that way future consumers can<br>
just fetch the source path, e.g.:<br>
<br>
const char *<br>
virDomainLoaderDefGetLoaderPat<wbr>h(virDomainLoaderDefPtr loader)<br>
{<br>
    return loader->loader.path;<br>
}<br>
<br>
Anything that accesses loader.path should change to use this via<br>
something like:<br>
<br>
    const char *loaderPath;<br>
...<br>
    loaderPath = virDomainLoaderDefGetLoaderPat<wbr>h(xxx)<br>
...<br>
<br>
Eventually this code will return either loader.path or loader.src->path<br>
since both FILE and NETWORK storage use src->path.<br>
<br>
3. Add virStorageSourcePtr to the loader union and modify places in the<br>
code to use/read it. Update the domaincommon.rng, update formatdomain to<br>
describe usage of <source> for <loader>, add genericxml2xmltests for<br>
both "loader-source-file" and "loader-source-network" type formats for<br>
at least "type='rom'". You could add type='pflash' tests too...<br>
<br>
...<br>
    union {<br>
        char *path;<br>
        virStorageSourcePtr src;<br>
    } loader;<br>
    bool useLoaderSrc;<br>
...<br>
<br>
The patch code to parse needs to be changed to follow more closely what<br>
virDomainDisk{BackingStore|<wbr>DefMirror}Parse does...  Alter ctxt locally<br>
to the passed @node (and restore at the end).  It should also be able to<br>
use the union to do the magic, consider:<br>
<br>
    loader->loader.path = (char *) xmlNodeGetContent(node);<br>
<br>
    /* When not present, could return '' */<br>
    if (virStringIsEmpty(loader-><wbr>loader.path))<br>
        VIR_FREE(loader->loader.path);<br>
<br>
    /* See if we need to look for new style <source...> subelement */<br>
    if (!loader->loader.path) {<br>
        xmlNodePtr source;<br>
<br>
        if (!(source = virXPathNode("./source", ctxt))) {<br>
            virReportError(VIR_ERR_XML_<wbr>ERROR, "%s"<br>
                           _("missing os loader source"));<br>
            goto cleanup;<br>
        }<br>
<br>
        if (VIR_ALLOC(loader->loader.src) < 0)<br>
            goto cleanup;<br>
<br>
        if ((tmp = virXMLPropString(source, "file")))<br>
            loader->loader.src->type = VIR_STORAGE_TYPE_FILE;<br>
        else if ((tmp = virXMLPropString(source, "protocol")))<br>
            loader->loader.src->type = VIR_STORAGE_TYPE_NETWORK;<br>
<br>
        if (loader->loader.src->type == VIR_STORAGE_TYPE_NONE) {<br>
            virReportError(VIR_ERR_XML_<wbr>ERROR,<br>
                           _("unknown loader source type: '%s"), tmp);<br>
            goto cleanup;<br>
        }<br>
<br>
        if (virDomainStorageSourceParse(<wbr>source, ctxt,<br>
loader->loader.src, 0) < 0)<br>
            goto cleanup;<br>
<br>
        loader->useLoaderSrc = true;<br>
    }<br>
<br>
<br>
Then do the similar set of changes for nvram...  Although for this one -<br>
it's slightly trickier since <nvram> is optional...  You'll probably<br>
also need to modify qemuDomainDefPostParse to not automagically generate<br>
an nvram.path if you're using <source>.<br>
<br>
Once the xml2xml portion is done, the next patch alters qemu_command,<br>
adds more tests, etc. Since you have generic xml2xml files, you probably<br>
could just create a link from the qemuxml2argvdata directory or<br>
create/use new files.  Eventually it'd be nice for hte qemuxml2* code to<br>
be able to use the generic xml files, but that's outside this scope.<br>
<br>
BTW: I wouldn't bother with too many qemu_parse_command.c changes. Just<br>
do the minimum. That code is so far out of date it's going to take a<br>
solid effort to bring it back to today's options.<br>
<br>
In any case, there's a lot of changes to be made so it's really not<br>
worth going through each of the files in depth... I'll just point out<br>
the domain_conf.h changes.<br></blockquote><div><br></div><div>Thanks John for the elaborate review. I will start in this direction and post the next series asap.</div></div></div></div>