{"id":815743,"url":"http://patchwork.ozlabs.org/api/patches/815743/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170919165226.23022-25-marcandre.lureau@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170919165226.23022-25-marcandre.lureau@redhat.com>","list_archive_url":null,"date":"2017-09-19T16:52:23","name":"[v2,24/27] vhost-user-scsi: use glib logging","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4a7af26bcf97a34ecedbb70e13820ada5794f3b1","submitter":{"id":66774,"url":"http://patchwork.ozlabs.org/api/people/66774/?format=json","name":"Marc-André Lureau","email":"marcandre.lureau@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170919165226.23022-25-marcandre.lureau@redhat.com/mbox/","series":[{"id":3931,"url":"http://patchwork.ozlabs.org/api/series/3931/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3931","date":"2017-09-19T16:51:59","name":"vhost-user-scsi: code clean-up","version":2,"mbox":"http://patchwork.ozlabs.org/series/3931/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815743/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815743/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=marcandre.lureau@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxVbr6KR1z9rvt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 03:43:52 +1000 (AEST)","from localhost ([::1]:44397 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duMYo-0007eD-UA\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 13:43:50 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:47685)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <marcandre.lureau@redhat.com>) id 1duLnC-0006iG-Du\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:54:41 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <marcandre.lureau@redhat.com>) id 1duLnB-0002uS-1i\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:54:38 -0400","from mx1.redhat.com ([209.132.183.28]:36960)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <marcandre.lureau@redhat.com>)\n\tid 1duLnA-0002tx-Ov\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:54:36 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id B3DDE4A6E9;\n\tTue, 19 Sep 2017 16:54:35 +0000 (UTC)","from localhost (ovpn-112-56.ams2.redhat.com [10.36.112.56])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D2B9D5D6A6;\n\tTue, 19 Sep 2017 16:54:32 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com B3DDE4A6E9","From":"=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Tue, 19 Sep 2017 18:52:23 +0200","Message-Id":"<20170919165226.23022-25-marcandre.lureau@redhat.com>","In-Reply-To":"<20170919165226.23022-1-marcandre.lureau@redhat.com>","References":"<20170919165226.23022-1-marcandre.lureau@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tTue, 19 Sep 2017 16:54:35 +0000 (UTC)","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH v2 24/27] vhost-user-scsi: use glib logging","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"pbonzini@redhat.com, felipe@nutanix.com, changpeng.liu@intel.com,\n\t=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\tf4bug@amsat.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"- PLOG is unused\n- code is compiled out unless debug is enabled\n- logging is too verbose\n- you can pipe to ts to have timestamp if needed, or use structured\n  logging with more recent glib\n\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nReviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n---\n contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++----------------------\n 1 file changed, 21 insertions(+), 56 deletions(-)","diff":"diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c\nindex 2e1100dea3..ff817d6643 100644\n--- a/contrib/vhost-user-scsi/vhost-user-scsi.c\n+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c\n@@ -18,42 +18,6 @@\n \n #include <glib.h>\n \n-/* #define VUS_DEBUG 1 */\n-\n-/** Log helpers **/\n-\n-#define PPRE                                                          \\\n-    struct timespec ts;                                               \\\n-    char   timebuf[64];                                               \\\n-    struct tm tm;                                                     \\\n-    (void)clock_gettime(CLOCK_REALTIME, &ts);                         \\\n-    (void)strftime(timebuf, 64, \"%Y%m%d %T\", gmtime_r(&ts.tv_sec, &tm))\n-\n-#define PEXT(lvl, msg, ...) do {                                      \\\n-    PPRE;                                                             \\\n-    fprintf(stderr, \"%s.%06ld \" lvl \": %s:%s():%d: \" msg \"\\n\",        \\\n-            timebuf, ts.tv_nsec / 1000,                               \\\n-            __FILE__, __func__, __LINE__, ## __VA_ARGS__);            \\\n-} while (0)\n-\n-#define PNOR(lvl, msg, ...) do {                                      \\\n-    PPRE;                                                             \\\n-    fprintf(stderr, \"%s.%06ld \" lvl \": \" msg \"\\n\",                    \\\n-            timebuf, ts.tv_nsec / 1000, ## __VA_ARGS__);              \\\n-} while (0)\n-\n-#ifdef VUS_DEBUG\n-#define PDBG(msg, ...) PEXT(\"DBG\", msg, ## __VA_ARGS__)\n-#define PERR(msg, ...) PEXT(\"ERR\", msg, ## __VA_ARGS__)\n-#define PLOG(msg, ...) PEXT(\"LOG\", msg, ## __VA_ARGS__)\n-#else\n-#define PDBG(msg, ...) { }\n-#define PERR(msg, ...) PNOR(\"ERR\", msg, ## __VA_ARGS__)\n-#define PLOG(msg, ...) PNOR(\"LOG\", msg, ## __VA_ARGS__)\n-#endif\n-\n-/** vhost-user-scsi specific definitions **/\n-\n #define VUS_ISCSI_INITIATOR \"iqn.2016-11.com.nutanix:vhost-user-scsi\"\n \n typedef struct VusIscsiLun {\n@@ -168,27 +132,28 @@ static int vus_iscsi_add_lun(VusIscsiLun *lun, char *iscsi_uri)\n \n     iscsi_ctx = iscsi_create_context(VUS_ISCSI_INITIATOR);\n     if (!iscsi_ctx) {\n-        PERR(\"Unable to create iSCSI context\");\n+        g_warning(\"Unable to create iSCSI context\");\n         return -1;\n     }\n \n     iscsi_url = iscsi_parse_full_url(iscsi_ctx, iscsi_uri);\n     if (!iscsi_url) {\n-        PERR(\"Unable to parse iSCSI URL: %s\", iscsi_get_error(iscsi_ctx));\n+        g_warning(\"Unable to parse iSCSI URL: %s\", iscsi_get_error(iscsi_ctx));\n         goto fail;\n     }\n \n     iscsi_set_session_type(iscsi_ctx, ISCSI_SESSION_NORMAL);\n     iscsi_set_header_digest(iscsi_ctx, ISCSI_HEADER_DIGEST_NONE_CRC32C);\n     if (iscsi_full_connect_sync(iscsi_ctx, iscsi_url->portal, iscsi_url->lun)) {\n-        PERR(\"Unable to login to iSCSI portal: %s\", iscsi_get_error(iscsi_ctx));\n+        g_warning(\"Unable to login to iSCSI portal: %s\",\n+                  iscsi_get_error(iscsi_ctx));\n         goto fail;\n     }\n \n     lun->iscsi_ctx = iscsi_ctx;\n     lun->iscsi_lun = iscsi_url->lun;\n \n-    PDBG(\"Context %p created for lun 0: %s\", iscsi_ctx, iscsi_uri);\n+    g_debug(\"Context %p created for lun 0: %s\", iscsi_ctx, iscsi_uri);\n \n out:\n     if (iscsi_url) {\n@@ -230,7 +195,7 @@ static int get_cdb_len(uint8_t *cdb)\n     case 4: return 16;\n     case 5: return 12;\n     }\n-    PERR(\"Unable to determine cdb len (0x%02hhX)\", cdb[0] >> 5);\n+    g_warning(\"Unable to determine cdb len (0x%02hhX)\", cdb[0] >> 5);\n     return -1;\n }\n \n@@ -252,7 +217,7 @@ static int handle_cmd_sync(struct iscsi_context *ctx,\n \n     if (!(!req->lun[1] && req->lun[2] == 0x40 && !req->lun[3])) {\n         /* Ignore anything different than target=0, lun=0 */\n-        PDBG(\"Ignoring unconnected lun (0x%hhX, 0x%hhX)\",\n+        g_debug(\"Ignoring unconnected lun (0x%hhX, 0x%hhX)\",\n              req->lun[1], req->lun[3]);\n         rsp->status = SCSI_STATUS_CHECK_CONDITION;\n         memset(rsp->sense, 0, sizeof(rsp->sense));\n@@ -295,10 +260,10 @@ static int handle_cmd_sync(struct iscsi_context *ctx,\n         task->iovector_in.niov = in_len;\n     }\n \n-    PDBG(\"Sending iscsi cmd (cdb_len=%d, dir=%d, task=%p)\",\n+    g_debug(\"Sending iscsi cmd (cdb_len=%d, dir=%d, task=%p)\",\n          cdb_len, dir, task);\n     if (!iscsi_scsi_command_sync(ctx, 0, task, NULL)) {\n-        PERR(\"Error serving SCSI command\");\n+        g_warning(\"Error serving SCSI command\");\n         g_free(task);\n         return -1;\n     }\n@@ -316,7 +281,7 @@ static int handle_cmd_sync(struct iscsi_context *ctx,\n \n     g_free(task);\n \n-    PDBG(\"Filled in rsp: status=%hhX, resid=%u, response=%hhX, sense_len=%u\",\n+    g_debug(\"Filled in rsp: status=%hhX, resid=%u, response=%hhX, sense_len=%u\",\n          rsp->status, rsp->resid, rsp->response, rsp->sense_len);\n \n     return 0;\n@@ -332,7 +297,7 @@ static void vus_panic_cb(VuDev *vu_dev, const char *buf)\n \n     vdev_scsi = container_of(vu_dev, VusDev, vu_dev);\n     if (buf) {\n-        PERR(\"vu_panic: %s\", buf);\n+        g_warning(\"vu_panic: %s\", buf);\n     }\n \n     g_main_loop_quit(vdev_scsi->loop);\n@@ -373,19 +338,19 @@ static void vus_proc_req(VuDev *vu_dev, int idx)\n \n     vdev_scsi = container_of(vu_dev, VusDev, vu_dev);\n     if (idx < 0 || idx >= VHOST_MAX_NR_VIRTQUEUE) {\n-        PERR(\"VQ Index out of range: %d\", idx);\n+        g_warning(\"VQ Index out of range: %d\", idx);\n         vus_panic_cb(vu_dev, NULL);\n         return;\n     }\n \n     vq = vu_get_queue(vu_dev, idx);\n     if (!vq) {\n-        PERR(\"Error fetching VQ (dev=%p, idx=%d)\", vu_dev, idx);\n+        g_warning(\"Error fetching VQ (dev=%p, idx=%d)\", vu_dev, idx);\n         vus_panic_cb(vu_dev, NULL);\n         return;\n     }\n \n-    PDBG(\"Got kicked on vq[%d]@%p\", idx, vq);\n+    g_debug(\"Got kicked on vq[%d]@%p\", idx, vq);\n \n     while (1) {\n         VuVirtqElement *elem;\n@@ -394,23 +359,23 @@ static void vus_proc_req(VuDev *vu_dev, int idx)\n \n         elem = vu_queue_pop(vu_dev, vq, sizeof(VuVirtqElement));\n         if (!elem) {\n-            PDBG(\"No more elements pending on vq[%d]@%p\", idx, vq);\n+            g_debug(\"No more elements pending on vq[%d]@%p\", idx, vq);\n             break;\n         }\n-        PDBG(\"Popped elem@%p\", elem);\n+        g_debug(\"Popped elem@%p\", elem);\n \n         assert(!(elem->out_num > 1 && elem->in_num > 1));\n         assert(elem->out_num > 0 && elem->in_num > 0);\n \n         if (elem->out_sg[0].iov_len < sizeof(VirtIOSCSICmdReq)) {\n-            PERR(\"Invalid virtio-scsi req header\");\n+            g_warning(\"Invalid virtio-scsi req header\");\n             vus_panic_cb(vu_dev, NULL);\n             break;\n         }\n         req = (VirtIOSCSICmdReq *)elem->out_sg[0].iov_base;\n \n         if (elem->in_sg[0].iov_len < sizeof(VirtIOSCSICmdResp)) {\n-            PERR(\"Invalid virtio-scsi rsp header\");\n+            g_warning(\"Invalid virtio-scsi rsp header\");\n             vus_panic_cb(vu_dev, NULL);\n             break;\n         }\n@@ -437,7 +402,7 @@ static void vus_queue_set_started(VuDev *vu_dev, int idx, bool started)\n     assert(vu_dev);\n \n     if (idx < 0 || idx >= VHOST_MAX_NR_VIRTQUEUE) {\n-        PERR(\"VQ Index out of range: %d\", idx);\n+        g_warning(\"VQ Index out of range: %d\", idx);\n         vus_panic_cb(vu_dev, NULL);\n         return;\n     }\n@@ -445,7 +410,7 @@ static void vus_queue_set_started(VuDev *vu_dev, int idx, bool started)\n     vq = vu_get_queue(vu_dev, idx);\n \n     if (idx == 0 || idx == 1) {\n-        PDBG(\"queue %d unimplemented\", idx);\n+        g_debug(\"queue %d unimplemented\", idx);\n     } else {\n         vu_set_queue_handler(vu_dev, vq, started ? vus_proc_req : NULL);\n     }\n@@ -462,7 +427,7 @@ static gboolean vus_vhost_cb(gpointer data)\n     assert(vu_dev);\n \n     if (!vu_dispatch(vu_dev) != 0) {\n-        PERR(\"Error processing vhost message\");\n+        g_warning(\"Error processing vhost message\");\n         vus_panic_cb(vu_dev, NULL);\n         return G_SOURCE_REMOVE;\n     }\n","prefixes":["v2","24/27"]}