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

Re: [Libvir] PATCH: Implement CDROM media change for QEMU/KVM driver



Richard W.M. Jones wrote:
> +    char *cmd;
> +    char *reply;
> +    /* XXX QEMU only supports a single CDROM for now */
> +    /*cmd = malloc(strlen("change ") + strlen(olddisk->dst) + 1 + 
> strlen(newdisk->src) + 2);*/
> +    cmd = malloc(strlen("change ") + strlen("cdrom") + 1 + 
> strlen(newdisk->src) + 2);
> +    if (!cmd) {
> +        qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_MEMORY, 
> "monitor command");
> +        return -1;
> +    }
> +    strcpy(cmd, "change ");
> +    /* XXX QEMU only supports a single CDROM for now */
> +    /*strcat(cmd, olddisk->dst);*/
> +    strcat(cmd, "cdrom");
> +    strcat(cmd, " ");
> +    strcat(cmd, newdisk->src);
> +    strcat(cmd, "\n");
> 
> Much as it irritates me to say it, a fixed-size buffer and snprintf 
> might be preferable here ...

Or asprintf.

-jim


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