예제 #1
0
static int
xenstore_puts(int domid, const char *val, const char *fmt, ...)
{
    int rc;
    va_list ap;

    va_start(ap, fmt);
    rc = xenstore_putsv(domid, val, fmt, ap);
    va_end(ap);
    return rc;
}
static int hvmloader_flag(const char *key)
{
    /* Params going to hvmloader need to convert "true" -> '1' as Xapi gets
     * this wrong when migrating from older hosts. */

    char *val = xenstore_gets("%s",key);
    int ret = -1;

    if ( val )
    {
        if ( !strcmp(val, "1") )
        {
            ret = 1;
            goto out;
        }
        else if ( !strcmp(val, "0") )
        {
            ret = 0;
            goto out;
        }
        if ( !strcasecmp(val, "true") )
            ret = 1;
        else
        {
            errno = 0;
            ret = strtol(val, NULL, 0);
            if ( errno )
                ret = 0;
        }

        xg_info("HVMLoader error: Fixing up key '%s' from '%s' to '%d'\n", key, val, ret);
        xenstore_putsv(key, "%d", !!ret);
    }
    else
        xenstore_puts(key, "0");

 out:
    free(val);
    return ret;
}
int xenstore_puts(const char *key, const char *val)
{
    return xenstore_putsv(key, "%s", val);
}