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

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

 



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

--
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]