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

Re: [libvirt] [PATCH 3/3] Remove wrong check for uml monitor response size



On Sun, Aug 15, 2010 at 11:08:43PM +0200, Soren Hansen wrote:
> Unless multiple threads are reading from the fd (?), I'm quite
> confident in my data. I dumped the whole monitor_response buffer right
> before and right after the recvfrom call along with the return value
> of recvfrom.  I'll rerun the tests tomorrow and show you the results.

I'm running this on another kernel right now and I'm not seeing the
problem. I'll try again with the kernel I used a couple of days ago.

> I'm not sure if I pointed this out in my initial e-mail, but even if I
> didn't have this recvfrom problem, the check seems odd to my eye. Is
> the monitor really going to send a max sized datagram each time? I
> would have expected it to only send a datagram the size of the header
> + the length of the data.

My hunch here seems correct though.

I've applied this diff:
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 9cf669f..c289ad3 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -729,8 +733,13 @@ static int umlMonitorCommand(const struct uml_driver *driver,
     do {
         ssize_t nbytes;
         addrlen = sizeof(addr);
+        VIR_DEBUG("res.error: %d, res.extra: %d, res.length: %d, res.data: %.*s",
+                          res.error, res.extra, res.length, res.length, res.data);
         nbytes = recvfrom(priv->monitor, &res, sizeof res, 0,
                           (struct sockaddr *)&addr, &addrlen);
+        VIR_DEBUG("nbytes: %d", nbytes);
+        VIR_DEBUG("res.error: %d, res.extra: %d, res.length: %d, res.data: %.*s",
+                          res.error, res.extra, res.length, res.length, res.data);
         if (nbytes < 0) {
             if (errno == EAGAIN || errno == EINTR)
                 continue;


And I get this output:
11:28:14.602: debug : umlMonitorCommand:702 : Run command 'config con0'
11:28:14.602: debug : umlMonitorCommand:737 : res.error: 5, res.extra: 0, res.length: 4096, res.data: 
11:28:14.602: debug : umlMonitorCommand:740 : nbytes: 28
11:28:14.602: debug : umlMonitorCommand:742 : res.error: 0, res.extra: 0, res.length: 16, res.data: pts:/dev/pts/31
11:28:14.602: debug : umlMonitorCommand:771 : Command reply is 'pts:/dev/pts/31'

So the size of the response datagram isn't sizeof(res) as the check in
uml_driver.c expects, but rather sizeof(res.error) + sizeof(res.extra) +
sizeof(res.length) + res.length.

-- 
Soren Hansen <soren linux2go dk>
Systems Architect, The Rackspace Cloud
Ubuntu Developer


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