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

Richard W.M. Jones rjones at redhat.com
Mon Oct 15 11:47:59 UTC 2007


+    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 ...

Rich.

-- 
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20071015/9edad63f/attachment-0001.bin>


More information about the libvir-list mailing list