return r;
}
librbd::Image *image = NULL;
- image = rbd.image_open(pool, imgname);
- if (!image) {
+ r = rbd.open(pool, image, imgname);
+ if (r < 0) {
cerr << "failed to open image" << std::endl;
return r;
}
static void err_exit(librados::pool_t pool, librbd::Image *image = NULL)
{
if (image)
- image->close();
+ delete image;
rados.close_pool(pool);
rados.shutdown();
exit(1);
(opt_cmd == OPT_RESIZE || opt_cmd == OPT_INFO || opt_cmd == OPT_SNAP_LIST ||
opt_cmd == OPT_SNAP_CREATE || opt_cmd == OPT_SNAP_ROLLBACK ||
opt_cmd == OPT_SNAP_REMOVE || opt_cmd == OPT_EXPORT || opt_cmd == OPT_WATCH)) {
- image = rbd.image_open(pool, imgname);
- if (!image) {
- cerr << "error opening image " << imgname << std::endl;
+ r = rbd.open(pool, image, imgname);
+ if (r < 0) {
+ cerr << "error opening image " << imgname << ": " << strerror(r) << std::endl;
err_exit(pool);
}
}
}
if (image)
- image->close();
+ delete image;
rados.close_pool(pool);
rados.shutdown();