Skip to contentSkip to conversation

ioemu: use asprintf instead of PATH_MAX

PATCH In review Samuel Thibault 3 participants 5 messages Jan 23, 2008 – Jan 24, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ioemu: use asprintf instead of PATH_MAX

Use asprintf instead of PATH_MAX, which POSIX says to be facultative.

tools/ioemu/target-i386-dm/helper2.c +3 -3
diff -r c364f80eb4b5 tools/ioemu/target-i386-dm/helper2.c
@@ -635,7 +635,7 @@
     extern int suspend_requested;
     CPUState *env = cpu_single_env;
     int evtchn_fd = xce_handle == -1 ? -1 : xc_evtchn_fd(xce_handle);
-    char qemu_file[PATH_MAX];
+    char *qemu_file;
     fd_set fds;
     int ret = 0;
 
@@ -665,9 +665,9 @@
         main_loop_wait(1); /* For the select() on events */
 
         /* Save the device state */
-        snprintf(qemu_file, sizeof(qemu_file), 
-                 "/var/lib/xen/qemu-save.%d", domid);
+        asprintf(&qemu_file, "/var/lib/xen/qemu-save.%d", domid);
         do_savevm(qemu_file);
+        free(qemu_file);
 
         xenstore_record_dm_state("paused");
#1 lore raw

tools/ioemu/target-i386-dm/helper2.c line 668

Quoted 7 lines · Samuel Thibault

Use asprintf instead of PATH_MAX, which POSIX says to be facultative.

tools/ioemu/target-i386-dm/helper2.c +1 -2
-        snprintf(qemu_file, sizeof(qemu_file), 
-                 "/var/lib/xen/qemu-save.%d", domid);
+        asprintf(&qemu_file, "/var/lib/xen/qemu-save.%d", domid);

Just a question - afaik asprintf is a unix-ism that isn't supported on windows. Will this cause problems if also pushed to upstream qemu?

Mike

Signature · 5 lines
Mike D. Day
IBM LTC
Cell: 919 412-3900
Sametime: [email protected] AIM: ncmikeday  Yahoo: ultra.runner
PGP key: http://www.ncultra.org/ncmike/pubkey.asc
#2 lore raw
Quoted 11 lines · Mike D. Day, le Wed 23 Jan 2008 15:53:47 -0500, a écrit :

tools/ioemu/target-i386-dm/helper2.c line 668

Quoted 7 lines · Samuel Thibault

Use asprintf instead of PATH_MAX, which POSIX says to be facultative.

tools/ioemu/target-i386-dm/helper2.c +1 -2
-        snprintf(qemu_file, sizeof(qemu_file), 
-                 "/var/lib/xen/qemu-save.%d", domid);
+        asprintf(&qemu_file, "/var/lib/xen/qemu-save.%d", domid);

Just a question - afaik asprintf is a unix-ism that isn't supported on windows. Will this cause problems if also pushed to upstream qemu?

qemu is quite often used in windows too so that would pose problem indeed. But I guess the /var/lib patch would too anyway :) And this part of the code is actually xen-specific.

Samuel

#3 lore raw
Quoted 10 lines · Samuel Thibault
Quoted 9 lines · Mike D. Day, le Wed 23 Jan 2008 15:53:47 -0500, a écrit :
Quoted 7 lines · Samuel Thibault

Use asprintf instead of PATH_MAX, which POSIX says to be facultative.

tools/ioemu/target-i386-dm/helper2.c +1 -2
-        snprintf(qemu_file, sizeof(qemu_file), 
-                 "/var/lib/xen/qemu-save.%d", domid);
+        asprintf(&qemu_file, "/var/lib/xen/qemu-save.%d", domid);
Quoted 6 lines
Quoted 2 lines

Just a question - afaik asprintf is a unix-ism that isn't supported on windows. Will this cause problems if also pushed to upstream qemu?

qemu is quite often used in windows too so that would pose problem indeed. But I guess the /var/lib patch would too anyway :) And this part of the code is actually xen-specific.

Yes, true. At a higher scope, what are current plans for a merge with upstream Qemu? Is the process to merge upstream or to continue maintaining the Xen differences out-of-tree?

thanks,

Mike

Signature · 5 lines
Mike D. Day
IBM LTC
Cell: 919 412-3900
Sametime: [email protected] AIM: ncmikeday  Yahoo: ultra.runner
PGP key: http://www.ncultra.org/ncmike/pubkey.asc
#4 lore raw
Quoted 10 lines · Mike D. Day
Quoted 6 lines
Quoted 2 lines

Just a question - afaik asprintf is a unix-ism that isn't supported on windows. Will this cause problems if also pushed to upstream qemu?

qemu is quite often used in windows too so that would pose problem indeed. But I guess the /var/lib patch would too anyway :) And this part of the code is actually xen-specific.

Yes, true. At a higher scope, what are current plans for a merge with upstream Qemu? Is the process to merge upstream or to continue maintaining the Xen differences out-of-tree?

We'd like the diff to be reduced of course, but it depends if anyone is enthusiastic enough to do the work.

-- Keir