{"action":"created","issue":{"url":"https://api.github.com/repos/joyent/smartos-live/issues/65","labels_url":"https://api.github.com/repos/joyent/smartos-live/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/joyent/smartos-live/issues/65/comments","events_url":"https://api.github.com/repos/joyent/smartos-live/issues/65/events","html_url":"https://github.com/joyent/smartos-live/issues/65","id":3391478,"number":65,"title":"Allow raw disks (or other GZ devices) to be used by guests","user":{"login":"trisk","id":207920,"avatar_url":"https://avatars.githubusercontent.com/u/207920?v=3","gravatar_id":"","url":"https://api.github.com/users/trisk","html_url":"https://github.com/trisk","followers_url":"https://api.github.com/users/trisk/followers","following_url":"https://api.github.com/users/trisk/following{/other_user}","gists_url":"https://api.github.com/users/trisk/gists{/gist_id}","starred_url":"https://api.github.com/users/trisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trisk/subscriptions","organizations_url":"https://api.github.com/users/trisk/orgs","repos_url":"https://api.github.com/users/trisk/repos","events_url":"https://api.github.com/users/trisk/events{/privacy}","received_events_url":"https://api.github.com/users/trisk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"joshwilsdon","id":78194,"avatar_url":"https://avatars.githubusercontent.com/u/78194?v=3","gravatar_id":"","url":"https://api.github.com/users/joshwilsdon","html_url":"https://github.com/joshwilsdon","followers_url":"https://api.github.com/users/joshwilsdon/followers","following_url":"https://api.github.com/users/joshwilsdon/following{/other_user}","gists_url":"https://api.github.com/users/joshwilsdon/gists{/gist_id}","starred_url":"https://api.github.com/users/joshwilsdon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshwilsdon/subscriptions","organizations_url":"https://api.github.com/users/joshwilsdon/orgs","repos_url":"https://api.github.com/users/joshwilsdon/repos","events_url":"https://api.github.com/users/joshwilsdon/events{/privacy}","received_events_url":"https://api.github.com/users/joshwilsdon/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2012-02-26T16:02:12Z","updated_at":"2015-10-30T16:59:42Z","closed_at":null,"body":"I have existing pools which I want to be managed by KVM guests running illumos and NexentaStor. On the older vmadmd in smartos-live 201109xx, I was able to add the physical disks by overloading the 'model' net-attr for devices.\r\n\r\nFor example, I have a\r\n```\r\n<device match=\"/dev/rdsk/c2t514d0\">\r\n    <net-attr name=\"model\" value=\"none,id=sata-disk0\"/>\r\n</device>\r\n```\r\nCorresponding to 'qemu-extra-opts' contents \"-device ahci,id=ahci0,bus=pci.0,multifunction=on -device ide-drive,drive=sata0-disk0,bus=ahci0.0\".\r\n\r\nThis was converted into qemu arguments:\r\n\"-drive file=/dev/rdsk/c2t514d0,if=none,id=sata-disk0,index=1,media=disk\"\r\n\r\nThe current vmadmd does this instead and causes qemu to choke:\r\n\"-drive file=/dev/rdsk/c2t514d0,if=undefined,index=1,media=disk\"\r\n\r\nstartElement in VM.js assumes _all_ device elements are disks but only uses the net-attr child attributes for devices with paths matching \"/dev\\/.*disk[0-9]+\" when setting properties. It tries to use direct attributes for the device element as well but I don't think any are allowed by the zonecfg DTD. This results in \"undefined\" for the 'model' property for any devices not matching \"/dev\\/.*disk[0-9]+\".\r\n\r\n```javascript\r\n    } else if (where === 'zone.device') {\r\n        // new disk device\r\n        for (prop in attrs) {\r\n            if (XML_PROPERTIES.disk.hasOwnProperty(prop)) {\r\n                use = XML_PROPERTIES.disk[prop];\r\n                disk[use] = attrs[prop];\r\n            } else {\r\n                VM.log('DEBUG', 'unknown disk prop: ' + prop);\r\n            }\r\n        }\r\n        if (!obj.hasOwnProperty('devices')) {\r\n            obj.devices = {};\r\n        }\r\n        obj.devices[disk.path] = disk;\r\n        stack.push(disk.path);\r\n    } else if (where.match(/zone\\.device\\.\\/dev\\/.*disk[0-9]+\\.net-attr/)) {\r\n        if (XML_PROPERTIES.disk.hasOwnProperty(attrs.name)) {\r\n            use = XML_PROPERTIES.disk[attrs.name];\r\n            obj.devices[stack[2]][use] = attrs.value;\r\n        } else {\r\n            VM.log('DEBUG', 'unknown disk prop: ' + attrs.name);\r\n        }\r\n    }\r\n```\r\n\r\nOne alternative might be for vmadmd to ignore device elements without a 'model' net-attr, so invalid \"-drive\" arguments are not passed to qemu. This would also allow non-disk devices (audio, etc.) to be passed through.\r\n\r\nThis would leave \"-drive\" to be manually specified in the 'qemu-extra-opts' attr. A helpful addition might be to keep constructing \"-drive\" for devices with another net-attr, whose value is passed directly to qemu (as 'model' was previously).\r\n\r\nThis is obviously not a complete solution for external devices but would make my life a lot easier."},"comment":{"url":"https://api.github.com/repos/joyent/smartos-live/issues/comments/152586668","html_url":"https://github.com/joyent/smartos-live/issues/65#issuecomment-152586668","issue_url":"https://api.github.com/repos/joyent/smartos-live/issues/65","id":152586668,"user":{"login":"tomww","id":1033608,"avatar_url":"https://avatars.githubusercontent.com/u/1033608?v=3","gravatar_id":"","url":"https://api.github.com/users/tomww","html_url":"https://github.com/tomww","followers_url":"https://api.github.com/users/tomww/followers","following_url":"https://api.github.com/users/tomww/following{/other_user}","gists_url":"https://api.github.com/users/tomww/gists{/gist_id}","starred_url":"https://api.github.com/users/tomww/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomww/subscriptions","organizations_url":"https://api.github.com/users/tomww/orgs","repos_url":"https://api.github.com/users/tomww/repos","events_url":"https://api.github.com/users/tomww/events{/privacy}","received_events_url":"https://api.github.com/users/tomww/received_events","type":"User","site_admin":false},"created_at":"2015-10-30T16:59:42Z","updated_at":"2015-10-30T16:59:42Z","body":"Does a more current SmartOS version allow raw disks without patching?\r\n\r\nI would highly appreciate if this patch could be updated to work with a end-2015 SmartOS version.\r\nThe *js scripts have change too much since 2012 as the above would be a quick task for me.\r\n\r\nAs the files reside on the ramdisk, I would patch in the changed with a SMF startscript at boot time.\r\n\r\nThanks for having a look into this. A plus would be to have this integrated in the regular SmartOS code one day!\r\n@tomww"}}