From 2d5eceef0c9fa94e53575c5917c18f676b1367cc Mon Sep 17 00:00:00 2001 From: Dave Finster Date: Tue, 29 Sep 2015 09:30:10 +1000 Subject: [PATCH 1/2] Added Name and Size output to vmunbundle get_header in the case of processing raw JSON. This is required to allow VM.js receive to function when passed raw JSON instead of the output of vmadm send --- src/vmunbundle.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vmunbundle.c b/src/vmunbundle.c index 86f181f5b..d8c1f5929 100644 --- a/src/vmunbundle.c +++ b/src/vmunbundle.c @@ -253,18 +253,22 @@ get_header(int fd, header_t *header, int fallback_to_raw) * handles the case where you just pipe raw JSON to vmadm receive. * */ + size_t chunk_size = 0; fprintf(stderr, "No magic! Dumping raw JSON.\n"); (void) write_bytes(1, data, data_size); while ((nread = read_bytes(fd, (char *)data, VMBUNDLE_HEADER_SIZE)) > 0) { fprintf(stderr, "got %d bytes\n", nread); + chunk_size += nread; (void) write_bytes(1, data, nread); } if (nread < 0) { fprintf(stderr, "Error %d reading raw data\n", nread); return (-1); } + fprintf(stderr, "Name: [JSON]\n"); + fprintf(stderr, "Size: %zu\n", chunk_size); return (-2); } else { fprintf(stderr, "No magic!\n"); From fbe63de4f9d47cb13847e03b96512b9ddb86b97e Mon Sep 17 00:00:00 2001 From: Dave Finster Date: Tue, 29 Sep 2015 17:20:30 +1000 Subject: [PATCH 2/2] chunk_size needs to be initialised to data_size --- src/vmunbundle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vmunbundle.c b/src/vmunbundle.c index d8c1f5929..be103e114 100644 --- a/src/vmunbundle.c +++ b/src/vmunbundle.c @@ -253,7 +253,7 @@ get_header(int fd, header_t *header, int fallback_to_raw) * handles the case where you just pipe raw JSON to vmadm receive. * */ - size_t chunk_size = 0; + size_t chunk_size = data_size; fprintf(stderr, "No magic! Dumping raw JSON.\n"); (void) write_bytes(1, data, data_size); while ((nread = read_bytes(fd, (char *)data,