-
Notifications
You must be signed in to change notification settings - Fork 292
Merge of qemu-datapath into REQ477/master branch #3522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
let path = String.sub params prefix_len (String.length params - prefix_len) in | ||
Db.VBD.set_device ~__context ~self ~value:path; | ||
let device_path = | ||
let nbd_prefix = "hack|nbd:unix:" in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will come up with a proper design, but for now, the strategy is to make sure the new code is isolated, and this "hack|..."
method is hopefully good enough for that.
let is_nbd = String.startswith nbd_prefix params in | ||
if is_nbd then begin | ||
let export_name = "qemu_node" in | ||
let unix_socket_path = params |> Astring.String.cuts ~empty:false ~sep:nbd_prefix |> List.hd |> String.split_on_char '|' |> List.hd in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will raise an horrible looking and hard to debug error if there are empty lists on the way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it's isolated to the qemu-datapath branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I could add a debug message above this with the content of params
, so that we now what we got in case one of the List.hd
s fail?
Or is there a concise way of doing something like List.hd
but with nice error messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding a preliminary debug with the params could be enough.
The only thing with List.hd
is probably to define your own hd_log
as something like
let hd_log logline = function
| h :: _ -> h
| [] -> debug logline; raise Not_found (* or whatever else List.hd raises *)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've added a debug line.
scripts/nbd_client_manager.py
Outdated
self._lock_file = open(self._path, 'w+') | ||
fcntl.flock(self._lock_file, flags) | ||
|
||
def unlock(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you add __enter__
and __exit__
as alias of lock
and unlock
you can use with FILE_LOCK:
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's a great idea, I'll add those :)
import fcntl | ||
|
||
|
||
LOGGER = logging.getLogger("nbd_client_manager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this logs at warning
level by default. Maybe adding a --verbose
or --level
to set the level to debug on demand could be useful if you want to read the debug logs below as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, good spot, I'll increase the logging level to debug
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 There is a LOGGER.setLogLevel()
call for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to do more configuration to redirect log messages into syslog using SysLogHandler
.
scripts/nbd_client_manager.py
Outdated
|
||
def __enter__(self): | ||
self._lock() | ||
return self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the return
if you don't need to do anything to the returned object. Returning None
is the default for functions and for context managers, and it is what happens if you omit the return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done
9dd9217
to
14f9855
Compare
Should I also add this |
I don't know. Ping @jonludlam |
Now logging should work fine:
|
I've decided to add it to |
269ab99
to
f997e17
Compare
Thanks for the review, I think I've addressed all the comments. I'll squash the fixes and merge if this is ok now. |
ocaml/xapi/xapi_vbd.ml
Outdated
Db.VBD.set_device ~__context ~self ~value:path; | ||
let device_path = | ||
let nbd_prefix = "hack|nbd:unix:" in | ||
let is_nbd = String.startswith nbd_prefix params in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should use Astring
here too :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you wish. The main xapi is still not ported to Astring at all, feel free to use Xstringext
here. If you use Astrig, you will porbably need to add it to the jbuiild and opam files as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done it now
8c013f1
to
f8e39b3
Compare
4cce019
to
c1555d6
Compare
We invoke the nbd_client_manager.py script for VBD.plug/unplug and in the static-vdis HA script in case it's needed. Signed-off-by: Gabor Igloi <gabor.igloi@citrix.com>
f8e39b3
to
8d776e8
Compare
Rebased on latest master |
Signed-off-by: Gabor Igloi gabor.igloi@citrix.com