Re: [libvirt] [PATCH] Implement autostart commands for xen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 07, 2008 at 04:21:25PM -0400, Cole Robinson wrote:
> +int
> +xenDaemonDomainGetAutostart(virDomainPtr domain,
> +                            int *autostart)
> +{
> +    struct sexpr *root;
> +    const char *tmp;
> +
> +    if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
> +        virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
> +                     __FUNCTION__);
> +        return (-1);
> +    }

Since this only works in Xen 3.0.4 or later can you add in:

    /* xm_internal.c (the support for defined domains from /etc/xen
     * config files used by old Xen) will handle this.
     */
    if (priv->xendConfigVersion < 3)
        return(-1);

This ensures that users will get a 'operation not supported' error for older
XenD - at least until we implement the alternate /etc/xen/auto symlink scheme
for xm_internal.c driver.


> +xenDaemonDomainSetAutostart(virDomainPtr domain,
> +                            int autostart)
> +{
> +    struct sexpr *root, *autonode;
> +    const char *autostr;
> +    char buf[4096];
> +    int ret = -1;
> +
> +    if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
> +        virXendError((domain ? domain->conn : NULL), VIR_ERR_INTERNAL_ERROR,
> +                     __FUNCTION__);
> +        return (-1);
> +    }

Same here - add a xendConfigVersion check.

> +    root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
> +    if (root == NULL) {
> +        virXendError (domain->conn, VIR_ERR_XEN_CALL,
> +                      _("xenDaemonSetAutostart failed to find this domain"));
> +        return (-1);
> +    }
> +
> +    autostr = sexpr_node(root, "domain/on_xend_start");
> +    if (autostr) {
> +        if (!STREQ(autostr, "ignore") && !STREQ(autostr, "start")) {
> +            virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
> +                         _("unexpected value from on_xend_start"));
> +            goto error;
> +        }
> +
> +        // Change the autostart value in place, then define the new sexpr
> +        autonode = sexpr_lookup(root, "domain/on_xend_start");
> +        free(autonode->u.s.car->u.value);
> +        autonode->u.s.car->u.value = (autostart ? strdup("start")
> +                                                : strdup("ignore"));
> +        if (!(autonode->u.s.car->u.value)) {
> +            virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
> +                         _("no memory"));
> +            goto error;
> +        }
> +
> +        if (sexpr2string(root, buf, 4096) == 0) {

Use sizeof(buf) here instead of duplicating 4096 constant.

Regards,
Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]